1507 |
1507 |
nldebug("cannot create cocoa view for cocoa window");
|
1508 |
1508 |
return false;
|
1509 |
1509 |
}
|
|
1510 |
|
|
1511 |
_cocoaWindow = cocoa_window;
|
1510 |
1512 |
|
1511 |
1513 |
#elif defined (NL_OS_UNIX)
|
1512 |
1514 |
|
... | ... | |
1688 |
1690 |
#elif defined(NL_OS_MAC)
|
1689 |
1691 |
|
1690 |
1692 |
// leave fullscreen mode, enter windowed mode
|
1691 |
|
if(windowStyle == EWSWindowed && [containerView() isInFullScreenMode])
|
|
1693 |
if(windowStyle == EWSWindowed && !_CurrentMode.Windowed)
|
1692 |
1694 |
{
|
1693 |
|
// disable manual setting of back buffer size, cocoa handles this
|
1694 |
|
// automatically as soon as the view gets resized
|
1695 |
|
CGLError error = CGLDisable((CGLContextObj)[_ctx CGLContextObj],
|
1696 |
|
kCGLCESurfaceBackingSize);
|
1697 |
|
|
1698 |
|
if(error != kCGLNoError)
|
1699 |
|
nlerror("cannot disable kCGLCESurfaceBackingSize (%s)",
|
1700 |
|
CGLErrorString(error));
|
1701 |
|
|
1702 |
|
// pull the view back from fullscreen restoring window options
|
1703 |
|
[containerView() exitFullScreenModeWithOptions:nil];
|
1704 |
|
|
|
1695 |
// disable manual setting of back buffer size, cocoa handles this
|
|
1696 |
// automatically as soon as the view gets resized
|
|
1697 |
CGLError error = CGLDisable((CGLContextObj)[_ctx CGLContextObj], kCGLCESurfaceBackingSize);
|
|
1698 |
if(error != kCGLNoError)
|
|
1699 |
nlerror("cannot disable kCGLCESurfaceBackingSize (%s)", CGLErrorString(error));
|
|
1700 |
|
|
1701 |
// Makes the cocoaWindow a regular window
|
|
1702 |
[cocoaWindow() setStyleMask:(NSTitledWindowMask | NSClosableWindowMask |
|
|
1703 |
NSMiniaturizableWindowMask | NSResizableWindowMask)];
|
|
1704 |
[cocoaWindow() setFrame:[[NSScreen mainScreen] visibleFrame] display:true];
|
|
1705 |
[cocoaWindow() setLevel:NSNormalWindowLevel];
|
|
1706 |
|
1705 |
1707 |
// let the gl view receive key events
|
1706 |
1708 |
[[containerView() window] makeFirstResponder:_glView];
|
1707 |
|
|
1708 |
|
// bring the window containing the gl view to the front
|
1709 |
|
[[containerView() window] makeKeyAndOrderFront:nil];
|
1710 |
1709 |
}
|
1711 |
1710 |
|
1712 |
1711 |
// enter fullscreen, leave windowed mode
|
1713 |
|
else if(windowStyle == EWSFullscreen && ![containerView() isInFullScreenMode])
|
|
1712 |
else if(windowStyle == EWSFullscreen && _CurrentMode.Windowed)
|
1714 |
1713 |
{
|
1715 |
|
// enable manual back buffer size for mode setting in fullscreen
|
1716 |
|
CGLError error = CGLEnable((CGLContextObj)[_ctx CGLContextObj],
|
1717 |
|
kCGLCESurfaceBackingSize);
|
1718 |
|
|
1719 |
|
if(error != kCGLNoError)
|
1720 |
|
nlerror("cannot enable kCGLCESurfaceBackingSize (%s)",
|
1721 |
|
CGLErrorString(error));
|
1722 |
|
|
1723 |
|
// put the view in fullscreen mode, hiding the dock but enabling the menubar
|
1724 |
|
// to pop up if the mouse hits the top screen border.
|
1725 |
|
// NOTE: withOptions:nil disables <CMD>+<Tab> application switching!
|
1726 |
|
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
1727 |
|
[containerView() enterFullScreenMode:[NSScreen mainScreen] withOptions:
|
1728 |
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
1729 |
|
[NSNumber numberWithInt:
|
1730 |
|
NSApplicationPresentationHideDock |
|
1731 |
|
NSApplicationPresentationAutoHideMenuBar],
|
1732 |
|
NSFullScreenModeApplicationPresentationOptions, nil]];
|
1733 |
|
#endif
|
1734 |
|
/*
|
1735 |
|
TODO check if simply using NSView enterFullScreenMode is a good idea.
|
1736 |
|
the context can be set to full screen as well, performance differences?
|
1737 |
|
*/
|
1738 |
|
|
|
1714 |
// enable manual back buffer size for mode setting in fullscreen
|
|
1715 |
CGLError error = CGLEnable((CGLContextObj)[_ctx CGLContextObj], kCGLCESurfaceBackingSize);
|
|
1716 |
if(error != kCGLNoError)
|
|
1717 |
nlerror("cannot enable kCGLCESurfaceBackingSize (%s)", CGLErrorString(error));
|
|
1718 |
|
|
1719 |
// Makes the cocoaWindow borderless, fullscreen, and one level above the menu bar
|
|
1720 |
[cocoaWindow() setStyleMask:NSBorderlessWindowMask];
|
|
1721 |
[cocoaWindow() setFrame:[[NSScreen mainScreen] frame] display:true];
|
|
1722 |
[cocoaWindow() setLevel:NSMainMenuWindowLevel+1];
|
|
1723 |
|
1739 |
1724 |
// let the gl view receive key events
|
1740 |
1725 |
[[containerView() window] makeFirstResponder:_glView];
|
1741 |
1726 |
}
|
... | ... | |
2072 |
2057 |
mode.Depth = NSBitsPerPixelFromDepth([screen depth]);
|
2073 |
2058 |
|
2074 |
2059 |
// in fullscreen mode
|
2075 |
|
if([containerView() isInFullScreenMode])
|
|
2060 |
if(!_CurrentMode.Windowed)
|
2076 |
2061 |
{
|
2077 |
2062 |
// return the size of the back buffer (like having switched monitor mode)
|
2078 |
2063 |
mode.Windowed = false;
|
... | ... | |
2396 |
2381 |
else
|
2397 |
2382 |
{
|
2398 |
2383 |
#ifdef NL_OS_MAC
|
2399 |
|
if([containerView() isInFullScreenMode])
|
|
2384 |
if(!_CurrentMode.Windowed)
|
2400 |
2385 |
{
|
2401 |
2386 |
width = _backBufferWidth;
|
2402 |
2387 |
height = _backBufferHeight;
|
... | ... | |
2439 |
2424 |
#elif defined(NL_OS_MAC)
|
2440 |
2425 |
|
2441 |
2426 |
// for fullscreen mode, adjust the back buffer size to desired resolution
|
2442 |
|
if([containerView() isInFullScreenMode])
|
|
2427 |
if(!_CurrentMode.Windowed)
|
2443 |
2428 |
{
|
2444 |
2429 |
// disable and re-enable fullscreen
|
2445 |
2430 |
// fixes #1062 (http://dev.ryzom.com/issues/1062)
|