Skip to main content
GameDev.net gamedev.net
🔒 Locked

Using double buffers

Started by majoub Oct 12, 2005 at 3:17 PM 2 replies 450+ views
Original Post
majoub
majoub
hi, I'm new to OPENGL so you might find my question to be trivial. I'm writing a small animation program using double buffers to simulate the movement so I'm using function such as: glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); glutSwapBuffers(); glutPostRedisplay(); The problem is that I don't get any display at all Here are the parts of the code where I think the problem is:

void main(int argc , char**argv)
{
 
	
	
	glutInit(&argc , argv); //initialize the toolkit

	glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB); //sets the display mode

          //sets the window size  
	glutInitWindowSize(720,655);   

	  //sets the window position 
	glutInitWindowPosition(200,25);  

	glutCreateWindow("Drawing polygons ");  //open the screen window
	
	myInit();

	glutDisplayFunc(myDisplay);
	glutSwapBuffers();
	
	idle();

	
	glutMainLoop();


	
	
}


oid myInit(void)
{

glClearColor(1.0,1.0,1.0,0.0);  // set white background color
//glColor3f(1.0f,0.0f,0.0f);      // sets the drawing color to be red
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,640, -20.0,480);  // the transformation of the screen

}

void idle()
{
	
	theta += 2;

	if(theta == 360)
		theta= 0;

	glutPostRedisplay();


}





the myDisplay function works fine...I tried it using a single buffer... Thanks :)
Nit
Nit
glutSwapBuffers(); should be called at the end of your display function.
majoub
majoub
thanks

I got a display but it is static..
I'm basically trying to rotate some polygones using a global variable theta...

just to make things clear:

the glutPostRedisplay() calls myDisplay function right?
the swapping should be done after glFlush() in myDisplay?

James Trotter
James Trotter
Quote:
Original post by majoub
thanks

I got a display but it is static..
I'm basically trying to rotate some polygones using a global variable theta...

just to make things clear:

the glutPostRedisplay() calls myDisplay function right?
the swapping should be done after glFlush() in myDisplay?


Yes and yes.

Though it seems you're only calling idle() once, before you go into glutMainLoop(). You should post the code for the myDisplay function.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.