Enabling depth testing when using CAOpenGLLayer

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2012-10-15T03:01:23Z Indexed on 2012/10/15 21:37 UTC
Read the original article Hit count: 228

Filed under:
|
|

If one is using a subclass of NSOpenGLView then one enables depth testing by selecting a 16/24/32 bit buffer from the attributes menu in Xcode, and then adding

glEnable(GL_DEPTH_TEST);
glClear(GL_DEPTH_BUFFER_BIT);

to the drawRect method. However, in the application I'm creating I'm rendering OpenGL content via the drawInCGLContext method of a CAOpenGLLayer which is contained within a subclass of NSView. This means that it is no longer possible to create a depth buffer via the inspector. Does anyone know how I can achieve this in such a situation?

© Stack Overflow or respective owner

Related posts about xcode

Related posts about cocoa