Today I tried to use the ARB_window_pos extension, for placing a texture font on the screen (“2D mode”), but that didn´t work.
Could one explain how to use that extension or can´t I use it here (thought it could be used for “2d overlays” / HUDs)???
ARB_window_pos updates the raster position which is used in conjunction with glDrawPixels. You sure you use that in Draw_a_letter()? I don’t see any glRasterPos* calls …
My hope was, that I use the raster position, to set the letter position, without the need to manually switch to a “2D mode” and avoid some state changes (matrix switching and the gluOrtho2d call).
But OK … any hints on how to do that better, than I currently do (even without ARB_window_pos g)?
Diapolo
[This message has been edited by Diapolo (edited 12-06-2002).]
If you draw your letters as textured primitives (glVertex and friends), neither glRasterPos* nor glWindowPos*ARB will do anything for you.
I kind of suspect that, though I can’t see it in the snippet you posted. Maybe you could clarify?
Raster position is exclusive to glDrawPixels.
You can do this:
glRasterPos2iARB(x,y); //0<x<ScrWidth ; 0<y<ScrHeight
glDrawPixels(letter_size_x,letter_size_y,blablabla,pixel_data_for_this_letter);
edit
Be warned that textured quads usually perform much better with lots of small things to draw (fonts are a perfect example).
[This message has been edited by zeckensack (edited 12-06-2002).]
The draw_a_letter() function calls and draws a series of display lists, that contain a textured triangle strip (quad form) -> font via textured primitives.
So I guess I can forget about the window_pos extension.
But have you got any ideas, how I could speed up my 2D drawing stuff?
Next step is to lump your complete charset into one texture and precompute a set of texture coordinates for each letter.
Now you can implement a font::render_string(char* bla) style function that writes the appropriate texture coordinates to the vertex_array and then blasts it out as glDrawArrays(GL_QUADS,0,4*length_of_string);.