   SDL, OpenGL, and Bitmap Fonts
  Hello,I've got a question about Bitmap Fonts. In the past, I just used SDL blittings and then, of course, everything works fine with Bitmap Fonts. No problem.Now, I'm using SDL and OpenGL, so I can't blit stuff anymore on the main window. At first a little question on that topic: Is this really completely impossible or is there some way to accomplish this? I read about a certain flag (I don't remember it anymore), but I also read that it's a bad idea to use it (and I think it didn't even work on my machine, but it's some time ago).Okay, the standard way is now to blit stuff into textures, and then display those textures on quads. But I've got a question about it: Would it be better to blit the whole text into one SDL_Surface, then convert this into a texture, and then display that on a single quad? Or would it be better to divide the Bitmap Font into separate letter textures (at initialization stage of course), and then display the text by drawing a quad for every single letter?I'd think that the first option would be better for performance, but I might be wrong. It would also be possible to cache this SDL_Surface, as long as the text on it doesn't change.Are there any alternative suggestions on how to do that? Or should I stick with one of the above?Nice greetingsZeHa   
Quote:Okay, the standard way is now to blit stuff into textures, and then display those textures on quads. But I've got a question about it: Would it be better to blit the whole text into one SDL_Surface, then convert this into a texture, and then display that on a single quad? Or would it be better to divide the Bitmap Font into separate letter textures (at initialization stage of course), and then display the text by drawing a quad for every single letter?Isn't that the question! With the first option it will be slow to change the text, but once you have it draw to a surface it will be fast to blit. The second option will be slower for static text, but quicker for dynamic text. It is really your choice, you may want to consider both options. Now, I would avoid using SDL_Surfaces for loading textures into OpenGL, especially for text, you may want to consider using libpng directly, SOIL, devIL, or write your own BMP/TGA loader.   ;  Or write a TTF to texture converter. I was able to go from SDL_ttf to a texture for each letter fairly easily. This lets the program display dynamic text fairly well from any arbitrary ttf file you distribute with your program.   ;  If you were going to do that, I would just use Freetype.   ;  Well I don't think I will use TTF, I prefer "real" bitmap fonts which are build directly as a bitmap, not from a TTF.@ Portmanteau: Well, the thing about using both for different purposes doesn't sound bad. I'll think about that. But in this case, there doesn't seem to be any third way, I assume?Quote:Now, I would avoid using SDL_Surfaces for loading textures into OpenGL, especially for text, you may want to consider using libpng directly, SOIL, devIL, or write your own BMP/TGA loader.What is the reason for this? With SDL, I can perfectly load PNGs and turn them into textures (with a small code snippet). Is it too slow? Does libpng have a direct "makeOpenGlTextureOutOfIt()" method?   ;  Often used strings can(should?) be cached to a texture and drawn with a single quad.  I just build them up character by character, as I never have enough text on the screen to make a difference, and that is a simpler route.As for tools, in case you haven't seen it, you may want to try the AngelCode Bitmap Font Generator.  I also wrote a similar tool using signed distance fields (see this thread).(And SOIL does have a single function load image to OpenGL texture function [8^)   ;  Nice :) I'll try SOIL!Btw, I tried to find the license of SOIL and finally saw that it was public domain, but here's a small tip: Just as you have "Introduction", "Download", "Features" on your page, make an additional headline "License" and write one sentence about it being public domain :) it's much easier to find if you're just scanning the page's text.   ;  Using SDL_OPENGLBLIT as a flag while setting the video mode allows for blitting over the OpenGL context. I hear this method is deprecated, can anyone confirm? I still use it in my engines.   ;Quote:Original post by EctaraUsing SDL_OPENGLBLIT as a flag while setting the video mode allows for blitting over the OpenGL context. I hear this method is deprecated, can anyone confirm? I still use it in my engines.It is, see the comment here:Quote:SDL_OPENGLBLIT Create an OpenGL rendering context, like above, but allow normal blitting operations. The screen (2D) surface may have an alpha channel, and SDL_UpdateRects must be used for updating changes to the screen surface. NOTE: This option is kept for compatibility only, and will be removed in next versions. Is not recommended for new code.