Is there a workaround to the macOS 10.13 SDK breaking CGLCreatePBuffer?

125 Views Asked by At

I have a simple piece of code that successfully creates pbuffers when compiled against the macOS 10.12 SDK, but an update to the 10.13 SDK breaks things. I know that this tech is very deprecated.

#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl3.h>
#import <OpenGL/glext.h>

int main( int argc, const char* argv[] )
{
    GLsizei width = 1024;
    GLsizei height = 1024;
    GLenum target = GL_TEXTURE_RECTANGLE_EXT;
    GLenum internalFormat = GL_RGBA;
    GLint maxLevel = 0;

    CGLPBufferObj pBuffer = NULL;
    CGLError error = kCGLNoError;

    error = CGLCreatePBuffer( width, height, target, internalFormat, maxLevel, &pBuffer );

    if( error )
    {
        NSLog(@"CGL Error %@ : %s", @(error), CGLErrorString( error ) );
    }

    return 0;
}

Using the 10.12 SDK, I get kCGLNoError, but using 10.13 it delivers kCGLBadDrawable.

Beyond transitioning to using e.g. framebuffer objects, what can I do to keep this piece of code going for a little bit longer?

Note: it's not even necessary to fully recompile the generated binary against a different macOS SDK. Changing the Mach-O load command (changing a single byte) around VERSION_MIN_MAC_OSX to point to 10.12.0 rather than 10.13.0 also fixes things.

0

There are 0 best solutions below