cocoa - glFlush() vs [[self openGLContext]lushBuffer] vs glFinish vs glSwapAPPLE vs aglSwapBuffers

标签 cocoa macos opengl

使用 NSOpenGLView 时有几个类似的 OpenGL 操作:

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

什么时候应该使用这些?

在示例应用程序中,Apple 使用 glFlush(),后跟 [[self openGLContext]lushBuffer]。为什么他们同时使用这两个?

如果我使用双缓冲 Cocoa NSOpenGLView,正确的方法是什么?

最佳答案

小心! [[self openGLContext]lushBuffer] 不仅仅是 gFlush() 的 Objective-C 包装器。仅当您在像素格式中设置双缓冲区时,此函数(Apple Documentation 中的 - (void)flushBuffer )才有效

NSOpenGLPixelFormatAttribute attributes [] =
    {
        NSOpenGLPFADoubleBuffer,
        // other presets like
        // NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
        // NSOpenGLPFADepthSize, 32,
        0
    };

    NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] 
                                            initWithAttributes:attributes];

否则你必须使用glFlush();我花了很长时间才看到 NSOpenGLContext Class Reference 中的基本行。

关于cocoa - glFlush() vs [[self openGLContext]lushBuffer] vs glFinish vs glSwapAPPLE vs aglSwapBuffers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7027346/

相关文章:

windows - Mac .Pkg 文件在 Windows 中打开...奇怪的事情

Mac OSX 上的 Java - 检测程序是否全屏

c++ - 使用 OpenGL 绘图,无需杀死 CPU 且无需并行化

cocoa - 当 isGroupItem 委托(delegate)方法与 Swift 一起使用时,NSOutlineView 崩溃

objective-c - 更改 Cocoa 中圆形按钮的大小

ios - 当取消处理程序引用 self 时,在 -dealloc 中取消 XPC 连接

c++ - 如何在 GLSL 中使用 4x4 矩阵作为顶点属性?

opengl - 具有不同转换的批量绘图对象的最佳实践是什么?

objective-c - 如何获取 cocoa 中目录的大小和可用空间?

Objective-C、Doxygen 以及如何在文档中显示 AppKit 类