I have been working on a 3d game (well its not a game yet just the forming of one). So far I have a decent system setup for window rendering and projection, in other words I have the basics cover in most areas. The problem is that I need a really simple HUD system just for displaying variables just so I can make sure all my functions are running correctly. I would like to do this all in one function if possible. I know that I need to setup so that in this function it switches to glortho instead of glperspective. But what I need help with is a really simple way of printing variables to a given x and y coordinate. Is their anyway easy way of archiving this? Thanks
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
now the window goes from (-1,-1) -> (1,1) (u could make 0,0->1,1 if u prefer)
this is a better method than using fixed X,Y screen coordinates, as u can resize the window + have everything in the correct place
see I was able to figure that much out myself, what I need help with is the actual drawing of the text. Can I just use sprintf or something?
the easiest/most common way is to do text is
create a texture with the letters of the alphabet on it
see this program
http://www.lmnopc.com/bitmapfontbuilder/
heres a method to draw the text
create a texture 16 charatcers width by 8 characters high
starting at the space(ascii==32) and going to the char at ascii32+8*16
- then use something like the following code
for ( int i=0; i<strlen(text); i++ )
{
num = text[i] - 32;
char_placeX = num & 15;
char_placeY = (num >> 4);
s = char_placeX * 0.0625;
t = char_placeY * 0.1250;
VEC3 vec[4];
vec[0] = VEC3( x, y, 0 );
vec[1] = VEC3( x+size, y, 0 );
vec[2] = VEC3( x+size, y+size,0 );
vec[3] = VEC3( x, y+size, 0 );
TEXCOORD tc[4];
tc[0] = TEXCOORD(s+0.0000, t+0.125);
tc[1] = TEXCOORD(s+0.0625, t+0.125);
tc[2] = TEXCOORD(s+0.0625, t+0.0);
tc[3] = TEXCOORD(s+0.0000, t+0.0);
draw_immediate_quad_v_t_c( vec, tc, text_color );
x += size;
}