   Bmp font characters
  I'm trying to get a 'console' type font (in this case fixedsys) converted into a bitmap font.  I am using AngelCode BMfont but it looks like I must select the characters in the order I want them to appear in the bitmap.  If i use the 'select all' method they seem to be arranged almost randomly.The question is, if I wanted to use a 16x16 grid of characters for a bitmap font, how should the characters be ordered?  I thought it would be by ascii but I don't know which characters should be assigned to which control characters   
  What's the general method to getting fonts to display on the screen?I am using SDL with OpenGL.Sfont doesn't look like it's a full ascii character set.BFont website goes to a dead link.I see the NeHe tutorial on bitmap fonts calls some Windows function "CreateFont()"I don't have any windows specific code in my program and would like to keep it that way.I am thinking I need to know:1)String of characters to show on screen including dynamic variables2)Where to draw on screenBut the (harder part which I have never done) how to:a) Build texture from different parts of the bmp fileb) Render the texture in orthographic mode on top of sceneWouldn't it be faster if the characters in the image were on a uniform grid to avoid doing per-character arithmetic?  The space saving by packing like that seems minimal with only 256 chars.   ;Quote:Original post by PrestoChungWhat's the general method to getting fonts to display on the screen?Depends on your needs. Vertex Arrays are fine if you're working with older contexts, but Vertex Buffer Objects are required for Open GL 3+ contexts.Quote:Sfont doesn't look like it's a full ascii character set.You'll find that a few of the first 256 characters are a little abnormal, and subsequently aren't given pretty forms, and some are probably dropped all together (new line / return characters, etc.).Quote:I am thinking I need to know:1)String of characters to show on screen including dynamic variables2)Where to draw on screenThese are basically left up to you to sort out. String streams come in handy when building strings with numbers.Quote:But the (harder part which I have never done) how to:a) Build texture from different parts of the bmp fileYou only need to create one texture. It's the texture coordinates that change.Quote:b) Render the texture in orthographic mode on top of sceneThis also depends on how you do things (your own matrices, etc.). Once upon a time, it was done like this:glMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();//depending on how you draw your text, this will need to be changedglOrtho(0,40,-30,0,-1,1);glMatrixMode(GL_MODELVIEW);glPushMatrix();glLoadIdentity();glDisable(GL_DEPTH_TEST);//render textglEnable(GL_DEPTH_TEST);glPopMatrix();glMatrixMode(GL_PROJECTION);glPopMatrix();Quote:Wouldn't it be faster if the characters in the image were on a uniform grid to avoid doing per-character arithmetic?  The space saving by packing like that seems minimal with only 256 chars.Faster? No. Easier? Definitely. Only problem is the text looks a little crappy because of how the letters are set out with spaces in between, and there's only so much you can do when fiddling with the image you're using for your texture.In any case, back when I was starting out with text rendering, I ended up basically dumping every character I could to a console and copied most of it, then tried to make it a little prettier. It's a 256x256 PNG file with white text on a transparent background, so it might not show up properly in your browser, but it's there.You can get it here:;  I ended up making my own bitmap (below) by outputting the chars to console.  (I noticed that if I wrote them as a text file instead that some of the chars were different and many of them were missing, at least they didn't appear in the standard ascii order)Now that I have a windows bmp image I'm trying to figure out how to get this into a GL Bitmap so I can draw it using the glBitmap function.I thought the easiest way would be to use the SDL_LoadBMP function which I can do but now how to access the pixel data (void * type)?  My understanding is that glBitmap works on bit fields basically so I need to check each pixel of the .bmp file and convert to a 1 or a 0 depending on the underlying value (in this case FF or 00 i guess i could just check the R channel since the bmp is in black & white).  I try surface->pixels[0] but because pixels data is void*, compiler no likey.;  hrm a bit closer, I just saved as 1bpp format in mspaint (couldnt' figure out how to do this in Gimp). I can draw from full_set (an array of GLBytes) but something isn't going in right.  http://i45.tinypic.com/2q2k2f5.gifI came up with this based on this http://www.libsdl.org/cgi/docwiki.cgi/Pixel_Accessvoid Font::loadFont(){using namespace std;if (charset = SDL_LoadBMP("charset.bmp")){cout << "charset BytesPerPixel: " << int(charset->format->BytesPerPixel) << endl;h = charset->h/16;w = charset->w/16;numbytes = charset->pitch*charset->h;full_set = new GLubyte[numbytes];GLubyte* pixel_pointer;for (Uint32 i = 0; i < numbytes; i++){pixel_pointer = (GLubyte*)charset->pixels + i*charset->format->BytesPerPixel;full_set = *pixel_pointer;}}else{cout << "...SDL_LoadBMP('charset.bmp') failed" << endl;}};This week brings five new samples for the XNA Game Studio 4.0 Beta!View the full article