PDA

View Full Version : GL Screensaver Performance



Stack Overflow
02-10-2003, 03:01 PM
Hello,

I am trying to create a screensaver using Visual C++ 6, and with the ScreenSaverProc Procedure. Now my problem is that when I execute my OpenGL screensaver, my performance is really slick and percise in Win2000, but when I execute it in Win98, it goes really slow and my animation jitters alot. Is there a reason, and/or am I forgetting to add something to my code? I am also creating my program with a timer:

SetTimer( hWnd, myTimer, 1, NULL );

Is this timer to fast for Win98, or is it something else? I am also initializing my GL SS using the pfd flags, and here is an example:

pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_GENERIC_ACCELERATED | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_SWAP_LAYER_BUFFERS;
pfd.iPixelType = PFD_TYPE_RGBA;

Is this creating the slow performance or is it something else? I also have a function prototoype called OnTimer which is defined in my WM_TIMER function, and this is what it looks like:

void OnTimer( HDC hDC ) {
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glLoadIdentity();

glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -0.6f, -0.5f, 0.5f );
glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 0.6f, -0.5f, 0.5f );
glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0.6f, 0.5f, 0.5f );
glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -0.6f, 0.5f, 0.5f );
glEnd();

glFlush();

SwapBuffers( hDC );
}

Is this updating to fast becuase I am updating the timer very fast, or is it becuase I am swapping the buffers in the wrong place, and/or is it something else?

I also have something called SetupAnimation for Initializing my animation in the WM_CREATE function, and here is what it looks like:

void SetupAnimation( int w, int h ) {
glViewport( 0, 0, w, h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective( 50, ( GLfloat ) w / ( GLfloat ) h, 1.0, 100.0 );
glMatrixMode( GL_MODELVIEW );

glEnable( GL_TEXTURE_2D );
glShadeModel( GL_SMOOTH );
glEnable( GL_DEPTH_TEST );
}

Is this setup incorrectly, and/or is it something else?

I hope all of this information is explainable for an answer, and if not, I will explain some more.

- VC6-OGL

[This message has been edited by VC6-OGL (edited 02-10-2003).]