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?
-
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 byinitWithString
):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
andGL_COLOR_MATERIAL
prior to drawing.The class is small. I recommend you just read it.
0 comments:
Post a Comment