/*-----------------------------------------------------------------
LOG
    GEM - Graphics Environment for Multimedia

    A texfont

    Copyright (c) 1997-1999 Mark Danks. mark@danks.org
    For information on usage and redistribution, and for a DISCLAIMER OF ALL
    WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.

-----------------------------------------------------------------*/

#ifndef INCLUDE_TEXFONT_H_
#define INCLUDE_TEXFONT_H_

#include "Base/TextBase.h"
#include "TexFont.h"

/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
    texfont
    
    Turns on texture mapping

KEYWORDS
    pix
    
DESCRIPTION

-----------------------------------------------------------------*/
class GEM_EXTERN texfont : public TextBase
{
    CPPEXTERN_HEADER(texfont, TextBase)

    public:

        //////////
        // Constructor
    	texfont(int argc, t_atom *argv);
    	
    protected:
    	
    	//////////
    	// Destructor
    	virtual ~texfont ();

    	//////////
    	// Do the rendering
    	virtual void 	render(GemState *state);

    	//////////
    	// Turn back off texture mapping
    	virtual void 	postrender(GemState *state);

    	//////////
    	// Establish texture object
    	virtual void	startRendering();

    	//////////
    	// Delete texture object
    	virtual void	stopRendering();
    	
        //////////
        // Turn on/off texture mapping
        void            textureOnOff(int on);

	//////////
	// Set up the texture state
	void			setUpTextureState();

        //////////
        int             m_textureOnOff;

        //////////
        GLuint			m_textureQuality;

	char*           m_fontname;

        //////////
        // Set the texture quality
        // [in] type - if == 0, then GL_NEAREST, else GL_LINEAR
        void            textureQuality(int type);

        //////////
        // Do we need to rebuild the display List
        int             m_rebuildList;

	//////////
	// The size of the texture (so we can use sub image)
	int				m_dataSize[3];

    	//////////
    	// The texture font object 
	TexFont *	    	m_textureObj;

    	//////////
    	// The font to use
    	virtual void   	fontNameMess(const char *filename) 
	  {
	    if (m_fontname) delete m_fontname;
	    m_fontname = new char[sizeof(filename)+1];
	    strcpy(m_fontname,filename);
	  };

	//////////
	// Set the font size
	virtual void	setFontSize(int size) {};
		
	//////////
	// Set the precision for rendering
	virtual void	setPrecision(float prec) {};


	//// console style output
	void floatmess(int i);
	int m_current;
	int m_width;
	int m_height;
    	
	private:

    	//////////
    	// static member functions
    	static void 	floatMessCallback(void *data, float n);
    	static void 	textureMessCallback(void *data, t_floatarg n);
    	static void 	textMessCallback(void *data, t_floatarg n);
};

#endif	// for header file
