glFlush() vs [[self openGLContext] flushBuffer] vs glFinish vs glSwapAPPLE vs aglSwapBuffers

后端 未结 3 1521
[愿得一人]
[愿得一人] 2021-02-07 06:13

There are several similar OpenGL operations when working with an NSOpenGLView:

  • glFlush()
  • [[self openGLContext] flushBuffer]
3条回答
  •  忘掉有多难
    2021-02-07 07:06

    Be careful! [[self openGLContext] flushBuffer] is not just an Objective-C wrapper for gFlush(). This function (- (void)flushBuffer in the Apple Documentation) works only if you set double buffer in your pixel format like

    NSOpenGLPixelFormatAttribute attributes [] =
        {
            NSOpenGLPFADoubleBuffer,
            // other presets like
            // NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
            // NSOpenGLPFADepthSize, 32,
            0
        };
    
        NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] 
                                                initWithAttributes:attributes];
    

    Otherwise you have to use glFlush(); It took me a long time until I saw the essential line in the NSOpenGLContext Class Reference.

提交回复
热议问题