![]() |
|
How OpenGL text is stored and displayed? |
Archon
Member #4,195
January 2004
![]() |
I'm just following a tutorial in an OpenGL book that I have on Bitmap Fonts and I need to figure out exactly what the windows and wgl functions do so I can make a .NET/Mono cross-platform alternative. uint listbase; listbase = glGenLists(96); //96 individual lists HFONT font; //native windows object. font = CreateFont(...bunch of parameters specifying the font to load); //native windows func. SelectObject(hdc, font); //windows func... No idea what this does? Maps the font to the device context? //handle to device context //i'll assume that 32 = offset from first ASCII character //96 = size of list //the opengl list(s) wglUseFontBitmaps(hdc, 32, 96, listbase); I'll need to know what wglUseFontBitmaps does exactly since it's inner workings are not so obvious (to me)... Then there is the rendering function char *string; glPushAttrib(GL_LIST_BIT); glListBase(listbase - 32); //32 offset backwards since we offset it forwards glCallLists(strlen(string), GL_UNSIGNED_BYTE, string); glPopAttrib(); Also, I'll assume that you'll need to translate the text initially for the x,y position on the screen, but what is making the text translate to the right after each character when glCallLists is called? [edit] [edit2] |
Bob
Free Market Evangelist
September 2000
![]() |
Quote: I'll need to know what wglUseFontBitmaps does exactly since it's inner workings are not so obvious (to me)... wglUseFontBitmap() will create a set of display lists (one display list per character) that tells GL how to render that character. The exect contents of that display list are implementation-dependent and opaque to user applications. Using glDrawPixels() or glBitmap() (per glyph) is what's usually done though. Quote: what is making the text translate to the right after each character when glCallLists is called? The display list contains the cursor movement code too. Display lists can encompass most GL commands, so glTranslatef/glRasterPosition can be included. That said, if the display lists contains a call to glBitmap(), then glBitmap() has a parameter to move the raster position by some amount during that call. -- |
Archon
Member #4,195
January 2004
![]() |
Should/Are all the glyphs stored in their own textures (as in, separate IDs), or could they be put on 1 texture and use the 'source x' and 'source y'? I might actually look into glBitmap. [edit] |
Bob
Free Market Evangelist
September 2000
![]() |
Quote: Should/Are all the glyphs stored in their own textures (as in, separate IDs), or could they be put on 1 texture and use the 'source x' and 'source y'? There are no textures used. Quote: Pixmaps should work better How so? -- |
Archon
Member #4,195
January 2004
![]() |
Quote: Pixmaps should work better
Quote: How so? Pixmaps are better than bitmaps --> for the alpha bits? Quote: There are no textures used. Are you talking about all font renderings or just the bitmap/pixmap raster graphics? I'm now converting fonts to .tga files and loading them as textures. Is this a better idea? |
Bob
Free Market Evangelist
September 2000
![]() |
Quote: Pixmaps are better than bitmaps --> for the alpha bits? The bitmaps in question are glBitmap() bitmaps. They are literally a map of bits. You get 2 states for every fragment that will be generated: on or off. Secondly, pixmaps are not a part of OpenGL. Quote: Are you talking about all font renderings or just the bitmap/pixmap raster graphics? I'm talking about wglUseFontBitmaps(). Quote: I'm now converting fonts to .tga files and loading them as textures. Is this a better idea? I don't know. What are you trying to do? -- |
Archon
Member #4,195
January 2004
![]() |
Quote: I don't know. What are you trying to do? Sorry, I mean that I'm converting ordinary fonts from their usual format to the Targa format (like a tileset), and then loading the image as any other texture. Just after that, I'd generate and 'make' the GL Lists (16 x 6 glyphs) which would draw the individual characters like wglUseFontBitmaps() does. |
Bob
Free Market Evangelist
September 2000
![]() |
Sure, that works. Incidentally, that's how AGL processes fonts. -- |
Archon
Member #4,195
January 2004
![]() |
I almost have it working. I've still got to figure out how to determine how big each glyph is when I make the display lists... [Retrospective edit] Another thing is, does the font look too blurry? [edit] |
|