我正在尝试在MacOS上升级到OpenGL 4.1。 为此,我正在尝试使用MultiSample技术。 这是我选择像素格式的代码:
GLint answer;
int numAttribs = 0;
CGLRendererInfoObj rend;
bool multisampleSupport = false;
CGLQueryRendererInfo(CGDisplayIDToOpenGLDisplayMask
(kCGDirectMainDisplay), &rend, &answer);
CGLDescribeRenderer(rend, 0, kCGLRPSampleModes, &answer);
if ((answer & kCGLMultisampleBit) != 0)
multisampleSupport = true;
NSOpenGLPixelFormatAttribute attributes[64] = { 0 };
attributes[numAttribs++] = NSOpenGLPFAOpenGLProfile;
attributes[numAttribs++] = NSOpenGLProfileVersion4_1Core;
attributes[numAttribs++] = NSOpenGLPFADoubleBuffer;
attributes[numAttribs++] = NSOpenGLPFAClosestPolicy;
attributes[numAttribs++] = NSOpenGLPFANoRecovery;
attributes[numAttribs++] = NSOpenGLPFAColorSize;
attributes[numAttribs++] = (NSOpenGLPixelFormatAttribute) 24;
attributes[numAttribs++] = NSOpenGLPFAAlphaSize;
attributes[numAttribs++] = (NSOpenGLPixelFormatAttribute) 8;
attributes[numAttribs++] = NSOpenGLPFADepthSize;
attributes[numAttribs++] = (NSOpenGLPixelFormatAttribute) 24;
attributes[numAttribs++] = NSOpenGLPFAStencilSize;
attributes[numAttribs++] = (NSOpenGLPixelFormatAttribute) 1;
if (multisampleSupport)
{
attributes[numAttribs++] = NSOpenGLPFAMultisample;
attributes[numAttribs++] = NSOpenGLPFASampleBuffers;
attributes[numAttribs++] = (NSOpenGLPixelFormatAttribute) 1;
attributes[numAttribs++] = NSOpenGLPFASamples;
attributes[numAttribs++] = (NSOpenGLPixelFormatAttribute) 4;
}
_masterPixelFormat = (WCOGLPixelFormatRef)[[NSOpenGLPixelFormat alloc] initWithAttributes:(NSOpenGLPixelFormatAttribute*) attributes];
如果我将multisampleSupport设置为FALSE,则一切正常(当然,没有抗锯齿)。但是,如果由于渲染器支持而将其设置为true(应该如此),则会显示白色窗口。
是的,我知道OpenGL已弃用,但它仍然可以正常工作。我在做什么错了?