Browse Source

Fixed the PlatformMacOSX resize issue.

seanpaultaylor 11 years ago
parent
commit
debb3e2cae

+ 7 - 2
gameplay/src/PlatformMacOSX.mm

@@ -745,14 +745,19 @@ double getMachTimeInMilliseconds()
     [[NSApplication sharedApplication] terminate:self];
     [[NSApplication sharedApplication] terminate:self];
 }
 }
 
 
-- (void)windowDidResize:(NSNotification*)notification
+- (void)reshape
 {
 {
     [gameLock lock];
     [gameLock lock];
+    
     NSSize size = [ [ _window contentView ] frame ].size;
     NSSize size = [ [ _window contentView ] frame ].size;
     __width = size.width;
     __width = size.width;
     __height = size.height;
     __height = size.height;
+    CGLContextObj cglContext = (CGLContextObj)[[self openGLContext] CGLContextObj];
+    GLint dim[2] = {__width, __height};
+    CGLSetParameter(cglContext, kCGLCPSurfaceBackingSize, dim);
+    CGLEnable(cglContext, kCGLCESurfaceBackingSize);
+    
     gameplay::Platform::resizeEventInternal((unsigned int)__width, (unsigned int)__height);
     gameplay::Platform::resizeEventInternal((unsigned int)__width, (unsigned int)__height);
-
     
     
     [gameLock unlock];
     [gameLock unlock];
 }
 }

+ 5 - 0
samples/browser/src/SamplesGame.cpp

@@ -116,6 +116,11 @@ void SamplesGame::render(float elapsedTime)
     _sampleSelectForm->draw();
     _sampleSelectForm->draw();
 }
 }
 
 
+void SamplesGame::resizeEvent(unsigned int width, unsigned int height)
+{
+    setViewport(gameplay::Rectangle(width, height));
+}
+
 void SamplesGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 void SamplesGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
     if (_activeSample)
     if (_activeSample)

+ 2 - 0
samples/browser/src/SamplesGame.h

@@ -35,6 +35,8 @@ public:
      */
      */
     SamplesGame();
     SamplesGame();
 
 
+    void resizeEvent(unsigned int width, unsigned int height);
+    
 	void keyEvent(Keyboard::KeyEvent evt, int key);
 	void keyEvent(Keyboard::KeyEvent evt, int key);
 
 
     void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
     void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);