I have been an avid user of OpenSteer at work for quite some time. It compiles and runs smoothly under Windows. However, I had trouble running it on my Linux machine at home (a Gateway MX3558 notebook with Debian Lenny and freeglut 2.6.0). The graphics render fine, but instead of readable text, it shows a random bitmap pattern. I get this not only with OpenSteer, but also with some, but not all other OpenGL applications that use bitmap text rendering.
Upon some lengthy research and code comparisons, I found that this erroneous behaviour occurs when the option GL_DEPTH_TEST is enabled while the text is rendered (i.e. during the calls to glutBitmapCharacter(…). I don't know exactly what this option does, but it seems to wreak havoc with the character map and is probably useless while in 2d mode anyway.
The following patch seems to work for me. It follows a number of code examples I have seen on the Web. You may wish to give it some cross-platform testing before adopting though. Also, the commented-out versions of draw2dText…. would have to be fixed analogously.
-- Draw_old.cpp 2010-08-26 18:36:18.000000000 -0700
+++ Draw.cpp 2010-09-07 20:58:14.000000000 -0700
@@ -1505,6 +1505,10 @@
// the origin of the text relative to the screen space projection of
// the 3d point.
+ // JH: On some Linux systems, the fonts appear shot when this is omitted
+ glPushAttrib(GL_DEPTH_TEST);
+ glDisable(GL_DEPTH_TEST);
// set text color and raster position
glColor3f (color.r(), color.g(), color.b());
glRasterPos3f (location.x, location.y, location.z);
@@ -1543,6 +1547,8 @@
// switch back out of 2d screen space
end2dDrawing (originalMatrixMode);
+ // JH: be stack-savvy
+ glPopAttrib();
}
void
Regards,
Jens
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have been an avid user of OpenSteer at work for quite some time. It compiles and runs smoothly under Windows. However, I had trouble running it on my Linux machine at home (a Gateway MX3558 notebook with Debian Lenny and freeglut 2.6.0). The graphics render fine, but instead of readable text, it shows a random bitmap pattern. I get this not only with OpenSteer, but also with some, but not all other OpenGL applications that use bitmap text rendering.
Upon some lengthy research and code comparisons, I found that this erroneous behaviour occurs when the option GL_DEPTH_TEST is enabled while the text is rendered (i.e. during the calls to glutBitmapCharacter(…). I don't know exactly what this option does, but it seems to wreak havoc with the character map and is probably useless while in 2d mode anyway.
The following patch seems to work for me. It follows a number of code examples I have seen on the Web. You may wish to give it some cross-platform testing before adopting though. Also, the commented-out versions of draw2dText…. would have to be fixed analogously.
-- Draw_old.cpp 2010-08-26 18:36:18.000000000 -0700
+++ Draw.cpp 2010-09-07 20:58:14.000000000 -0700
@@ -1505,6 +1505,10 @@
// the origin of the text relative to the screen space projection of
// the 3d point.
+ // JH: On some Linux systems, the fonts appear shot when this is omitted
+ glPushAttrib(GL_DEPTH_TEST);
+ glDisable(GL_DEPTH_TEST);
glColor3f (color.r(), color.g(), color.b());
glRasterPos3f (location.x, location.y, location.z);
@@ -1543,6 +1547,8 @@
// switch back out of 2d screen space
end2dDrawing (originalMatrixMode);
+ // JH: be stack-savvy
+ glPopAttrib();
}
void
Regards,
Jens