使用 NSOpenGLView 时有几个类似的 OpenGL 操作:
glFlush()
[[self openGLContext] flushBuffer]
glFinish()
- glSwap苹果
- egl交换缓冲区
何时应该使用其中的每一个?
在示例应用程序中,Apple 使用glFlush()
, 其次是[[self openGLContext] flushBuffer]
。为什么他们同时使用这两个?
如果我使用双缓冲 Cocoa NSOpenGLView,正确的方法是什么?
当心![[self openGLContext] flushBuffer]
不仅仅是 Objective-C 的包装器gFlush()
。这个函数(- (void)flushBuffer
in the 苹果文档 https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSOpenGLContext_Class/Reference/Reference.html#//apple_ref/occ/instm/NSOpenGLContext/flushBuffer)仅当您在像素格式中设置双缓冲区时才有效,例如
NSOpenGLPixelFormatAttribute attributes [] =
{
NSOpenGLPFADoubleBuffer,
// other presets like
// NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
// NSOpenGLPFADepthSize, 32,
0
};
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc]
initWithAttributes:attributes];
否则你必须使用glFlush();
我花了很长时间才看到其中的基本线条NSOpenGLContext 类参考 https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSOpenGLContext_Class/Reference/Reference.html#//apple_ref/occ/instm/NSOpenGLContext/flushBuffer.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)