Hello,
I am an OpenGL beginner. So please forgive me if I don’t describe thing as you’d expect
I have written a little font engine for iOS that essentially is rendering a string to a bitmap context, creates a bitmap from the context and then converts the bitmap into an OpenGL texture. It works fine, except when it comes to color.
The texture that I am generating is a grayscale texture. Why? Because I have the code from a tutorial and it said that a RGBA texture would be a waste.
So when I render my texture, I can remove the alpha channel and see a nice white text on the screen. In order to get it colored, I thought I just hand over some color attributes to the verteces that render the texture. But I end up with either one of two unsatisfying results.
I am using OpenGL 2.0. My development platform is iOS.
Result 1:
Nice red color, but the alpha channel is opaque.
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Result 2:
Alpha removed, but the red looks pale.
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
I am setting this option in the shader (a GLKBaseEffect)
effect.texture2d0.envMode = GLKTextureEnvModeModulate
Is it even possible to color my grayscale texture in a way that the alpha channel is removed, but the colors turn out nicely? Or should I use RGBA instead when generating the texture in the first place?