Good idea. I put together all the pertinent calls into one source file.
Sadly, I won’t be able to run this code on the machine that showed the issue again, but I’m hoping something in the following code jumps out as a problem.
Thanks again for looking at this for me.
#include "hud.h"
#define SCREENX 1000
#define SCREENY 500
void myReshape (int w, int h) {
glViewport (0, 0, w, h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
if (w <= h)
glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w,
50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0);
else
glOrtho (-50.0*(GLfloat)w/(GLfloat)h,
50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -1.0, 1.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
}
void keyboard(unsigned char key, int x, int y) {
if (key == 27)
exit (0);
}
int HUDInit (char *szTitle, int nXSize, int nYSize, int nRBg, int nGBg, int nBBg) {
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize (nXSize, nYSize);
glutInitWindowPosition (0, 0);
glutCreateWindow (szTitle);
glClearColor (0.0, 0.0, 0.0, 1.0);
glColor3ub (128, 20, 200);
glShadeModel (GL_FLAT);
/* antialiasing */
glEnable (GL_BLEND);
glDisable (GL_DEPTH_TEST);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glDisable (GL_LINE_SMOOTH);
glDisable (GL_POLYGON_SMOOTH);
glutReshapeFunc (myReshape);
glutIdleFunc (HUDDisplay);
glutDisplayFunc (HUDDisplay);
glutKeyboardFunc (keyboard);
}
void HUDDisplay (void) {
GLfloat twicePi = 2.0f * PI;
GLfloat radius = 50;
int i;
glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
glBegin(GL_TRIANGLE_FAN);
glColor3ub (150, 50, 192);
glVertex2f(0, 0);
for(i = 0; i <= 200;i++) {
glVertex2f(
0 + (radius * cos(i * twicePi / 200)),
0 + (radius * sin(i * twicePi / 200)));
}
glEnd();
glPopMatrix ();
glFlush ();
glutSwapBuffers ();
}
int main (int argc, char **argv) {
#ifdef FREEGLUT
glutInit (&argc, argv);
#endif
/* set up window settings */
HUDInit ("Test", SCREENX, SCREENY, 0, 0, 0);
#ifdef FREEGLUT
HUDMainLoop ();
#else
HUDMainLoop (HUDDisplay);
#endif
return (0);
}