views:

1510

answers:

1

I'm using the Texture2D class in an iPhone game using OpenGL ES.

Are their any good tutorials for understanding the Texture2D class?

Specifically I'm looking at the initWithString method for printing text. As the way it is implemented, you get white text when you use it. I would like to modify the method so I could specify the RGB color of the text. Any help / pointers?

+2  A: 

Because the class uses an alpha-only texture (read the code!), it will display in whatever color glColor has set. See this line in initWithData (which gets called by initWithString):

glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 
             width, height, 0, GL_ALPHA,
             GL_UNSIGNED_BYTE, data);

For red text, just call glColor4ub(255, 0, 0, 255) prior to drawing the texture.

Make sure you enable GL_BLEND and GL_COLOR_MATERIAL prior to drawing.

The class is small. I recommend you just read it.

Frank Krueger