I am having the same problem as this guy. The text will only show if SDL isnt in OpenGL mode. Being able to blit the text surface to an opengl texture then applying that texture to a quad sounds right but how can i convert an SDL_Surface* to an opengl texture?Quote:
>Just like the subject says, this is about using SDL_ttf with OpenGL.
>Does anyone know how I can get the text to show up on screen with the 3d
>Do I need to update the main video surface as well as call
>SDL_GL_SwapBuffers()? If so, what order do I call them in?
>I can get SDL_ttf to work on a 2D screen, but it doesn't display
>anything when OpenGL is enabled.
Yes, unless you use the (deprecated evil) SDL_OPENGLBLIT that won't work.
What you should do is use the surface returned by SDL_ttf to create an
OpenGL texture, and then draw a quad on-screen with that texture.
Btw, SDL blitting routines are very convenient to convert from one pixel
format to another, and thus can be used to painlessly convert your
surface to a format suitable for OpenGL texture creation.
i modified this function i found on gamedev.net forums but it foesnt work
Ive look at this for hours now an it looks like it should work. I have no idea what I'm doing wrong. GL_RGB should be GL_BGR but that wont compile for some reason...Code:
int convert_texture(SDL_Surface *surface)
glTexImage2D(GL_TEXTURE_2D, 0, 3, surface->w, surface->h,
0, GL_RGB, GL_UNSIGNED_BYTE, surface->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
Here is how I render it
SDL_Surface *text_surface = TTF_RenderText_Solid(font, "Courier 12", color );
GLuint tex = convert_texture(text_surface);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);