CGL vs. AGL

Member
Posts: 50
Joined: 2002.12
Post: #1
Here's the problem, I tried switching to a CGL only OpenGL context, instead of using AGL.

Now I get really bad tearing across the screen.

Here is some code for getting the context (I've tried this with and without vsync).

Code:
CGLContextObj    SetupCGL(void)
{
    CGDisplayCapture(kCGDirectMainDisplay);
    
        
    CGOpenGLDisplayMask displayMask =
        CGDisplayIDToOpenGLDisplayMask( kCGDirectMainDisplay ) ;
    CGLPixelFormatAttribute attribs[] =
    {
        kCGLPFAFullScreen,
        kCGLPFADisplayMask,
        kCGLPFADoubleBuffer,
        (CGLPixelFormatAttribute)displayMask,
        (CGLPixelFormatAttribute)NULL
    } ;
    
    CGLPixelFormatObj pixelFormatObj ;
    long numPixelFormats ;
    
    CGLChoosePixelFormat( attribs, &pixelFormatObj, &numPixelFormats );
    
    CGLContextObj contextObj ;

    
    CGLCreateContext( pixelFormatObj, NULL, &contextObj ) ;
    CGLDestroyPixelFormat( pixelFormatObj ) ;

    long swapInterval = 1 ;
    CGLSetParameter( contextObj, kCGLCPSwapInterval, &swapInterval ) ;
    
    CGLSetCurrentContext( contextObj ) ;
    CGLSetFullScreen( contextObj ) ;

    return contextObj;
    
}

And draw the screen.

Code:
void    DoAnimate (void)
{
    CalculateMicroseconds();
        
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    SFAnimateWorld();  // make opengl calls
    
    
    CGLFlushDrawable( gOpenGLContext );
}

It tears, um, terribly.

stinware.com where games are friends.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
Your pixel format attributes are in the wrong order. You've set your display mask to "double buffer", so you're getting a single-buffered fullscreen display, which will tear like crazy.
Quote this message in a reply
Member
Posts: 50
Joined: 2002.12
Post: #3
I see...Blink

Thank you very much, that works much better now!

stinware.com where games are friends.
Quote this message in a reply
Post Reply