Advertisement

glPrint() from tutorial 11 crashed my app, here's how i fixed it

Started by May 31, 2003 04:49 AM
0 comments, last by IdahoEv 21 years, 9 months ago
I posted a few days ago about a crash that was happening in my app when I was trying to release the window. It was strange, because I hadn''t modified that part of the code in over a month. After a while of commenting out code, I determined that drawing text to the screen (as per tutorial 11) while the window was open would cause a crash later when I released the window. I was able to fix it in my app by commenting out two lines of the glPrint() function from tutorial 11. Namely, I removed glPushAttrib(GL_LIST_BIT) and glPopAttrib(). My glPrint now looks like this: GLvoid WMRenderer::glPrint(const char *fmt, ...) // Custom GL "Print" routine { char text[256]; // Holds our string va_list ap; // Pointer to list of arguments if (fmt == NULL) return; // If there''s no text do nothing va_start(ap, fmt); vsprintf(text, fmt, ap); // And converts symbols to actual numbers va_end(ap); // Results are stored in text // push attributes from tutorial 11 removed! glListBase(base - 32); // Sets the base character to 32 glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); list text // pop removed as well! } Once I removed those two calls, the crash went away and text still displayed just fine. What do those two calls do, given that I was able to remove them from my code and still use fonts on screen? Are they necessary? The tutorial isn''t very clear on what they are for. Thanks, Ev
business: www.lrdesign.compersonal: www.idahoev.com
It depends on what states are changed inside the display list. They save/restore the states, like lighting, blending, etc.. It''s used to make sure that, if you''ve got some states enabled or disabled before calling glPrint, the SAME states will be enabled or disabled after the call.

Y.

This topic is closed to new replies.

Advertisement