Merge branch 'dev' of https://github.com/yangws/cocos2d-x into yangws-dev
|
@ -51,7 +51,7 @@ echo.*/
|
|||
echo.
|
||||
|
||||
set SCRIPT_LOG=InstallWizardLog.txt
|
||||
set SCRIPT_DIR=.\template\CCApplicationWizard.vs\
|
||||
set SCRIPT_DIR=.\template\msvc\
|
||||
|
||||
if exist %SCRIPT_LOG% del /Q %SCRIPT_LOG%
|
||||
cscript "%SCRIPT_DIR%InstallWizardForVC2008Express.js" /quiet
|
||||
|
|
|
@ -109,11 +109,12 @@ void ccDrawPoints(const CCPoint *points, unsigned int numberOfPoints)
|
|||
|
||||
void ccDrawLine(CCPoint origin, CCPoint destination)
|
||||
{
|
||||
CCPoint vertices[2];
|
||||
ccVertex2F vertices[2] =
|
||||
{
|
||||
{origin.x * CC_CONTENT_SCALE_FACTOR(), origin.y * CC_CONTENT_SCALE_FACTOR()},
|
||||
{destination.x * CC_CONTENT_SCALE_FACTOR(), destination.y * CC_CONTENT_SCALE_FACTOR()},
|
||||
};
|
||||
|
||||
vertices[0] = origin;
|
||||
vertices[1] = destination;
|
||||
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
|
||||
|
@ -131,29 +132,61 @@ void ccDrawLine(CCPoint origin, CCPoint destination)
|
|||
}
|
||||
|
||||
|
||||
void ccDrawPoly(const CCPoint *poli, int points, bool closePolygon)
|
||||
void ccDrawPoly(const CCPoint *poli, int numberOfPoints, bool closePolygon)
|
||||
{
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, poli);
|
||||
if (closePolygon)
|
||||
{
|
||||
glDrawArrays(GL_LINE_LOOP, 0, points);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDrawArrays(GL_LINE_STRIP, 0, points);
|
||||
}
|
||||
|
||||
// restore default state
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
ccVertex2F* newPoint = new ccVertex2F[numberOfPoints];
|
||||
if (! newPoint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
|
||||
// iPhone and 32-bit machines
|
||||
if( sizeof(CCPoint) == sizeof(ccVertex2F) ) {
|
||||
|
||||
// convert to pixels ?
|
||||
if( CC_CONTENT_SCALE_FACTOR() != 1 ) {
|
||||
memcpy( newPoint, poli, numberOfPoints * sizeof(ccVertex2F) );
|
||||
for( int i=0; i<numberOfPoints;i++)
|
||||
{
|
||||
newPoint[i].x = poli[i].x * CC_CONTENT_SCALE_FACTOR();
|
||||
newPoint[i].y = poli[i].y * CC_CONTENT_SCALE_FACTOR();
|
||||
}
|
||||
glVertexPointer(2, GL_FLOAT, 0, newPoint);
|
||||
|
||||
} else
|
||||
glVertexPointer(2, GL_FLOAT, 0, poli);
|
||||
|
||||
|
||||
} else {
|
||||
// 64-bit machines (Mac)
|
||||
|
||||
for( int i=0; i<numberOfPoints;i++)
|
||||
{
|
||||
newPoint[i].x = poli[i].x;
|
||||
newPoint[i].y = poli[i].y;
|
||||
}
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, newPoint );
|
||||
|
||||
}
|
||||
|
||||
if( closePolygon )
|
||||
glDrawArrays(GL_LINE_LOOP, 0, numberOfPoints);
|
||||
else
|
||||
glDrawArrays(GL_LINE_STRIP, 0, numberOfPoints);
|
||||
|
||||
// restore default state
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
delete[] newPoint;
|
||||
}
|
||||
|
||||
void ccDrawCircle(CCPoint center, float r, float a, int segs, bool drawLineToCenter)
|
||||
|
@ -180,11 +213,11 @@ void ccDrawCircle(CCPoint center, float r, float a, int segs, bool drawLineToCen
|
|||
float j = r * cosf(rads + a) + center.x;
|
||||
float k = r * sinf(rads + a) + center.y;
|
||||
|
||||
vertices[i*2] = j;
|
||||
vertices[i*2+1] =k;
|
||||
vertices[i*2] = j * CC_CONTENT_SCALE_FACTOR();
|
||||
vertices[i*2+1] =k * CC_CONTENT_SCALE_FACTOR();
|
||||
}
|
||||
vertices[(segs+1)*2] = center.x;
|
||||
vertices[(segs+1)*2+1] = center.y;
|
||||
vertices[(segs+1)*2] = center.x * CC_CONTENT_SCALE_FACTOR();
|
||||
vertices[(segs+1)*2+1] = center.y * CC_CONTENT_SCALE_FACTOR();
|
||||
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
|
@ -213,10 +246,10 @@ void ccDrawQuadBezier(CCPoint origin, CCPoint control, CCPoint destination, int
|
|||
{
|
||||
float x = powf(1 - t, 2) * origin.x + 2.0f * (1 - t) * t * control.x + t * t * destination.x;
|
||||
float y = powf(1 - t, 2) * origin.y + 2.0f * (1 - t) * t * control.y + t * t * destination.y;
|
||||
vertices[i] = CCPointMake(x, y);
|
||||
vertices[i] = CCPointMake(x * CC_CONTENT_SCALE_FACTOR(), y * CC_CONTENT_SCALE_FACTOR());
|
||||
t += 1.0f / segments;
|
||||
}
|
||||
vertices[segments] = destination;
|
||||
vertices[segments] = CCPointMake(destination.x * CC_CONTENT_SCALE_FACTOR(), destination.y * CC_CONTENT_SCALE_FACTOR());
|
||||
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
|
@ -244,10 +277,10 @@ void ccDrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoi
|
|||
{
|
||||
float x = powf(1 - t, 3) * origin.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x;
|
||||
float y = powf(1 - t, 3) * origin.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y;
|
||||
vertices[i] = CCPointMake(x, y);
|
||||
vertices[i] = CCPointMake(x * CC_CONTENT_SCALE_FACTOR(), y * CC_CONTENT_SCALE_FACTOR());
|
||||
t += 1.0f / segments;
|
||||
}
|
||||
vertices[segments] = destination;
|
||||
vertices[segments] = CCPointMake(destination.x * CC_CONTENT_SCALE_FACTOR(), destination.y * CC_CONTENT_SCALE_FACTOR());
|
||||
|
||||
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
||||
// Needed states: GL_VERTEX_ARRAY,
|
||||
|
|
|
@ -392,6 +392,7 @@ public:
|
|||
@since v0.99.5
|
||||
*/
|
||||
bool enableRetinaDisplay(bool enabled);
|
||||
bool isRetinaDisplay() { return m_bRetinaDisplay; }
|
||||
|
||||
/** There are 4 types of Director.
|
||||
- kCCDirectorTypeNSTimer (default)
|
||||
|
@ -548,6 +549,7 @@ protected:
|
|||
* mac platforms specific members
|
||||
**************************************************/
|
||||
bool m_bIsFullScreen;
|
||||
bool m_bRetinaDisplay;
|
||||
int m_nResizeMode;
|
||||
CCPoint m_winOffset;
|
||||
CCSize m_originalWinSize;
|
||||
|
|
|
@ -119,6 +119,7 @@ bool CCDirector::init(void)
|
|||
|
||||
m_pobOpenGLView = NULL;
|
||||
|
||||
m_bRetinaDisplay = false;
|
||||
m_fContentScaleFactor = 1;
|
||||
m_bIsContentScaleSupported = false;
|
||||
|
||||
|
@ -804,6 +805,16 @@ bool CCDirector::enableRetinaDisplay(bool enabled)
|
|||
m_pFPSLabel->retain();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_fContentScaleFactor == 2)
|
||||
{
|
||||
m_bRetinaDisplay = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bRetinaDisplay = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 811 B After Width: | Height: | Size: 811 B |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
Before Width: | Height: | Size: 43 B After Width: | Height: | Size: 43 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 811 B After Width: | Height: | Size: 811 B |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
@ -0,0 +1 @@
|
|||
79a3a895ba8a3568400db39e819a15d110045d6c
|
|
@ -0,0 +1 @@
|
|||
33b72a10558b874067b03ec1fd2a38a53b31d044
|
|
@ -11,9 +11,13 @@ CCLayer* createHiResLayer(int idx)
|
|||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
pLayer = new HiResTest1(); break;
|
||||
CCDirector::sharedDirector()->enableRetinaDisplay(false);
|
||||
pLayer = new HiResTest1();
|
||||
break;
|
||||
case 1:
|
||||
pLayer = new HiResTest2(); break;
|
||||
CCDirector::sharedDirector()->enableRetinaDisplay(true);
|
||||
pLayer = new HiResTest2();
|
||||
break;
|
||||
}
|
||||
|
||||
return pLayer;
|
||||
|
@ -44,6 +48,25 @@ CCLayer* backHiResAction()
|
|||
return pLayer;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// HiResTestBackToMainMenuLayer
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class HiResTestBackToainMenuLayer : public BackToMainMenuLayer
|
||||
{
|
||||
public:
|
||||
HiResTestBackToainMenuLayer() {}
|
||||
|
||||
// The CallBack for back to the main menu scene
|
||||
virtual void MainMenuCallback(CCObject* pSender)
|
||||
{
|
||||
CCDirector::sharedDirector()->enableRetinaDisplay(sm_bRitinaDisplay);
|
||||
BackToMainMenuLayer::MainMenuCallback(pSender);
|
||||
}
|
||||
|
||||
static bool sm_bRitinaDisplay;
|
||||
};
|
||||
bool HiResTestBackToainMenuLayer::sm_bRitinaDisplay = false;
|
||||
|
||||
////////////////////////////////////
|
||||
//
|
||||
// HiResDemo
|
||||
|
@ -143,16 +166,6 @@ void HiResDemo::backCallback(CCObject* pSender)
|
|||
///////////////////////////////////
|
||||
void HiResTest1::onEnter()
|
||||
{
|
||||
CCDirector::sharedDirector()->enableRetinaDisplay(false);
|
||||
// Because BackToMainMenuLayer maybe addChild to scene again by HiResTest2,
|
||||
// we add it again to make it in the right place.
|
||||
// The right way is calling enableRetinaDisplay before all scene and layer.
|
||||
CCScene * pScene = (CCScene*)getParent();
|
||||
CCLayer* pLayer = (CCLayer*)pScene->getChildByTag(54321);
|
||||
pScene->removeChild(pLayer, true);
|
||||
pLayer = new BackToMainMenuLayer;
|
||||
pScene->addChild(pLayer, 1000, 54321);
|
||||
pLayer->release();
|
||||
|
||||
HiResDemo::onEnter();
|
||||
|
||||
|
@ -180,17 +193,6 @@ std::string HiResTest1::subtitle()
|
|||
///////////////////////////////////
|
||||
void HiResTest2::onEnter()
|
||||
{
|
||||
CCDirector::sharedDirector()->enableRetinaDisplay(true);
|
||||
|
||||
// Because BackToMainMenuLayer has been addChild to scene,
|
||||
// we must add it again.
|
||||
// The right way is calling enableRetinaDisplay before all scene and layer.
|
||||
CCScene * pScene = (CCScene*)getParent();
|
||||
CCLayer* pLayer = (CCLayer*)pScene->getChildByTag(54321);
|
||||
pScene->removeChild(pLayer, true);
|
||||
pLayer = new BackToMainMenuLayer;
|
||||
pScene->addChild(pLayer, 1000, 54321);
|
||||
pLayer->release();
|
||||
|
||||
HiResDemo::onEnter();
|
||||
|
||||
|
@ -218,9 +220,22 @@ std::string HiResTest2::subtitle()
|
|||
///////////////////////////////////
|
||||
void HiResTestScene::runThisTest()
|
||||
{
|
||||
HiResTestBackToainMenuLayer::sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay();
|
||||
|
||||
CCLayer* pLayer = nextHiResAction();
|
||||
addChild(pLayer);
|
||||
|
||||
pLayer->release();
|
||||
CCDirector::sharedDirector()->replaceScene(this);
|
||||
}
|
||||
|
||||
void HiResTestScene::onEnter()
|
||||
{
|
||||
TestScene::onEnter();
|
||||
|
||||
CCLayer* pLayer = (CCLayer*)getChildByTag(54321);
|
||||
removeChild(pLayer, true);
|
||||
pLayer = new HiResTestBackToainMenuLayer;
|
||||
addChild(pLayer, 1000, 54321);
|
||||
pLayer->release();
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class HiResTestScene : public TestScene
|
|||
{
|
||||
public:
|
||||
virtual void runThisTest();
|
||||
virtual void onEnter();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,8 +17,6 @@ BackToMainMenuLayer::BackToMainMenuLayer()
|
|||
|
||||
void BackToMainMenuLayer::MainMenuCallback(CCObject* pSender)
|
||||
{
|
||||
CCDirector::sharedDirector()->enableRetinaDisplay(false);
|
||||
|
||||
CCScene* pScene = CCScene::node();
|
||||
CCLayer* pLayer = new TestController();
|
||||
pLayer->autorelease();
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
BackToMainMenuLayer();
|
||||
|
||||
// The CallBack for back to the main menu scene
|
||||
void MainMenuCallback(CCObject* pSender);
|
||||
virtual void MainMenuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class TestScene : public CCScene
|
||||
|
|