Browse files

fixed #946: HD image for both retina and normal

  • Loading branch information...
1 parent 23c2c11 commit 6cc57b970ecc992f2fe096fefb4a332a8d81a0a7 @minggo committed Feb 16, 2012
View
6 cocos2dx/CCDirector.cpp
@@ -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
2 cocos2dx/platform/android/CCEGLView_android.h
@@ -62,6 +62,8 @@ class CC_DLL CCEGLView
CCRect getViewPort();
float getScreenScaleFactor();
void setIMEKeyboardState(bool bOpen);
+
+ float getMainScreenScale() { return -1.0; }
// static function
/**
View
2 cocos2dx/platform/bada/CCEGLView_bada.h
@@ -71,6 +71,8 @@ class CC_DLL CCEGLView
@brief get the shared main open gl window
*/
static CCEGLView& sharedOpenGLView();
+
+ float getMainScreenScale() { return -1.0; }
/*
* param
View
4 cocos2dx/platform/ios/CCEGLView_ios.h
@@ -49,13 +49,15 @@ class CC_DLL CCEGLView
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
8 cocos2dx/platform/ios/CCEGLView_ios.mm
@@ -54,8 +54,7 @@ of this software and associated documentation files (the "Software"), to deal
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 @@ of this software and associated documentation files (the "Software"), to deal
return instance;
}
+float CCEGLView::getMainScreenScale()
+{
+ return [[UIScreen mainScreen] scale];
+}
+
} // end of namespace cocos2d;
View
2 cocos2dx/platform/linux/CCEGLView_linux.h
@@ -47,6 +47,8 @@ class CCEGLView {
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
2 cocos2dx/platform/marmalade/CCEGLView_marmalade.h
@@ -67,6 +67,8 @@ class CC_DLL CCEGLView
void setIMEKeyboardState(bool bOpen);
CCRect getViewPort();
float getScreenScaleFactor();
+
+ float getMainScreenScale() { return -1.0; }
// static function
/**
View
2 cocos2dx/platform/qnx/CCEGLView_qnx.h
@@ -66,6 +66,8 @@ class CC_DLL CCEGLView
CCRect getViewPort();
float getScreenScaleFactor();
void setIMEKeyboardState(bool bOpen);
+
+ float getMainScreenScale() { return 1.0 };
bool HandleEvents();
View
2 cocos2dx/platform/win32/CCEGLView_win32.h
@@ -52,6 +52,8 @@ class CC_DLL CCEGLView
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);

0 comments on commit 6cc57b9

Please sign in to comment.