glClearColor(255.0f, 0.0f, 0.0f, 0.5f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//draw teh text
glColor3ub(255,255,255);
glTranslated(0,0,0);
glRasterPos2f(-0.5, -0.5);
glPushAttrib(GL_LIST_BIT);
glListBase(m_iBase - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
// draw teh dragon
glLoadIdentity();
glTranslated(x,y,0);
glCallList(frame);
//swap buffers
In short, the dragon is there, the text is not.
I feel dumb: wglUseFontBitmaps() is tricking me out. :(
well I'm using wglUseFontBitmaps just like the articles at nehe say, the text gets displayed the first frame and then it's never displayed again.
I'm also calling other list I made to draw a dragon into a textured quad, which get always displayed without problems.
So, I wonder, what am I doing wrong? :(
the main function looks something like this:
// this is everything I setglViewport(0,0,width,height); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f);glClearDepth(1.0f);glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //<-- this?// Here I build the font m_SystemText.BuildFont(window); /* this is the method's codevoid CSystemText::BuildFont(IWindow& win) { HDC hDC = GetDC((HWND)win.Handle()); HFONT font; HFONT oldfont; m_iBase = glGenLists(96); font = CreateFont(/*the usual lot of stuff*/); oldfont = (HFONT)SelectObject(hDC, font); wglUseFontBitmaps(hDC, 32, 96, m_iBase); SelectObject(hDC, oldfont); DeleteObject(font); }*///then I set the ortho viewglMatrixMode (GL_PROJECTION);glLoadIdentity ();glOrtho(0.0f, m_pWindow->Width(), m_pWindow->Height(), 0.0f, -1.0f, 1.0f);glMatrixMode (GL_MODELVIEW);glLoadIdentity ();// and later some other stuffglDepthFunc(GL_LEQUAL);glEnable(GL_DEPTH_TEST); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D);
It feels like if the text weren't being drawn into the rendering context anymore after swaping the buffers the first time, but I'm not sure.
Tried running an app with your settings and it runs ok, so I think the problem is in your Rendering method, if you dont draw the dragon does the text show up?
Would be nice to see how you setup the list for the dragon.
Would be nice to see how you setup the list for the dragon.
Quote:Original post by Brocketino
Tried running an app with your settings and it runs ok, so I think the problem is in your Rendering method, if you dont draw the dragon does the text show up?
nope, it doesn't show up. I removed everything that had to do with the dragon.
An it gets even more interesting... Actually I'm only able to see the text at the beggining of the app, only if I display a messagebox that stops the app.
this screenshot is from the app being freezed while displaying a messagebox right after everything gets created:
and this is after clicking the messagebox.
If I don't glClear the GL_COLOR_BUFFER_BIT the text stays there, what makes me think that it was drawn correctly at least once. If I don't show the messagebox even if I don't clear the GL_COLOR_BUFFER_BIT the text is not printed.
weird uh?
Hmmm, sound very mysterious.
Here's what I do without any problems.
Here's what I do without any problems.
void Init(){ // CreateList g_List = glGenLists(96); // Use default font wglUseFontBitmaps(g_hdc, 32, 96, g_List); glClearColor(0,0,255,1.0f); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D);}void glPrintText(const GLint x, const GLint y, const char * szText){ glColor3ub(255,255,255); glTranslated(0,0,0); glRasterPos2f(x,y); glPushAttrib(GL_LIST_BIT); glListBase(g_List - 32); glCallLists(strlen(szText), GL_UNSIGNED_BYTE, szText); glPopAttrib();}void RenderScene(void){ // Clear the depth and color buffers glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ); // Reset projection matrix glLoadIdentity(); glPrintText(300,100,"HELLO"); glColor3ub(255,0,255); glBegin(GL_QUADS); glVertex2d(100,100); glVertex2d(200,100); glVertex2d(200,200); glVertex2d(100,200); glEnd(); // Force rendering to screen glFlush(); // Swap the buffers SwapBuffers( g_hdc );}
are you redrawing the text? Just a simple guess.
probably better looking fonts would come from FreeType 2. But it is a bit of a pain to setup from what I'm told.
probably better looking fonts would come from FreeType 2. But it is a bit of a pain to setup from what I'm told.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement