Performace Problem

 #ifdef _WIN32
	#include <windows.h>
	#include <gl\gl.h>
	#include <gl\glut.h>
#endif

#ifndef _WIN32
	#include <glut/glut.h>
#endif

#include <stdlib.h>
#include <iostream.h>

void init(void) 
{
   glClearColor (0.0, 0.0, 0.0, 0.0);
   glShadeModel (GL_SMOOTH);
   glEnable(GL_LIGHTING);
   glEnable(GL_LIGHT0);
   glEnable(GL_DEPTH_TEST);						
   glDepthFunc(GL_LEQUAL);	
}

GLfloat spin=0.0;

void display(void)
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
   glColor3f (1.0, 1.0, 1.0);
   glLoadIdentity ();             /* clear the matrix */
           /* viewing transformation  */
   gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
   glScalef (1.0, 2.0, 1.0);      /* modeling transformation */ 
   spin+=0.2;
   if(spin>=360) spin=0;
   glRotatef(spin,1.0,1.0,1.0);
   glutSolidCube (1.0);
   glFlush();
   glutSwapBuffers();
}

void reshape (int w, int h)
{
   glViewport (0, 0, (GLsizei) w, (GLsizei) h); 
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
   glMatrixMode (GL_MODELVIEW);
}

void keyboard(unsigned char key, int x, int y)
{
   switch (key) {
      case 27:
         exit(0);
         break;
   }
}

void animation(void)
{
   glutPostRedisplay();
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);	
   glutInitWindowSize (500, 500); 
   glutInitWindowPosition (100, 100);
   glutCreateWindow (argv[0]);
   init();
   glutDisplayFunc(display); 
   glutReshapeFunc(reshape);
   glutIdleFunc(animation);
   glutKeyboardFunc(keyboard);
   glutMainLoop();
   return 0;
}
 

what is wrong with this code? it is a modified example of my opengl book…the framerate on my low end mac is much higher than the framerate on my windows xp…
is this a windows specific problem…i don’t know,please help…

thank you

i use vc++ 6.0…maybe the libs are too old…any ideas?

the cpu usage: 7%

if i change the display mode to single -> amazing framerate but display bugs and shimmering…and display bugs

GLUT isn’t particulary good for the performances
if your machine is also old, the latest OS from microsoft willbe lazy (when you have got few RAm or bad video card)

VC 6.0 is old but it’s work fine on my computer

The lower performance is most likely because of vsync. Your graphics driver control panel will let you turn it off globally. For starters: right click on desktop, “settings”, “advanced” and then just look around for it.

I don’t think this is about GLUT or the other stuff Gollum said – which I couldn’t make sense of :stuck_out_tongue:

sounds good…because if i use the highest resolution with anti aliasing and stuff like that de framerate is much higher…

thank y

thank you…vsync was the problem…
is it possible to control vsync with opengl code?

thank you

thank you…vsync was the problem…
is it possible to control vsync with opengl code?

thank you

Look at WGL_EXT_swap_control extension:

WGL_EXT_swap_control

thank you