and they make all the game text with it (change the color, size, etc). How do they do that?
They create a quad by letter and put it at -0.00000000000000001f on the z position?
Anyway if someone have a code that I can modifie the bitmap or can help me please answer!
Edited by - Dunge on January 6, 2001 1:03:58 PM
🔒 Locked
Bitmap Font engine
Advertisement
Original Post
Hi, I made a little PONG game using the Nehe text tutorial and it slow down the game of 100fps! So I wanted to make a bitmap engine.
You know like in Half-Life they take this bitmap :
and they make all the game text with it (change the color, size, etc). How do they do that?
They create a quad by letter and put it at -0.00000000000000001f on the z position?
Anyway if someone have a code that I can modifie the bitmap or can help me please answer!
Edited by - Dunge on January 6, 2001 1:03:58 PM
and they make all the game text with it (change the color, size, etc). How do they do that?
They create a quad by letter and put it at -0.00000000000000001f on the z position?
Anyway if someone have a code that I can modifie the bitmap or can help me please answer!
Edited by - Dunge on January 6, 2001 1:03:58 PM
Hello there,
heres a bit of code that you may find usefull.
Hope it helps
heres a bit of code that you may find usefull.
|
Hope it helps
wglXXX... sounds like one those evil windows-only extensions
"This album was written, recorded and edited at Gröndal, Stockholm in the year of 2000. At this point in time money still ruled the world. Capitalistic thoughts were wide spread. From the sky filled with the fumes of a billionarie''s cigar to the deepest abyss drenched in nuclear waste. A rich kid was a happy kid, oh..dirty, filthy times. Let this be a reminder."
- Fireside, taken from back of the Elite album
"This album was written, recorded and edited at Gröndal, Stockholm in the year of 2000. At this point in time money still ruled the world. Capitalistic thoughts were wide spread. From the sky filled with the fumes of a billionarie''s cigar to the deepest abyss drenched in nuclear waste. A rich kid was a happy kid, oh..dirty, filthy times. Let this be a reminder."
- Fireside, taken from back of the Elite album
Yeah, seemingly
but wait... Windows, and speed ?!?
Isn''t that a contradiction?
pi~
but wait... Windows, and speed ?!?
Isn''t that a contradiction?
pi~
i wasnt getting anywhere with the font tuts from nehe (my own fault
) so i added a bmp rendering func
bassiclly it works like this, my texture(256x256) is dividded into sections of 32x32 for each character.
i keep a standard "alphabet" of the order, say
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef...01234...!"£$%^ etc
(it think its 8x8 per texture,so i have another for symbols)
then, that order, is stuck into a string, and i add a func to find its pos (on the texture)
it loops through my string("ABCDE...") till it finds the char (i should use scanf) increasing x and y as i go.
*then* i have the x/y on the pos (eg, "D" is x3 y0) so i can use that to apply the texture in a certain place on a flat quad.
you can also easily scale the font by chnaging the size of the quad, and colour it etc using color3f.
hope that kinda made sense :]
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
bassiclly it works like this, my texture(256x256) is dividded into sections of 32x32 for each character.
i keep a standard "alphabet" of the order, say
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef...01234...!"£$%^ etc
(it think its 8x8 per texture,so i have another for symbols)
then, that order, is stuck into a string, and i add a func to find its pos (on the texture)
it loops through my string("ABCDE...") till it finds the char (i should use scanf) increasing x and y as i go.
*then* i have the x/y on the pos (eg, "D" is x3 y0) so i can use that to apply the texture in a certain place on a flat quad.
you can also easily scale the font by chnaging the size of the quad, and colour it etc using color3f.
hope that kinda made sense :]
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
oop, as the bmp has now loaded at the top, i can tell you how they did that 
they just use the char''s number to find its pos.
char*(texturewidth/256)
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
they just use the char''s number to find its pos.
char*(texturewidth/256)
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
hummmm....
first MButchers I don''t understand anything to your code, except that it use glRasterPos2i(); and that''s what slow down the prog in the NeHe text tutorial.... and redmonkey I understand what you say but make it in C++ that''s another thing.... and that look very complicated! I know I ask a big thing but I want to make it working, and I want to understand it...
You said :
you can also easily scale the font by chnaging the size of the quad, and colour it etc using color3f.
Yeah but color3f don''t change the color of the textures!
first MButchers I don''t understand anything to your code, except that it use glRasterPos2i(); and that''s what slow down the prog in the NeHe text tutorial.... and redmonkey I understand what you say but make it in C++ that''s another thing.... and that look very complicated! I know I ask a big thing but I want to make it working, and I want to understand it...
You said :
you can also easily scale the font by chnaging the size of the quad, and colour it etc using color3f.
Yeah but color3f don''t change the color of the textures!
color3f does change the color:
1.0f,1.0f,1.0f is white
it doesnt icnrease the brightness, so
1.0f,0.0f,0.0f is a red, but not too bright.
next, i dunno how good you are at reading code, and my project is kinda open source, so here it is:
http://www.deadpenguin.org/files/nwb10.zip

thats a very old shot, but kinda gives the indication of what it does
find fontwrite()
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
1.0f,1.0f,1.0f is white
it doesnt icnrease the brightness, so
1.0f,0.0f,0.0f is a red, but not too bright.
next, i dunno how good you are at reading code, and my project is kinda open source, so here it is:
http://www.deadpenguin.org/files/nwb10.zip

thats a very old shot, but kinda gives the indication of what it does
find fontwrite()
__________________
graham "red" reeves.
red@deadpenguin.org
www.deadpenguin.org
Grrr.... my way of understanding code is to modifie it and test what it''s doing.... but I''m not abble to compille this game because of the f***ing directx... Yes I included all the .lib files, yes I have the DX SDK, yes I added the include and lib dir in the VC++ option and put them on the top of the list... but I''m not abble to compille the Nehe DirectInput tutorial too... same error :
Lesson23.cpp(543) : error C2065: ''DirectInputCreateEx'' : undeclared identifier
Maybe that''s because I have DirectX8 and the Directx8 SDK?
Lesson23.cpp(543) : error C2065: ''DirectInputCreateEx'' : undeclared identifier
Maybe that''s because I have DirectX8 and the Directx8 SDK?
Heres microsofts code then (non c++builder) from sdk help
Here''s a skeletal example that shows how to draw some text:
HDC hdc;
HGLRC hglrc;
// create a rendering context
hglrc = wglCreateContext (hdc);
// make it the calling thread''s current rendering context
wglMakeCurrent (hdc, hglrc);
// now we can call OpenGL API
// make the system font the device context''s selected font
SelectObject (hdc, GetStockObject (SYSTEM_FONT));
// create the bitmap display lists
// we''re making images of glyphs 0 thru 255
// the display list numbering starts at 1000, an arbitrary choice
wglUseFontBitmaps (hdc, 0, 255, 1000);
// display a string:
// indicate start of glyph display lists
glListBase (1000);
// now draw the characters in a string
glCallLists (24, GL_UNSIGNED_BYTE, "Hello Win32 OpenGL World");
my original post was in c++builder code (much easier?)
1st part changes the font
2nd part loads font into hdc
3rd part creates display lists for font
4th part (TextOut) displays text to current HGLRC
Here''s a skeletal example that shows how to draw some text:
HDC hdc;
HGLRC hglrc;
// create a rendering context
hglrc = wglCreateContext (hdc);
// make it the calling thread''s current rendering context
wglMakeCurrent (hdc, hglrc);
// now we can call OpenGL API
// make the system font the device context''s selected font
SelectObject (hdc, GetStockObject (SYSTEM_FONT));
// create the bitmap display lists
// we''re making images of glyphs 0 thru 255
// the display list numbering starts at 1000, an arbitrary choice
wglUseFontBitmaps (hdc, 0, 255, 1000);
// display a string:
// indicate start of glyph display lists
glListBase (1000);
// now draw the characters in a string
glCallLists (24, GL_UNSIGNED_BYTE, "Hello Win32 OpenGL World");
my original post was in c++builder code (much easier?)
1st part changes the font
2nd part loads font into hdc
3rd part creates display lists for font
4th part (TextOut) displays text to current HGLRC
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement