PDA

View Full Version : Stop Fliskering on animations



07-28-2002, 07:03 PM
Ok i need help to stop flickering with my animations its sopposed to sipn the teapot but it flickers all the code acctually work if u compile it but i need help to stop flickering this is wat i have so far:

#include <GL/glut.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#include <gl/gl.h>

static GLfloat Spin = 0.0;

void DrawObject(void)
{
//drawing STUff
glColor4f(0.0f,1.0f,0.0f,2.0f);
auxWireTeapot(0.5);
}

void MyDisplay(void){
/* Some OpenGL code that draws a frame */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glRotatef(Spin,Spin,Spin,1.0);
DrawObject();
glPopMatrix();
glFlush();
/* After drawing the frame we swap the buffers */
glutSwapBuffers();
};

void SpinDisplay(void)
{
Spin=Spin+2.0;
if (Spin > 360.0)
Spin = Spin - 360.0;
MyDisplay();
}

void main(int argcp, char **argv){

/* Initialize GLUT state */
glutInit(&argcp, argv);
glutInitWindowSize(640, 480);
glutInitWindowPosition(0, 0);

/* Open a window */
glutCreateWindow("My OpenGL Application");

/* Select type of Display mode:
Double buffer & RGBA color */
glutInitDisplayMode(GLUT_RGBA | GLUT_WINDOW_DOUBLEBUFFER);

/* Register Callback Functions */
glutDisplayFunc(MyDisplay);
glutIdleFunc(SpinDisplay);

/* Start Event Processing Engine */
glutMainLoop();
};

Any help would be appreciated thanks!!

ramo
07-29-2002, 05:08 PM
i dont know glut
but if you dont use double-buffer it flikers
and it seems that you create a window before you adjust double-buffer
adjust double-buffer than createwindow