flicker graphics

geroldboehler
Unregistered
 
Post: #1
hi all

i draw a simple polygon (fullscreen context) and rotate it in some way. now it does rotate but flickers awfully. i tried different stuff but probably missed something.
probably someone can help me out?

thanks a lot
gerold


// this is the initialisation function, sorry for the wrapping:

CGDisplayCapture(kCGDirectMainDisplay);
CGOpenGLDisplayMask displayMask = CGDisplayIDToOpenGLDisplayMask( kCGDirectMainDisplay ) ;
CGDisplayHideCursor( kCGDirectMainDisplay );
CGLPixelFormatAttribute attribs[] =
{
kCGLPFAFullScreen,
kCGLPFADisplayMask,
kCGLPFADoubleBuffer,
(CGLPixelFormatAttribute)displayMask,
(CGLPixelFormatAttribute)NULL
};
CGLPixelFormatObj pixelFormatObj ;
long numPixelFormats ;
CGLChoosePixelFormat( attribs, &pixelFormatObj, &numPixelFormats );
CGLCreateContext( pixelFormatObj, NULL, &contextObj ) ;
CGLDestroyPixelFormat( pixelFormatObj ) ;
long swapInterval = 1;
CGLSetParameter( contextObj, kCGLCPSwapInterval, &swapInterval ) ;
CGLSetCurrentContext( contextObj ) ;
CGLSetFullScreen( contextObj ) ;


// and this is the function i call in a tight loop

glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0, 0.0, 0.0, 0.0);

glRotatef(0.1, 0.0f, 1.0f, 0.0f);
glRotatef(0.05, 1.0f, 0.0f, 0.0f);
glRotatef(0.2, 0.0f, 0.0f, 1.0f);

glBegin(GL_POLYGON);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(-0.5, -0.5);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(-0.5, 0.5);
glColor3f(1.0, 1.0, 1.0);
glVertex2f(0.5, 0.5);
glColor3f(1.0, 1.0, 1.0);
glVertex2f(0.5, -0.5);
glEnd();
glFinish();

CGLFlushDrawable( contextObj );
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
Hmm... try moving your CGLSetParameter() after your CGLSetCurrentContext(). The context might not be fully created until you make it current.

also, offtopic, but:
* CGAssociateMouseAndMouseCursorPosition(0) after CGDisplayHideCursor() is probably a good idea, to keep the mouse where the user left it when your app quits.
* glFinish() is implicit in CGLFlushDrawable(); this will block your thread. You only need this if you want to time the GPU rendering for debugging purposes.
* you can use the CODE forum tag to format your code Wink
Quote this message in a reply
geroldboehler
Unregistered
 
Post: #3
hi

just moved the setparameter after the setcurrentcontenxt and removed the glfinish and glflush but nothing helped.
but i fixed the mouse :-)


any other suggestions?

thanks
gerold
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #4
double buffering and VBL should fix any flickering
Quote this message in a reply
geroldboehler
Unregistered
 
Post: #5
yes, that's what i was thinking too. as you can see in the code
i enabled both. after this the animation was faster but still
flicker.


thanks
gerold
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
What hardware is this on?
Quote this message in a reply
Post Reply