开发者

Cocoa app gives EXC_BAD_ACCESS on any GL function

开发者 https://www.devze.com 2023-03-27 18:24 出处:网络
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 re

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消