I want to create an NSOpenGLPixelBuffer for off-screen rendering. At the moment, I can’t even initialize it. Here is 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 tried to mess with the pixel format and width, height, but nothing works. I repeatedly get nil for pixBuf. I am using Xcode 9 on macOS 10.13. He says NSOpenGLPixelBuffer is deprecated, but it should still work, right?
source
share