Fix part of #26850: Cocoa OS X game player was not working, two issues:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 27 Jun 2011 13:57:27 +0000 (13:57 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 27 Jun 2011 13:57:27 +0000 (13:57 +0000)
* Unlike blender, the game player draws only on windows update callbacks,
  and those wer not implemented.
* Going fullscreen for player was not implemented correct, it expected an
  existing window but actually it should create one.

intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
intern/ghost/intern/GHOST_SystemCocoa.h
intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_WindowCocoa.h
intern/ghost/intern/GHOST_WindowCocoa.mm

index ab3abdd659fd158c99b339743bef233c078048a4..86f5f4cdddb1afeb5303853197880a075a130fde 100644 (file)
@@ -164,5 +164,5 @@ GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(GHOST_TUns8 d
 
        //CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
         
-       return /*err == CGDisplayNoErr ? GHOST_kSuccess :*/ GHOST_kFailure;
+       return /*err == CGDisplayNoErr ?*/ GHOST_kSuccess /*: GHOST_kFailure*/;
 }
index e7a8178a38259a2910a44e9b0901c3a3df280232..ce77735838934d088bff949686a3bc3fe8379d6c 100644 (file)
@@ -119,14 +119,6 @@ public:
                const GHOST_TEmbedderWindowID parentWindow = 0 
        );
        
-       virtual GHOST_TSuccess beginFullScreen(
-               const GHOST_DisplaySetting& setting, 
-               GHOST_IWindow** window,
-               const bool stereoVisual
-       );
-       
-       virtual GHOST_TSuccess endFullScreen( void );
-       
        /***************************************************************************************
         ** Event management functionality
         ***************************************************************************************/
index 2649929713a449d255499e931ad024d68d4494e7..69423f2dfbf83c74cbf4e89997efdcad0a87b1fc 100644 (file)
@@ -773,26 +773,6 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow(
     return window;
 }
 
-GHOST_TSuccess GHOST_SystemCocoa::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual)
-{      
-       GHOST_IWindow* currentWindow = m_windowManager->getActiveWindow();
-       *window = currentWindow;
-       
-       if(!currentWindow) return GHOST_kFailure;
-       
-       return currentWindow->setState(GHOST_kWindowStateFullScreen);
-}
-
-GHOST_TSuccess GHOST_SystemCocoa::endFullScreen(void)
-{      
-       GHOST_IWindow* currentWindow = m_windowManager->getActiveWindow();
-       if(!currentWindow) return GHOST_kFailure;
-       
-       return currentWindow->setState(GHOST_kWindowStateNormal);
-}
-
-
-       
 /**
  * @note : returns coordinates in Cocoa screen coordinates
  */
index e6de2bf07b4ee727b3d94887350152f2985b7293..ce28f8c453856b4a4e8cba9b0567b4f241b5c98e 100644 (file)
@@ -42,6 +42,7 @@
 #include "STR_String.h"
 
 @class CocoaWindow;
+@class CocoaOpenGLView;
 
 class GHOST_SystemCocoa;
 
@@ -309,7 +310,7 @@ protected:
     CocoaWindow *m_window;
        
        /** The openGL view */
-       NSOpenGLView *m_openGLView; 
+       CocoaOpenGLView *m_openGLView; 
     
        /** The opgnGL drawing context */
        NSOpenGLContext *m_openGLContext;
index 93bc87b2458b48e67ff71bac643aa50cb1bfe5dc..937dffe9fba0e2ff3cf9da65e6e50737f105af83 100644 (file)
@@ -241,10 +241,19 @@ extern "C" {
 //We need to subclass it in order to give Cocoa the feeling key events are trapped
 @interface CocoaOpenGLView : NSOpenGLView
 {
+       GHOST_SystemCocoa *systemCocoa;
+       GHOST_WindowCocoa *associatedWindow;
 }
+- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
 @end
 @implementation CocoaOpenGLView
 
+- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa
+{
+       systemCocoa = sysCocoa;
+       associatedWindow = winCocoa;
+}
+
 - (BOOL)acceptsFirstResponder
 {
     return YES;
@@ -294,6 +303,7 @@ extern "C" {
     else
     {
         [super drawRect:rect];
+        systemCocoa->handleWindowEvent(GHOST_kEventWindowUpdate, associatedWindow);
     }
 }
 
@@ -424,6 +434,8 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
        //Creates the OpenGL View inside the window
        m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect
                                                                                                 pixelFormat:pixelFormat];
+
+       [m_openGLView setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
        
        [pixelFormat release];