fixed #946: HD image for both retina and normal

This commit is contained in:
minggo 2012-02-16 10:47:16 +08:00
parent dc3599f7ae
commit b0b6b85a79
9 changed files with 27 additions and 3 deletions

View File

@ -778,6 +778,12 @@ bool CCDirector::enableRetinaDisplay(bool enabled)
return false;
}
// SD device
if (m_pobOpenGLView->getMainScreenScale() == 1.0)
{
return false;
}
float newScale = (float)(enabled ? 2 : 1);
setContentScaleFactor(newScale);

View File

@ -62,6 +62,8 @@ public:
CCRect getViewPort();
float getScreenScaleFactor();
void setIMEKeyboardState(bool bOpen);
float getMainScreenScale() { return -1.0; }
// static function
/**

View File

@ -71,6 +71,8 @@ public:
@brief get the shared main open gl window
*/
static CCEGLView& sharedOpenGLView();
float getMainScreenScale() { return -1.0; }
/*
* param

View File

@ -49,13 +49,15 @@ public:
void setTouchDelegate(EGLTouchDelegate * pDelegate);
void swapBuffers();
void setViewPortInPoints(float x, float y, float w, float h);
void setScissorInPoints(float x, float y, float w, float h);
void setScissorInPoints(float x, float y, float w, float h);
void touchesBegan(CCSet *set);
void touchesMoved(CCSet *set);
void touchesEnded(CCSet *set);
void touchesCancelled(CCSet *set);
float getMainScreenScale();
void setIMEKeyboardState(bool bOpen);
static CCEGLView& sharedOpenGLView();

View File

@ -54,8 +54,7 @@ bool CCEGLView::isOpenGLReady()
bool CCEGLView::canSetContentScaleFactor()
{
return [[EAGLView sharedEGLView] respondsToSelector:@selector(setContentScaleFactor:)]
&& [[UIScreen mainScreen] scale] != 1.0;
return [[EAGLView sharedEGLView] respondsToSelector:@selector(setContentScaleFactor:)];
}
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
@ -139,4 +138,9 @@ CCEGLView& CCEGLView::sharedOpenGLView()
return instance;
}
float CCEGLView::getMainScreenScale()
{
return [[UIScreen mainScreen] scale];
}
} // end of namespace cocos2d;

View File

@ -47,6 +47,8 @@ public:
int setDeviceOrientation(int eOritation);
void setViewPortInPoints(float x, float y, float w, float h);
void setScissorInPoints(float x, float y, float w, float h);
float getMainScreenScale() { return -1.0; }
void setIMEKeyboardState(bool bOpen);

View File

@ -67,6 +67,8 @@ public:
void setIMEKeyboardState(bool bOpen);
CCRect getViewPort();
float getScreenScaleFactor();
float getMainScreenScale() { return -1.0; }
// static function
/**

View File

@ -66,6 +66,8 @@ public:
CCRect getViewPort();
float getScreenScaleFactor();
void setIMEKeyboardState(bool bOpen);
float getMainScreenScale() { return 1.0 };
bool HandleEvents();

View File

@ -52,6 +52,8 @@ public:
void swapBuffers();
bool canSetContentScaleFactor();
void setContentScaleFactor(float contentScaleFactor);
float getMainScreenScale() { return -1.0; }
virtual bool Create(LPCTSTR pTitle, int w, int h);
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);