iDevGames Forums
Cocoa/OpenGL drawing full-screen problem - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Cocoa/OpenGL drawing full-screen problem (/thread-8537.html)



Cocoa/OpenGL drawing full-screen problem - ultitech - Jan 12, 2011 12:42 PM

Hey guys,
I have a little issue here. Im trying to make my NSOpenGLView fullscreen using apple's example here.
But when I toggle fullscreen my view gets all messed up.
I have a window with an OpenGL View and I want just this View to go fullscreen instead of the entire old window.
Code:
NSView *contentView = [[MyOpenGLView alloc] initWithFrame:viewRect pixelFormat: pixelFormat];
[fullscreenWindow setContentView:contentView];
I got the code from Cocoa with Love.
I would appreciate you help.


RE: Cocoa/OpenGL drawing full-screen problem - SethWillits - Jan 12, 2011 03:03 PM

You'll need to be more specific than "my view gets all messed up."

You can use NSView's enterFullScreenMode:withOptions: method to get the view fullscreen. It works with NSOpenGLView too. I'm not sure why Apple's docs don't show this yet.


RE: Cocoa/OpenGL drawing full-screen problem - ultitech - Jan 12, 2011 03:57 PM

Its like OpenGL crashes, pixel errors are all over the fullscreen. Is the method you described good in performance on fullscreen?


RE: Cocoa/OpenGL drawing full-screen problem - SethWillits - Jan 12, 2011 04:29 PM

If OpenGL crashed, your app or computer would crash with it. What you're seeing is just unwritten-to video memory. That can be caused by a few things.

On 10.5 the fullscreen OpenGL context that results from calling the enterFullScreenMode: method isn't really recognized by the system as being fullscreen, so there's a bit of performance loss, but the amount is insignificant. On 10.6+ it will recognize it, and there's absolutely zero performance loss. It's as fast as can be.


RE: Cocoa/OpenGL drawing full-screen problem - ultitech - Jan 13, 2011 08:54 AM

Thanks, works perfectly. But I can only access enterFullScreenMode from inside my NSOpenGLView, is that right?


RE: Cocoa/OpenGL drawing full-screen problem - SethWillits - Jan 13, 2011 01:11 PM

No, it's a public method on NSView just like any other. You can call it from anywhere you want using a pointer to the view. Cocoa doesn't use private methods.