The following code builds with no warnings, but when run displays nothing.
I’m on Redhat9, glxinfo tells me direct rendering is working fine, glxgears runs wildly fast, it’s a 106 miles to Chicago, we’ve got a full tank of gas, half-a-pack of cigarettes,… oh wait.
// tester.cpp #include <GL/glut.h> //================================================ void my_init(); void my_display_func(); void my_reshape_func( int w, int h ); //================================================ int main( int argc, char * argv[] ) { glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ); glutInitWindowSize( 600, 600 ); glutInitWindowPosition( 50, 50 ); glutCreateWindow( "tester" ); my_init(); glutDisplayFunc( my_display_func ); glutReshapeFunc( my_reshape_func ); glutMainLoop(); return 0; } //================================================ void my_init() { glClearColor( 0.0, 0.0, 0.0, 0.0 ); glEnable( GL_DEPTH_TEST ); } //================================================ void my_display_func() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor3f( 0.1, 0.7, 0.3 ); glBegin( GL_LINE_STRIP ); glVertex3d( 0.2, 0.2, 0.0 ); glVertex3d( -0.2, 0.2, 0.0 ); glVertex3d( -0.2, -0.2, 0.0 ); glVertex3d( 0.2, -0.2, 0.0 ); glEnd(); glutSwapBuffers(); } //================================================ void my_reshape_func( int w, int h ) { if ( w > h ) { glViewport( w/2 - h/2, // x_bottom_left_corner 0, // y_bottom_left_corner h, // width (x, to the left) h ); // height (y, up) } else { glViewport( 0, h/2 - w/2, w, w ); } glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 35.0, // fovy 1.0, // aspect 2.0, // near 6.0 ); // far glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt( 0.0, 0.0, 4.0, // eye position 0.0, 0.0, 0.0, // looking at 0.0, 1.0, 0.0 ); // which way is up glutPostRedisplay(); }
and makefile is
# makefile for glut_tester # APP_NAME = glut_tester LIBS = -lglut -lGLU -lGL -L/usr/X11R6/lib -lXmu -lXi $(APP_NAME): main.o g++ main.o -Wall -ansi -pedantic-errors -o $(APP_NAME) $(LIBS) main.o: main.cpp g++ -c main.cpp clean: rm -f $(APP_NAME) rm -f *.o