Merge pull request #835 from dumganhar/gles20

fixed #1155: Reverted CCDirector singleton to original implementation.
We must take care of the life cycle of CCDirector which should be firstly initialized and be destroyed at the last. Therefore, we should use a global object variable rather than a global object pointer variable.
This commit is contained in:
James Chen 2012-04-12 03:15:26 -07:00
commit ac89892db4
4 changed files with 13 additions and 13 deletions

View File

@ -119,7 +119,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes"
AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"

View File

@ -69,20 +69,21 @@ NS_CC_BEGIN
// XXX it shoul be a Director ivar. Move it there once support for multiple directors is added
// singleton stuff
static CCDisplayLinkDirector* s_pSharedDirector = NULL;
static CCDisplayLinkDirector s_SharedDirector;
#define kDefaultFPS 60 // 60 frames per second
extern const char* cocos2dVersion(void);
CCDirector* CCDirector::sharedDirector(void)
{
if (s_pSharedDirector == NULL)
static bool s_bFirstUseDirector = true;
if (s_bFirstUseDirector)
{
s_pSharedDirector = new CCDisplayLinkDirector();
s_pSharedDirector->init();
s_bFirstUseDirector = false;
s_SharedDirector.init();
}
return s_pSharedDirector;
return &s_SharedDirector;
}
CCDirector::CCDirector(void)
@ -673,7 +674,6 @@ void CCDirector::purgeDirector()
// OpenGL view
m_pobOpenGLView->release();
m_pobOpenGLView = NULL;
CC_SAFE_DELETE(s_pSharedDirector);
}
void CCDirector::setNextScene(void)
@ -1008,8 +1008,8 @@ void CCDisplayLinkDirector::mainLoop(void)
{
if (m_bPurgeDirecotorInNextLoop)
{
purgeDirector();
m_bPurgeDirecotorInNextLoop = false;
purgeDirector();
}
else if (! m_bInvalid)
{

View File

@ -124,7 +124,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\platform;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;.."
AdditionalIncludeDirectories="..\platform;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..;..\kazmath\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@ -145,7 +145,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libEGL.lib libgles_cm.lib libxml2.lib libzlib.lib libpng.lib libjpeg.lib libiconv.lib pthreadVCE2.lib"
AdditionalDependencies="libEGL.lib libGLESv2.lib libxml2.lib libzlib.lib libpng.lib libjpeg.lib libiconv.lib pthreadVCE2.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;"

View File

@ -120,7 +120,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;$(SolutionDir)cocos2dx\platform\third_party\win32&quot;;&quot;$(SolutionDir)cocos2dx\platform&quot;;&quot;$(SolutionDir)cocos2dx&quot;;&quot;$(SolutionDir)cocos2dx\include&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)chipmunk\include\chipmunk&quot;;&quot;$(SolutionDir)CocosDenshion\include&quot;;..\tests;&quot;$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES&quot;;..\;.\"
AdditionalIncludeDirectories="&quot;$(SolutionDir)cocos2dx\platform\third_party\win32&quot;;&quot;$(SolutionDir)cocos2dx\platform&quot;;&quot;$(SolutionDir)cocos2dx\kazmath\include&quot;;&quot;$(SolutionDir)cocos2dx&quot;;&quot;$(SolutionDir)cocos2dx\include&quot;;&quot;$(SolutionDir)&quot;;&quot;$(SolutionDir)chipmunk\include\chipmunk&quot;;&quot;$(SolutionDir)CocosDenshion\include&quot;;..\tests;&quot;$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES&quot;;..\;.\"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
@ -140,7 +140,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcocos2d.lib libgles_cm.lib libBox2d.lib libchipmunk.lib libcurl_imp.lib"
AdditionalDependencies="libcocos2d.lib libGLESv2.lib libBox2d.lib libchipmunk.lib libcurl_imp.lib"
OutputFile="$(OutDir)\$(ProjectName).exe"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;"