소스 검색

Fixed the PlatformMacOSX resize issue.

seanpaultaylor 11 년 전
부모
커밋
debb3e2cae
3개의 변경된 파일14개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      gameplay/src/PlatformMacOSX.mm
  2. 5 0
      samples/browser/src/SamplesGame.cpp
  3. 2 0
      samples/browser/src/SamplesGame.h

+ 7 - 2
gameplay/src/PlatformMacOSX.mm

@@ -745,14 +745,19 @@ double getMachTimeInMilliseconds()
     [[NSApplication sharedApplication] terminate:self];
 }
 
-- (void)windowDidResize:(NSNotification*)notification
+- (void)reshape
 {
     [gameLock lock];
+    
     NSSize size = [ [ _window contentView ] frame ].size;
     __width = size.width;
     __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);
-
     
     [gameLock unlock];
 }

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

@@ -116,6 +116,11 @@ void SamplesGame::render(float elapsedTime)
     _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)
 {
     if (_activeSample)

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

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