PDA

View Full Version : Performace Problem



H.Stony
12-06-2004, 10:21 AM
#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(&amp;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

H.Stony
12-06-2004, 11:51 AM
i use vc++ 6.0...maybe the libs are too old.....any ideas?

H.Stony
12-06-2004, 12:36 PM
the cpu usage: 7%

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

Silkut
12-06-2004, 01:16 PM
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

zeckensack
12-06-2004, 05:38 PM
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 :p

H.Stony
12-07-2004, 09:22 AM
sounds good...because if i use the highest resolution with anti aliasing and stuff like that de framerate is much higher......

thank y

H.Stony
12-07-2004, 10:06 AM
thank you...vsync was the problem...
is it possible to control vsync with opengl code?

thank you

H.Stony
12-07-2004, 10:07 AM
thank you...vsync was the problem...
is it possible to control vsync with opengl code?

thank you

12-07-2004, 11:40 AM
Look at WGL_EXT_swap_control extension:

WGL_EXT_swap_control (http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt)

H.Stony
12-07-2004, 04:01 PM
thank you