Advertisement

opengl bitmap-fonts and display-lists (c++)

Started by July 26, 2007 02:20 AM
1 comment, last by Stani R 17 years, 3 months ago
Hello, I'm working at the moment with the NeHe's tutorials. But i have a problem. When I'm trying to put 2d text on the screen (tutorial 13) und I also want to use selfmade displaylists (tutorial 12) i doesnt work. The selfmade displaylist is on the screen, but the 2d text doesnt comes. Example 1: glCallList(list); glDisable(GL_TEXTURE_2D); GL_Reset(); glRasterPos3f(-20.0, 0.0,-50); glColor3f(1,1,1); glPrint("output"); The text doesnt comes. Only the display list object. Example 2: //glCallList(list); glDisable(GL_TEXTURE_2D); GL_Reset(); glRasterPos3f(-20.0, 0.0,-50); glColor3f(1,1,1); glPrint("output"); "output" is on the screen. What can I do to use bitmapfonts and display lists togehter?? I hope you can help me... Thank you very much, so long thesparrow
Please show us the code where you initialize your display list and the fonts, usually the way you did it should be okay..
Advertisement
glDisable(GL_TEXTURE_2D) should prevent the font rendering in any event. Post the code of GL_Reset() please. I'm not sure about the usage of glRasterPos(), but my first guess is that the position offset from calling the initial display list is affecting the position for the output of your text. A better way (in the sense that I know that it works fine ^_^) of making operations directly on screen is to use orthographic projection mode instead of glRasterPos()

For example, first call

void setOrthoOn(){	glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT);		glDisable(GL_DEPTH_TEST);	glDisable(GL_LIGHTING);	glMatrixMode(GL_PROJECTION);	glPushMatrix();	glLoadIdentity();	glOrtho(0,getWidth(),0,getHeight(),-1,1);        glMatrixMode(GL_MODELVIEW);	glPushMatrix();	glLoadIdentity();}


now draw some text in screen coordinates (origin at lower left in this example), and finally call

void setOrthoOff(){	glMatrixMode(GL_PROJECTION);	glPopMatrix();	glMatrixMode(GL_MODELVIEW);	glPopMatrix();	glEnable(GL_DEPTH_TEST);	glEnable(GL_LIGHTING);	glPopAttrib();}

This topic is closed to new replies.

Advertisement