I’m calling TTF_RenderText_Blended
and loading the result into a GL texture. This is resulting in only the blue/alpha channel being set, like the color has been ignored.
SDL_Color c = {255,255,255,255};
sdl_tex = TTF_RenderText_Blended( font, text, c );
Then copy to texture:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, sdl_tex.w, sdl_tex.h,
0, GL_RGBA, GL_UNSIGNED_BYTE, sdl_tex.pixels);
I’m using this small fragment shader to test:
#version 130
out vec4 LFragment;
in highp vec2 texCoord;
uniform sampler2D tex;
void main() {
vec4 r = texture2D(tex, texCoord);
LFragment = vec4(r.xyz*r.w,r.w);
}
I get the correct text shape, but only the blue channel appears set. It appears that the SDL_Color
really isn’t being used at all. I can specify whatever values I want for g,b,a
and it always has the same result. Only changing the r
value changes the intensity of the result.
The same loading/drawing approach works when loading images with SDL_image, so I’m assuming it’s something particular about SDF_ttf.
Note my code is written in Leaf, not C, just converted the key points for clarity.