Merge pull request #1479 from dumganhar/gles20

Renamed "setFrameZoom" to "setFrameZoomFactor", added 'getFrameZoomFactor
This commit is contained in:
James Chen 2012-10-19 02:50:08 -07:00
commit aa818f3b54
6 changed files with 24 additions and 12 deletions

View File

@ -241,13 +241,18 @@ void CCEGLView::setFrameSize(float width, float height)
} }
} }
void CCEGLView::setFrameZoom(float fZoomFactor) void CCEGLView::setFrameZoomFactor(float fZoomFactor)
{ {
m_fFrameZoomFactor = fZoomFactor; m_fFrameZoomFactor = fZoomFactor;
glfwSetWindowSize(m_obScreenSize.width * fZoomFactor, m_obScreenSize.height * fZoomFactor); glfwSetWindowSize(m_obScreenSize.width * fZoomFactor, m_obScreenSize.height * fZoomFactor);
CCDirector::sharedDirector()->setProjection(CCDirector::sharedDirector()->getProjection()); CCDirector::sharedDirector()->setProjection(CCDirector::sharedDirector()->getProjection());
} }
float CCEGLView::getFrameZoomFactor()
{
return m_fFrameZoomFactor;
}
void CCEGLView::setViewPortInPoints(float x , float y , float w , float h) void CCEGLView::setViewPortInPoints(float x , float y , float w , float h)
{ {
glViewport((GLint)(x * m_fScaleX * m_fFrameZoomFactor+ m_obViewPortRect.origin.x * m_fFrameZoomFactor), glViewport((GLint)(x * m_fScaleX * m_fFrameZoomFactor+ m_obViewPortRect.origin.x * m_fFrameZoomFactor),

View File

@ -36,7 +36,8 @@ public:
/* /*
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. * 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 bool isOpenGLReady();
virtual void end(); virtual void end();
virtual void swapBuffers(); virtual void swapBuffers();

View File

@ -636,7 +636,7 @@ void CCEGLView::resize(int width, int height)
SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
} }
void CCEGLView::setFrameZoom(float fZoomFactor) void CCEGLView::setFrameZoomFactor(float fZoomFactor)
{ {
m_fFrameZoomFactor = fZoomFactor; m_fFrameZoomFactor = fZoomFactor;
resize(m_obScreenSize.width * fZoomFactor, m_obScreenSize.height * 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()); CCDirector::sharedDirector()->setProjection(CCDirector::sharedDirector()->getProjection());
} }
float CCEGLView::getFrameZoomFactor()
{
return m_fFrameZoomFactor;
}
void CCEGLView::setFrameSize(float width, float height) void CCEGLView::setFrameSize(float width, float height)
{ {
CCEGLViewProtocol::setFrameSize(width, 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); 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) void CCEGLView::setViewPortInPoints(float x , float y , float w , float h)
{ {
glViewport((GLint)(x * m_fScaleX * m_fFrameZoomFactor + m_obViewPortRect.origin.x * m_fFrameZoomFactor), 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), (GLint)(y * m_fScaleY * m_fFrameZoomFactor + m_obViewPortRect.origin.y * m_fFrameZoomFactor),
(GLsizei)(w * m_fScaleX * m_fFrameZoomFactor), (GLsizei)(w * m_fScaleX * m_fFrameZoomFactor),
(GLsizei)(h * m_fScaleY * m_fFrameZoomFactor)); (GLsizei)(h * m_fScaleY * m_fFrameZoomFactor));
} }
CCEGLView* CCEGLView::sharedOpenGLView() CCEGLView* CCEGLView::sharedOpenGLView()

View File

@ -65,7 +65,8 @@ public:
/* /*
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. * 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(); void centerWindow();
typedef void (*LPFN_ACCELEROMETER_KEYHOOK)( UINT message,WPARAM wParam, LPARAM lParam ); typedef void (*LPFN_ACCELEROMETER_KEYHOOK)( UINT message,WPARAM wParam, LPARAM lParam );

View File

@ -32,6 +32,6 @@ int main(int argc, char **argv)
eglView->setFrameSize(2048, 1536); eglView->setFrameSize(2048, 1536);
// The resolution of ipad3 is very large. In general, PC's resolution is smaller than it. // 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. // 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(); return CCApplication::sharedApplication()->run();
} }

View File

@ -18,6 +18,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
eglView->setFrameSize(2048, 1536); eglView->setFrameSize(2048, 1536);
// The resolution of ipad3 is very large. In general, PC's resolution is smaller than it. // 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. // 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(); return CCApplication::sharedApplication()->run();
} }