Cocoa fullscreen

I’ve migrated my app away from Carbon to Cocoa. Things are working well using NSOpenGLView. Draws fine into a window.

The question is how to go fullscreen. There appears to be one code snippet from Apple called “NSOpenGL Fullscreen”. They make a controller class. But it looks really ugly because they have their own event loops etc in the controller. Is this the right approach? Or is there a simpler way by just setting the attributes in my NSOpenGLView derived class? Its sort of weird because the controller shares the context with the original thingy.

I tried to set the initial NSOpenGLView to fullscreen but I get a black void screen of doom. :stuck_out_tongue:

If you require Leopard, you can just use NSView’s new - (BOOL)enterFullScreenMode:(NSScreen *)screen withOptions:(NSDictionary *)options method. If you need to work on Tiger, things aren’t so easy. Respond and I’ll dig up some slightly simpler code than Apple’s…

You can subclass NSApp and override sendEvent: to process events yourself while fullscreen.

Like in this game code.

Ya, I’d like the new program to work under leopard and tiger. Essentially, the user will click a checkbox option to go fullscreen or window mode. Initially, when the program starts up it will use this option or if the user changes the option it will change screen mode when the program is running.

I was having second thoughts about doing the stuff in a controller because the Hillegass book suggests in pre 10.3 days people would stuff everything in a controller class. Did not seem like the appropriate place for all the opengl calls to go fullscreen.

In my NSOpenGLView based class, I put the keyDown / Up , MouseDown /Up calls. Works fine and real easy too.

My old code was calling all the cgl stuff directly and capturing events through a tiny tid bit of carbon. This was after I had to ditch glut because it could not change screen resolutions properly while the program was running and it appeared it was no longer supported.

So, in Leopard these calls do the trick. Though, I cannot initially do them in the initWithFrame call but initially in awakeFromNib it works.

[self enterFullScreenMode: [NSScreen mainScreen] withOptions: nil ];

[self exitFullScreenModeWithOptions: nil];

I’d assume since there is some kind of context tweaking going on that display lists and vbo’s would not have a problem? Could not find any examples of the withOptions parameter. One more question. Do the options have to match the options passed in initWithFrame when calling enterFullScreenMode?

Thanks again.

These new methods for full screen NSViews are great, such a welcome addition… full screen OpenGL used to be so much harder in OS X!

I’m still getting a bug with full screen though… please see my other thread for details! :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.