Texture2D iPhone SDK openGL

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

Do they have good tutorials to understand the Texture2D class?

In particular, I look at the initWithString method for printing text. As a way to implement, you get white text when you use it. I would like to change the method so that I can specify the color of the RGB text. Any help / pointers?

+3
source share
1 answer

Since the class uses only alpha texture (read the code!), It will be displayed in any color set by glColor. See this line in initWithData(which is called 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)before drawing the texture.

, GL_BLEND GL_COLOR_MATERIAL.

. .

+3

Source: https://habr.com/ru/post/1707560/


All Articles