From 5751d82e6b8fd775f3b63c3b3e407869daf553e4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 19 Oct 2012 17:39:55 +0800 Subject: [PATCH] Renamed "setFrameZoom" to "setFrameZoomFactor", added 'getFrameZoomFactor'. --- cocos2dx/platform/linux/CCEGLView.cpp | 7 ++++++- cocos2dx/platform/linux/CCEGLView.h | 3 ++- cocos2dx/platform/win32/CCEGLView.cpp | 19 ++++++++++++------- cocos2dx/platform/win32/CCEGLView.h | 3 ++- samples/HelloCpp/proj.linux/main.cpp | 2 +- samples/HelloCpp/proj.win32/main.cpp | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cocos2dx/platform/linux/CCEGLView.cpp b/cocos2dx/platform/linux/CCEGLView.cpp index 961c6de158..99744d378b 100644 --- a/cocos2dx/platform/linux/CCEGLView.cpp +++ b/cocos2dx/platform/linux/CCEGLView.cpp @@ -241,13 +241,18 @@ void CCEGLView::setFrameSize(float width, float height) } } -void CCEGLView::setFrameZoom(float fZoomFactor) +void CCEGLView::setFrameZoomFactor(float fZoomFactor) { m_fFrameZoomFactor = fZoomFactor; glfwSetWindowSize(m_obScreenSize.width * fZoomFactor, m_obScreenSize.height * fZoomFactor); CCDirector::sharedDirector()->setProjection(CCDirector::sharedDirector()->getProjection()); } +float CCEGLView::getFrameZoomFactor() +{ + return m_fFrameZoomFactor; +} + void CCEGLView::setViewPortInPoints(float x , float y , float w , float h) { glViewport((GLint)(x * m_fScaleX * m_fFrameZoomFactor+ m_obViewPortRect.origin.x * m_fFrameZoomFactor), diff --git a/cocos2dx/platform/linux/CCEGLView.h b/cocos2dx/platform/linux/CCEGLView.h index 18d9e6e26c..65cb82f7ff 100644 --- a/cocos2dx/platform/linux/CCEGLView.h +++ b/cocos2dx/platform/linux/CCEGLView.h @@ -36,7 +36,8 @@ public: /* * Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. */ - void setFrameZoom(float fZoomFactor); + void setFrameZoomFactor(float fZoomFactor); + float getFrameZoomFactor(); virtual bool isOpenGLReady(); virtual void end(); virtual void swapBuffers(); diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index cef474d1fe..ed49e15a7b 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -636,7 +636,7 @@ void CCEGLView::resize(int width, int height) SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); } -void CCEGLView::setFrameZoom(float fZoomFactor) +void CCEGLView::setFrameZoomFactor(float fZoomFactor) { m_fFrameZoomFactor = fZoomFactor; resize(m_obScreenSize.width * fZoomFactor, m_obScreenSize.height * fZoomFactor); @@ -644,6 +644,11 @@ void CCEGLView::setFrameZoom(float fZoomFactor) CCDirector::sharedDirector()->setProjection(CCDirector::sharedDirector()->getProjection()); } +float CCEGLView::getFrameZoomFactor() +{ + return m_fFrameZoomFactor; +} + void CCEGLView::setFrameSize(float width, float height) { CCEGLViewProtocol::setFrameSize(width, height); @@ -684,12 +689,12 @@ void CCEGLView::centerWindow() SetWindowPos(m_hWnd, 0, offsetX, offsetY, 0, 0, SWP_NOCOPYBITS | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER); } -void CCEGLView::setViewPortInPoints(float x , float y , float w , float h) -{ - glViewport((GLint)(x * m_fScaleX * m_fFrameZoomFactor + m_obViewPortRect.origin.x * m_fFrameZoomFactor), - (GLint)(y * m_fScaleY * m_fFrameZoomFactor + m_obViewPortRect.origin.y * m_fFrameZoomFactor), - (GLsizei)(w * m_fScaleX * m_fFrameZoomFactor), - (GLsizei)(h * m_fScaleY * m_fFrameZoomFactor)); +void CCEGLView::setViewPortInPoints(float x , float y , float w , float h) +{ + glViewport((GLint)(x * m_fScaleX * m_fFrameZoomFactor + m_obViewPortRect.origin.x * m_fFrameZoomFactor), + (GLint)(y * m_fScaleY * m_fFrameZoomFactor + m_obViewPortRect.origin.y * m_fFrameZoomFactor), + (GLsizei)(w * m_fScaleX * m_fFrameZoomFactor), + (GLsizei)(h * m_fScaleY * m_fFrameZoomFactor)); } CCEGLView* CCEGLView::sharedOpenGLView() diff --git a/cocos2dx/platform/win32/CCEGLView.h b/cocos2dx/platform/win32/CCEGLView.h index a7ba9710f2..896ac939db 100644 --- a/cocos2dx/platform/win32/CCEGLView.h +++ b/cocos2dx/platform/win32/CCEGLView.h @@ -65,7 +65,8 @@ public: /* * Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. */ - void setFrameZoom(float fZoomFactor); + void setFrameZoomFactor(float fZoomFactor); + float getFrameZoomFactor(); void centerWindow(); typedef void (*LPFN_ACCELEROMETER_KEYHOOK)( UINT message,WPARAM wParam, LPARAM lParam ); diff --git a/samples/HelloCpp/proj.linux/main.cpp b/samples/HelloCpp/proj.linux/main.cpp index e85ef17632..876c63d567 100644 --- a/samples/HelloCpp/proj.linux/main.cpp +++ b/samples/HelloCpp/proj.linux/main.cpp @@ -32,6 +32,6 @@ int main(int argc, char **argv) eglView->setFrameSize(2048, 1536); // The resolution of ipad3 is very large. In general, PC's resolution is smaller than it. // So we need to invoke 'setFrameZoom'(only valid on desktop(win32, mac, linux)) to make the window smaller. - eglView->setFrameZoom(0.4f); + eglView->setFrameZoomFactor(0.4f); return CCApplication::sharedApplication()->run(); } diff --git a/samples/HelloCpp/proj.win32/main.cpp b/samples/HelloCpp/proj.win32/main.cpp index 560a587bda..42d4978482 100644 --- a/samples/HelloCpp/proj.win32/main.cpp +++ b/samples/HelloCpp/proj.win32/main.cpp @@ -18,6 +18,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, eglView->setFrameSize(2048, 1536); // The resolution of ipad3 is very large. In general, PC's resolution is smaller than it. // So we need to invoke 'setFrameZoom'(only valid on desktop(win32, mac, linux)) to make the window smaller. - eglView->setFrameZoom(0.4f); + eglView->setFrameZoomFactor(0.4f); return CCApplication::sharedApplication()->run(); }