From 8fd35181600832390c9945fd73e28c4744167fc7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 23 Apr 2012 15:38:02 +0800 Subject: [PATCH] issue #1177: fixed a bug about retina in CCDirector. --- cocos2dx/CCDirector.cpp | 12 +++++++++--- cocos2dx/platform/win32/CCEGLView_win32.cpp | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 53779fe0c4..a95a91970e 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -328,7 +328,7 @@ void CCDirector::setNextDeltaTimeZero(bool bNextDeltaTimeZero) void CCDirector::setProjection(ccDirectorProjection kProjection) { CCSize size = m_obWinSizeInPixels; - //CCSize sizePoint = m_obWinSizeInPoints; + CCSize sizePoint = m_obWinSizeInPoints; //glViewport(0, 0, size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() ); if (m_pobOpenGLView) @@ -354,6 +354,12 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) case kCCDirectorProjection3D: { + // reset the viewport if 3d proj & retina display + if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) + { + glViewport(-size.width/2, -size.height/2, size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() ); + } + float zeye = this->getZEye(); kmMat4 matrixPerspective, matrixLookup; @@ -377,8 +383,8 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); kmVec3 eye, center, up; - kmVec3Fill( &eye, size.width/2, size.height/2, zeye ); - kmVec3Fill( ¢er, size.width/2, size.height/2, 0.0f ); + kmVec3Fill( &eye, sizePoint.width/2, sizePoint.height/2, zeye ); + kmVec3Fill( ¢er, sizePoint.width/2, sizePoint.height/2, 0.0f ); kmVec3Fill( &up, 0.0f, 1.0f, 0.0f); kmMat4LookAt(&matrixLookup, &eye, ¢er, &up); kmGLMultMatrix(&matrixLookup); diff --git a/cocos2dx/platform/win32/CCEGLView_win32.cpp b/cocos2dx/platform/win32/CCEGLView_win32.cpp index 96c1202afe..f7a781c1df 100644 --- a/cocos2dx/platform/win32/CCEGLView_win32.cpp +++ b/cocos2dx/platform/win32/CCEGLView_win32.cpp @@ -503,7 +503,7 @@ void CCEGLView::setContentScaleFactor(float contentScaleFactor) { CCEGLViewProtocol::setContentScaleFactor(contentScaleFactor); - resize((int)(m_sSizeInPoint.width * contentScaleFactor), (int)(m_sSizeInPoint.height * contentScaleFactor)); + resize((int)(m_sSizeInPixel.width * contentScaleFactor), (int)(m_sSizeInPixel.height * contentScaleFactor)); centerWindow(); }