Setting up and using OpenGL 3.0+ with Mac OSX Lion(10.7)

前端 未结 1 653
青春惊慌失措
青春惊慌失措 2021-02-09 19:44

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 Ap

相关标签:
1条回答
  • 2021-02-09 19:47

    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.

    0 讨论(0)
提交回复
热议问题