OS X OpenGL context profile version


#1

The way the NativeContext is set up on OS X right now is only allowing me to get a context with version 2.1. The NSOpenGLPFAOpenGLProfile attribute needs to be specified in order to get a 3.2 core context. For now I’m simply doing the following:

juce_OpenGL_osx.h Line 114

NSOpenGLPixelFormatAttribute attribs[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAMPSafe, NSOpenGLPFAClosestPolicy, NSOpenGLPFANoRecovery, NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixFormat.redBits + pixFormat.greenBits + pixFormat.blueBits), NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixFormat.alphaBits, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixFormat.depthBufferBits, NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixFormat.stencilBufferBits, NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixFormat.accumulationBufferRedBits + pixFormat.accumulationBufferGreenBits + pixFormat.accumulationBufferBlueBits + pixFormat.accumulationBufferAlphaBits), pixFormat.multisamplingLevel > 0 ? NSOpenGLPFASamples : (NSOpenGLPixelFormatAttribute) 0, (NSOpenGLPixelFormatAttribute) pixFormat.multisamplingLevel, NSOpenGLPFAOpenGLProfile, (NSOpenGLPixelFormatAttribute) NSOpenGLProfileVersion3_2Core, // get a 3.2 core context 0 };

Some sort of mechanism to choose a context profile and version would be pretty nice. OpenGL on OS X right now only allows NSOpenGLProfileVersion3_2Core and NSOpenGLProfileVersionLegacy but in the probably not so near future, I’m assuming it will be able to target a specific version like on Windows.


#2

Figured I’d put something else in here since it is related to the pixel format. I couldn’t get MSAA to work either. Turns out there is an attribute missing for it. I also reordered the attributes because turning antialiasing off would result in not getting the last attribute.

NSOpenGLPixelFormatAttribute attribs[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAMPSafe, NSOpenGLPFAClosestPolicy, NSOpenGLPFANoRecovery, NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixFormat.redBits + pixFormat.greenBits + pixFormat.blueBits), NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixFormat.alphaBits, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixFormat.depthBufferBits, NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixFormat.stencilBufferBits, NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixFormat.accumulationBufferRedBits + pixFormat.accumulationBufferGreenBits + pixFormat.accumulationBufferBlueBits + pixFormat.accumulationBufferAlphaBits), NSOpenGLPFAOpenGLProfile, (NSOpenGLPixelFormatAttribute) NSOpenGLProfileVersion3_2Core, pixFormat.multisamplingLevel > 0 ? NSOpenGLPFASamples : (NSOpenGLPixelFormatAttribute) 0, (NSOpenGLPixelFormatAttribute) pixFormat.multisamplingLevel, pixFormat.multisamplingLevel > 0 ? NSOpenGLPFASampleBuffers : (NSOpenGLPixelFormatAttribute) 0, (NSOpenGLPixelFormatAttribute)1, 0 };