Enabling depth testing when using CAOpenGLLayer
- by Andrew
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?