Giter VIP home page Giter VIP logo

cocos3d-x's Introduction

cocos3d-x

www.cocos3dx.org

the c++ version of cocos3d Powerful cocos3d IOS game engine and run on Android and many other platforms,

Cocos3dx is easy to use and developers who are familiar with cocos2dx will learn and understand cocos3dx very quickly.

The Android version of sample project 'HelloWorld' is built with vs-android please download and install it from tools directory in the trunk

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// COCOS2D-X -->> COCOS3D-X PORT INSTRUCTIONS

  1. CCAction: ///////////////////////////////////////////////////////////

.h add a member(void* m_pUserData) and two inline member accessors inline void setUserData( void* userData ) { m_pUserData = userData; } inline void* getUserData() { return m_pUserData; }

.cpp add constructor initializer of m_pUserData

  1. CCActionManager: //////////////////////////////////////////////////// to override the CCActionManager we need do the flowing modifications .h move struct _hashElement declaration from .cpp to .h change 'void removeAction(CCAction *pAction)' to 'virtual void removeAction(CCObject *pAction)'

.cpp remove struct _hashElement declaration modify the implementation of void CCActionManager::removeAction(CCObject *pAction) change 'CCObject *pTarget = pAction->getOriginalTarget()' under 'tHashElement *pElement = NULL;' to 'CCObject pTarget = ((CCAction)pAction)->getOriginalTarget()' and leave other codes unchanged.

  1. CCNode: ////////////////////////////////////////////////////////////

.h make function 'void transform(void)' virtual

  1. CCParticleSystem: //////////////////////////////////////////////////

.cpp find 'm_pParent->removeChild(this, true) in CCParticleSystem::update( float )' and add parent non-null condition as below if ( m_pParent != NULL ) m_pParent->removeChild(this, true);

  1. CCParticleSystemQuad: //////////////////////////////////////////////

.h add getter member function for m_pQuads and m_uParticleIdx as below const ccV3F_C4B_T2F_Quad* getQuads() { return m_pQuads; }; unsigned int getParticleIndex() { return m_uParticleIdx; };

  1. CCEGEView: /////////////////////////////////////////////////////////

  2. CCTexture2D: ///////////////////////////////////////////////////////

.h make function 'bool initWithData(const void* data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const CCSize& contentSize)' virtual

  1. CCDirector: ////////////////////////////////////////////////////////

.cpp modify the implementation of void CCDirector::purgeDirector() as below after 'CHECK_GL_ERROR_DEBUG();' in this function #if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 // OpenGL view // m_pobOpenGLView was allocated on the heap, keep the address here CCEGLView* pGLView = m_pobOpenGLView;

	// safe to end the glview now
	m_pobOpenGLView->end();
	m_pobOpenGLView = NULL;

	// delete CCDirector
	release();

	// destroy gl after all gl resources are released
	pGLView->destroyGL();
	CC_SAFE_DELETE( pGLView );
#else
	// OpenGL view
	m_pobOpenGLView->end();
	m_pobOpenGLView = NULL;

	// delete CCDirector
	release();
#endif
  1. base64

.cpp to fix the compile error on android, include .

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// COCOS2D-X CCScriptEngineManager memory leak fix

  1. Destructor of CCObject /// Modified as the following codes CCObject::~CCObject(void) { // if the object is managed, we should remove it // from pool manager if (m_uAutoReleaseCount > 0) { CCPoolManager::sharedPoolManager()->removeObject(this); }

     // if the object is referenced by Lua engine, remove it
     CCScriptEngineManager* scriptManager = CCScriptEngineManager::sharedManager();
     if ( scriptManager )
     {
     	if (m_nLuaID)
     	{
     		CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptObjectByCCObject(this);
     	}
     	else
     	{
     		CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine();
     		if (pEngine != NULL && pEngine->getScriptType() == kScriptTypeJavascript)
     		{
     			pEngine->removeScriptObjectByCCObject(this);
     		}
     	}
     }
    

    }

  2. CCScriptSupport.cpp a. add 'static bool s_purged = false'; right after 'static CCScriptEngineManager* s_pSharedScriptEngineManager = NULL;' b. modify CCScriptEngineManager::sharedManager and void CCScriptEngineManager::purgeSharedManager(void) as the following codes CCScriptEngineManager* CCScriptEngineManager::sharedManager(void) { if ( !s_pSharedScriptEngineManager && !s_purged ) { s_pSharedScriptEngineManager = new CCScriptEngineManager(); } return s_pSharedScriptEngineManager; }

    void CCScriptEngineManager::purgeSharedManager(void) { if ( s_pSharedScriptEngineManager ) { delete s_pSharedScriptEngineManager; s_pSharedScriptEngineManager = NULL; s_purged = true; } }

cocos3d-x's People

Contributors

happygames avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.