flickering problem

Started by
2 comments, last by magneeto 17 years, 9 months ago
hi, i have a texture mapped rotating object and other still objects in a scene. i have put the rotations in the idle function. the problem is i am experiencing a lot of flickering . if i stop the glutPostRedisplay() then there is no flickering and no rotations also. how do i get the object to rotate without any flickerings
Advertisement
Moving to the OpenGL forum.
Quote:Original post by magneeto
hi,

i have a texture mapped rotating object and other still objects in a scene. i have put the rotations in the idle function. the problem is i am experiencing a lot of flickering . if i stop the glutPostRedisplay() then there is no flickering and no rotations also. how do i get the object to rotate without any flickerings


If by flickering you mean tearing, you need to sync with VSYNC. Otherwise, make sure you are doing glClear() at the start of every frame. There could be other problems, but it's hard to tell without any source code.
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
here is the code........only mentioning the functions and where i have put the glClear(). i'm not mentioning the other functions that read the textures and bind them........


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


void display(void) {

//****viewport 1 (Perspective view seen from the camera.)

glMatrixMode( GL_PROJECTION);
glLoadIdentity();
gluPerspective( fovy_1, (double) width/winHeight_1, near_1, far_1);

glMatrixMode( GL_MODELVIEW);
glLoadIdentity();
gluLookAt( xcam_1, ycam_1, zcam_1, xfoc_1, yfoc_1, zfoc_1, 0., 1., 0.);

draw();//draws a rotating earth

if ( showAxis_1 ) {
glDisable( GL_LIGHTING);
glDisable(GL_DEPTH_TEST);

axes_1( xyzmax_1);
}

//****End of Viewport 1*/

if (showCamera_1) {

//****ViewPort2 (Orthogonal view seen from a location on positive z)
glMatrixMode( GL_PROJECTION);
glLoadIdentity();
glOrtho( -w, w, -w, w, -far_1*w, far_1*w);

glMatrixMode( GL_MODELVIEW);
glLoadIdentity();

draw(); //Draws the same rotating earth in this smaller viewport
camera_1(); //Draw the camera
frustum_1(); //Draw the frustum
//****End of Viewport2

/****Viewport3 (Orthogonal view seen from a location on positive y)*/

glMatrixMode( GL_PROJECTION);
glLoadIdentity();
glOrtho( -w, w, -w, w, -far_1*w, far_1*w);

glMatrixMode( GL_MODELVIEW);
glLoadIdentity();
gluLookAt( 0., 2., 0., 0., 0., 0., 0., 0., -1.);

draw(); //Draw the object
camera_1(); //draw camera and the focal point
frustum_1(); //Draw the frustum*/

//****End Viewport3*/

}

glutSwapBuffers();

}


void Init() {

glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

glutInitWindowSize(winWidth_1, winHeight_1);

glutCreateWindow("");

glutReshapeFunc( reShape_1);

glutDisplayFunc(display);
glutSpecialFunc(specialKey_1);
glutKeyboardFunc( keyBoard_1);

glutMouseFunc(mouse);
glutMotionFunc(mouse_motion);


glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

void idle_func ( void )
{
/*update some rotations here*/

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glutPostRedisplay ( );



}

int main(int argc, char **argv) {
glutInit(&argc, argv);
Init();
init();
glutIdleFunc ( idle_func );
glutMainLoop();
return 0;

} //main()

This topic is closed to new replies.

Advertisement