I am trying to set up an OpenGL 3.0+ context within XCode 4.
As you can see talking about shaders here at the developer website the example it uses is OpenGL 2.0. In Appendix B it does talk about updating for 3.2 but just shows you function name changes and what only applies to the core, yet there is no example of actually setting up an OpenGL context. This has changed greatly since the fixed function pipeline being that you can no longer do things like glMatrixMode(...).. etc etc...i.e. opengl states are no longer.
If anyone can point me to a link somewhere on the web of setting up an OpenGL 3.0+ context on Mac OSX 10.7 using XCode 4 it would be appreciated.
There is some example code here for setting up an 3.2 context inside an NSOpenGLView.
Or using Core GL,
CGLPixelFormatAttribute attribs[13] = {
kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute)kCGLOGLPVersion_3_2_Core, // This sets the context to 3.2
kCGLPFAColorSize, (CGLPixelFormatAttribute)24,
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)8,
kCGLPFAAccelerated,
kCGLPFADoubleBuffer,
kCGLPFASampleBuffers, (CGLPixelFormatAttribute)1,
kCGLPFASamples, (CGLPixelFormatAttribute)4,
(CGLPixelFormatAttribute)0
};
CGLPixelFormatObj pix;
GLint npix;
CGLChoosePixelFormat(attribs, &pix, &npix);
CGLContextObj ctx;
CGLCreateContext(pix, 0, &ctx);
CGLSetCurrentContext(ctx);
CGLLockContext(ctx);
In either case you have to do it manually(not through InterfaceBuilder) because it's opt-in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With