Use of NSView subclass with OpenGL 3.2 gives undefined framebuffer errors
I've a 2008 Unibody Apple MacBook with a 2.4Ghz Core 2 Duo CPU, an 8GB RAM upgrade and an nVidia GeForce 9400M graphics chipset. It's running OS X 10.8.2.
I'm working on a pair of variants of Apple's OpenGL 3.2-based GLEssentials project (the reflected, spinning monster), which at this stage should display a simple 'ground' made up of flat-shaded triangles. The first variant sub-classes the NSOpenGLView class, and displays the triangles in a window without any issues. The second variant sub-classes the NSView class, as opposed to the NSOpenGLView class. When I compile and run it, the output of the command "glCheckFramebufferStatus(GL_FRAMEBUFFER)", situated immediately after creating a rendering context and making it current, is GL_FRAMEBUFFER_UNDEFINED. Further to that, the shader validation returns "Validation Failed: Current draw framebuffer is invalid." Needless to say, nothing gets rendered. I get the impression these errors pertain to the default framebuffer (object number of 0). I'm told that this should be set up automatically when the rendering context is created.
According to this page this can be resolved. If someone can enlighten me on how it would be greatly appreciated. It wouldn't surprise me if it was absurdly simple. :-| Happy to provide source code if need be.
Thanks in advance.
See the documentation:
Working With Rendering Contexts
which notes that NSOpenGLView handles on your behalf (via the -update method) associating the view with the context.
and Drawing to a Cocoa View
which shows an example of a custom NSView implementation (note -update etc, you are responsible for re-implementing the NSOpenGLView machinery.)
Thanks for the links, arekkusu. I'd read them before, but hadn't paid the same sort of attention as I've done now. Having followed the instructions more closely (particularly with the implementation of the prepareOpenGL method), I'm pleased to say that I've got OpenGL 3.2 and NSView sub-classes playing together just nicely, and rendering what I want.