使用 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/