Click here to Skip to main content
15,886,063 members
Articles / Mobile Apps / iPhone

FreeType on OpenGL ES (iPhone)

Rate me:
Please Sign up or sign in to vote.
4.75/5 (10 votes)
24 Nov 2010CPOL4 min read 86.5K   3K   27  
Faster, smarter and better looking fonts rendered with OpenGL ES
#ifndef _GLCALLBATCHER_H_INCLUDED_
#define _GLCALLBATCHER_H_INCLUDED_

// AtlasImage objects send their quads to GLCallBatcher for rendering.
// GLCallBatcher strings the quads together into triangle lists.
// All quads with same alpha, colour, transpancy and texture are rendered together 
// with one call to glDrawElements
class GLCallBatcher
{
public:
	GLCallBatcher();
	~GLCallBatcher();
	void AddQuad(GLuint textureID, int color, float alpha, bool transparent, bool smooth,
		const float* pTexCoords, const float* pVertices);
	void RenderCurr();
	void OutputData(ostringstream& os);
	void ResetStats()
	{
		m_drawCallCount = 0;
		m_quadCount = 0;
	}
	void SetAttribs(GLuint textureID, int color, float alpha, bool transparent, bool smooth);
	void AddQuad(const float* pTexCoords, const float* pVertices);
	void Release();
private:
	void Reallocate(int increase);
	float* m_pVertexData;		// storage of vertex array
	GLushort* m_pIndices;	// indices of quads
	int m_numQuads;			// current number of quads waiting to be rendered
	int m_sizeCache;		// current amount of quads that can fit in the arrays
	float m_alpha;			// alpha value of current quads
	int m_color;			// colour tint of current quads
	GLuint m_textureID;		// texture of current quads
	bool m_transparent;		// are current quads transparent
	int m_drawCallCount;	// statistical info
	int m_quadCount;
	bool m_smooth;
};





#endif // _GLCALLBATCHER_H_INCLUDED_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Astronautz
Spain Spain
After working in the software industry for many years, I've started my own games company that specialises in strategy games for mobile platforms.

Comments and Discussions