It seems that no matter what GL function I call, I get EXC_BAD_ACCESS. However, I'm calling these functions in readFromURL:ofType:error:
of an NSDocument
subclass, for some offscreen drawing. If I remove that code, and try to use GL later, once everything's loaded, everything works fine. Is thi开发者_JAVA百科s a GL context issue?
I read Apple's GL guide, but in the section about offscreen drawing, it just told me how to use framebuffers. Which I do, but since glGenFramebuffersEXT
crashes just like everything else, it's not very helpful.
Is there some sort of context creation I need to perform, and if so, what's the best way to do it?
Yes, OpenGL calls need a context. If you have NSOpenGLView
, you need to get its context and make it current:
[[openGLView openGLContext] makeCurrentContext];
// glCalls()
If you're not using NSOpenGLView
, you can create NSOpenGLContext
youself.
精彩评论