9
\$\begingroup\$

I do most of my development on OS X and for my current game project this is my target environment. However when I play games I play on Windows. As a windows gamer I am used to Alt+Tab switching from within the game to the last application that was open.

On OS X I currently can't find either a game that supports that nor can I find a way to make it possible. My current project is based on SDL 1.3 and I can see that cmd+tab is a sequence that is sent directly to my application and not intercepted by the operating system.

Now my first attempt was to hide the rendering window on cmd+tab which certainly works, but has the disadvantage that a hidden OpenGL window in SDL cannot be restored when the user tabs back to the application. First of all, there is no event fired for that or I can't find it, secondly the core problem is that when that application window is hidden, my game is still the active application, just that the window disappeared.

That is incredible annoying.

Any ideas how to approximate the windows / linux behavior for alt+tab?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

The issue is that you are capturing the display, as described in the Apple documentation here: https://developer.apple.com/library/mac/#documentation/graphicsimaging/Conceptual/QuartzDisplayServicesConceptual/Articles/DisplayCapture.html

This means that ALL keyboard commands are intercepted by your application. There are advantages to this approach, depending on your application.

The Apple docs say, at the bottom:

Note: It’s not necessary to capture a display to do full-screen drawing. Another approach is to create and draw into a borderless window the size of the display. This approach allows you to use all the features of the windowing system. It also plays well with the rest of the operating system, and it reduces the complexity of display handling (for example, you don’t have to worry about mirrored displays). With this approach, you can receive error alerts that might be missed with a captured display. You can also use Command-Tab to change applications with this approach. On systems with modern graphics hardware, drawing performance in a full-screen window is almost as fast as a full-screen drawing context.

What you need to do is make your openGL view full screen without capturing the display. This is how cocos2d currently handles full screen OS X applications. You can browse the code for cocos2d Mac here: https://github.com/cocos2d/cocos2d-iphone/tree/master-v2/cocos2d/Platforms/Mac

Look specifically in CCDirectorMac.m and CCGLView.m for their implementation.

If you determine that you want to selectively limit some of the functions, such as process switching, without limiting all of the features of the windowing system, you can look to the Apple Kiosk Mode Technical Note: http://developer.apple.com/library/mac/#technotes/KioskMode/Introduction/Introduction.html

\$\endgroup\$
1
\$\begingroup\$

My experience of this on the Mac is that there's normally a shortcut to exit fullscreen mode into windowed mode (typically CMD+M or CMD+Return). Once you've switched into windowed mode then you can access all your applications as normal. Windowed mode also nicely allows the user to monitor their game amongst all their other apps. So I guess you could just implement this sort of functionality to your game.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .