Full Screen OpenGL Crashes

I designed an NSOpenGLView subclass to support switching to full screen rendering. I based the class on one from OSC and the one from the InkuGame project. After getting it working, I then copied the classes to a new project and hooked everything up the same in InterfaceBuilder, but when I try to go full screen in the new project my system just hangs and I have to force a restart! Anyone have any ideas as to what may be causing this? Here some possibly relevant code.

Switching into/out of full screen can be a total pain. All I remember is that it was confusing to figure out. I don't see anything that sticks out immediately. I forgot if setOpenGLContext will make the context current as well. You might want to try calling makeCurrentContext right after setOpenGLContext in your full screen switch just to be sure, since you called clearCurrentContext earlier.

I'd also wager that you need to make the new context current. I'd also suggest using a shared context approach, unless you do already (not evident from code snippet), otherwise you have to reload all OpenGL resources, such as textures and vertex buffers, for the new context. It's also not clear from that snippet if the contexts are set up correctly.

You definitely should not be getting a kernel panic, so file a radr with Apple, but I've seen OSX KP quite a few times when an invalid OpenGL context is accessed, or with threads stepping on each other's toes.

It may not be a kernel panic. It is possible to put an OpenGL context into fullscreen mode, not make it current, and not have it attached to any other objects. Once you've done that nothing you do has any visible effect and you cannot easily get out of fullscreen mode. I have managed to set this up in such a way that even pressing command-q didn't send a terminate message to my app controller and force-quitting blind was the only way out.
It is also possible to crash the video card without crashing the OS by sending it a bad pointer, which kills the visuals without stopping any software from running (although I'm pretty sure that isn't happening here).

Debugging fullscreen can be a pain. If you have two monitors that can make it a lot easier. You can have xcode running in one monitor with the debugger and the fullscreen going on the other monitor. Seemed to make things easier for me...

macnib Wrote:Debugging fullscreen can be a pain. If you have two monitors that can make it a lot easier. You can have xcode running in one monitor with the debugger and the fullscreen going on the other monitor. Seemed to make things easier for me...

That's a good idea, I'll have to commandeer the TV for that. I thought that when you went full screen both monitors became black, is that true? Is there anything special I need to do?

That is specifically there because I had such a hell of a time debugging full screen problems like this that I used two monitors. Only the captured one goes black (or at least stays black). The other one was able to mouse around and be used normally. That saved a lot of time.

Thanks for the help. As I messed around with my code, it suddenly started working again! (Well, I'm not drawing anything in full screen mode yet, but I can go in and out without problems.) The only major thing I seem to have changed is to remove the timers that I had to run drawRect at a constant frequency. I can't see how that would make a difference and maybe it didn't. Seems like this stuff should be straight forward, but for some reason it just isn't.

Does that mean you're not calling drawrect: any more? If so, don't assume that the problem is actually fixed - it may be that something in drawrect: is causing the issue (do you definitely have a valid context?).