PDA

View Full Version : Why this little program doesn't work ?



airseb
03-31-2002, 04:04 AM
nothing appears in the windows http://www.opengl.org/discussion_boards/ubb/eek.gif

#include <GL/glut.h>
#include <stdlib.h>


void display (void)
{

glClearColor (0.0, 0.0, 0.0, 0.0) ;
glClear (GL_COLOR_BUFFER_BIT) ;
glColor3f (1.0, 1.0, 1.0) ;
glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0) ;
glBegin (GL_POLYGON) ;
glVertex3f ( 0.25, 0.25, 0.0 ) ;
glVertex3f ( 0.75, 0.25, 0.25) ;
glVertex3f ( 0.75, 0.75, 0.25) ;
glVertex3f ( 0.25, 0.75, 0.0 ) ;
glEnd () ;
glFlush () ;
}

int main (int argc, char** argv)

{
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
glutInitWindowSize (640, 480) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;
glutDisplayFunc (display) ;
glutMainLoop () ;
return 0 ;
}

SnowKrash
03-31-2002, 05:39 AM
You've asked for a double-buffered framebuffer (GLUT_DOUBLE) and by default rendering is set to the back buffer.

Stick glutSwapBuffers() at the end of your display function to swap front and back.

That's the first thing I spotted... I haven't really checked the rest.

airseb
03-31-2002, 06:22 AM
thanks it works http://www.opengl.org/discussion_boards/ubb/biggrin.gif

[This message has been edited by airseb (edited 03-31-2002).]