Create an 8-bit palettized surface and render the given text at fast quality with the given font and color. The 0 pixel value is the colorkey, giving a transparent background, and the 1 pixel value is set to the text color. The colormap is set to have the desired foreground color at index 1, this allows you to change the color without having to render the text again. Colormap index 0 is of course not drawn, since it is the colorkey, and thus transparent, though it’s actual color is 255 minus each RGB component of the foreground.
Does it have something to do with the way i should use glTexImage2D()? it says the surface is 8-bit, how do i create through glTexImage2D()? How do you set up glTexImage2D() to accept an 8bit surface whose 0 pixel value is the colorkey?
TTF_RenderText_Blended seems more appropriate for OpenGL textures.
8-bit palettized textures are rarely available, so you have to convert to RGBA (if 0 then 1,1,1,0 else if 1 then 1,1,1,1) and then use alpha testing. And you will have jaggies around your letters.
RGBA high quality text is great and smooth ! Blending textures is easy in opengl.
I don’t know well SDL_Surface, but you should be able to extract an array of values to convert to a texture. Don’t forget that opengl textures must be power of two.
yeah, but TTF_RenderText_Blended() returns an ARGB surface…how do i tell glTexImage2D() that i’m giving it an ARGB surface? i only know of GL_RGB, GL_BGR, GL_RGBA, GL_COLOR_INDEX…