I want to create an NSOpenGLPixelBuffer for offscreen rendering. For now, I'm even unable to init it. Here's the code:
NSOpenGLPixelFormatAttribute attribs[] = {
NSOpenGLPFAPixelBuffer,
NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated,
NSOpenGLPFADepthSize, 24,
(NSOpenGLPixelFormatAttribute) 0
};
NSOpenGLPixelFormat* format = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs] autorelease];
NSOpenGLPixelBuffer* pixBuf = [[NSOpenGLPixelBuffer alloc]
initWithTextureTarget: GL_TEXTURE_2D
textureInternalFormat: GL_RGBA
textureMaxMipMapLevel: 0
pixelsWide: 32
pixelsHigh: 32];
NSLog(@"pbuf address: %p", pixBuf);
I've tried to fiddle with pixel format and width, height but nothing seems to work. I repeatedly get nil for the pixBuf. I'm using Xcode 9 on MacOS 10.13. It says the NSOpenGLPixelBuffer is deprecated but it should still work, right?