Skip to content

Commit

Permalink
Merge pull request #297 from liswei/issue502
Browse files Browse the repository at this point in the history
Issue502
  • Loading branch information
minggo committed Jun 15, 2011
2 parents c81c3a5 + af8b489 commit 145cbac
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 17 deletions.
26 changes: 13 additions & 13 deletions cocos2dx/CCConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ THE SOFTWARE.
using namespace std;
namespace cocos2d {

// singleton stuff
static bool g_bInited;
static CCConfiguration g_SharedConfiguration;
static char *g_pGlExtensions;

CCConfiguration::CCConfiguration(void)
:m_nMaxTextureSize(0)
Expand All @@ -42,8 +38,10 @@ CCConfiguration::CCConfiguration(void)
, m_bSupportsNPOT(false)
, m_bSupportsBGRA8888(false)
, m_bSupportsDiscardFramebuffer(false)
, m_bInited(false)
, m_uOSVersion(0)
, m_nMaxSamplesAllowed(0)
, m_pGlExtensions(NULL)
{
}

Expand All @@ -53,7 +51,7 @@ bool CCConfiguration::init(void)
CCLOG("cocos2d: GL_RENDERER: %s", glGetString(GL_RENDERER));
CCLOG("cocos2d: GL_VERSION: %s", glGetString(GL_VERSION));

g_pGlExtensions = (char *)glGetString(GL_EXTENSIONS);
m_pGlExtensions = (char *)glGetString(GL_EXTENSIONS);

glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_nMaxTextureSize);
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &m_nMaxModelviewStackDepth);
Expand Down Expand Up @@ -108,21 +106,23 @@ CCGlesVersion CCConfiguration::getGlesVersion()

CCConfiguration* CCConfiguration::sharedConfiguration(void)
{
if (! g_bInited)
{
g_SharedConfiguration.init();
}

return &g_SharedConfiguration;
static CCConfiguration sharedConfiguration;
if (!sharedConfiguration.m_bInited)
{
sharedConfiguration.init();
sharedConfiguration.m_bInited = true;
}

return &sharedConfiguration;
}

bool CCConfiguration::checkForGLExtension(const string &searchName)
{
bool bRet = false;
const char *kSearchName = searchName.c_str();

if (g_pGlExtensions &&
strstr(g_pGlExtensions, kSearchName))
if (m_pGlExtensions &&
strstr(m_pGlExtensions, kSearchName))
{
bRet = true;
}
Expand Down
9 changes: 7 additions & 2 deletions cocos2dx/CCConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ class CC_DLL CCConfiguration : public CCObject
bool m_bSupportsNPOT;
bool m_bSupportsBGRA8888;
bool m_bSupportsDiscardFramebuffer;
bool m_bInited;
unsigned int m_uOSVersion;
GLint m_nMaxSamplesAllowed;
char * m_pGlExtensions;

public:
CCConfiguration(void);
private:

CCConfiguration(void);

public:

CCGlesVersion getGlesVersion();

Expand Down
2 changes: 1 addition & 1 deletion cocos2dx/actions/CCActionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void CCActionManager::removeAction(cocos2d::CCAction *pAction)
if (pElement)
{
unsigned int i = ccArrayGetIndexOfObject(pElement->actions, pAction);
if (UINT_MAX == i)
if (UINT_MAX != i)
{
removeActionAtIndex(i, pElement);
}
Expand Down
6 changes: 6 additions & 0 deletions cocos2dx/include/CCParticleSystemPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class CC_DLL CCParticleSystemPoint : public CCParticleSystem
:m_pVertices(NULL)
{}
virtual ~CCParticleSystemPoint();

/** creates an initializes a CCParticleSystemPoint from a plist file.
This plist files can be creted manually or with Particle Designer:
*/
static CCParticleSystemPoint * particleWithFile(const char *plistFile);

// super methods
virtual bool initWithTotalParticles(int numberOfParticles);
virtual void updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition);
Expand Down
6 changes: 6 additions & 0 deletions cocos2dx/include/CCParticleSystemQuad.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class CC_DLL CCParticleSystemQuad : public CCParticleSystem
,m_pIndices(NULL)
{}
virtual ~CCParticleSystemQuad();

/** creates an initializes a CCParticleSystemQuad from a plist file.
This plist files can be creted manually or with Particle Designer:
*/
static CCParticleSystemQuad * particleWithFile(const char *plistFile);

/** initialices the indices for the vertices*/
void initIndices();

Expand Down
14 changes: 14 additions & 0 deletions cocos2dx/particle_nodes/CCParticleSystemPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ CCParticleSystemPoint::~CCParticleSystemPoint()
glDeleteBuffers(1, &m_uVerticesID);
#endif
}

// implementation CCParticleSystemPoint
CCParticleSystemPoint * CCParticleSystemPoint::particleWithFile(const char *plistFile)
{
CCParticleSystemPoint *pRet = new CCParticleSystemPoint();
if (pRet && pRet->initWithFile(plistFile))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet)
return pRet;
}

void CCParticleSystemPoint::updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition)
{
// place vertices and colos in array
Expand Down
14 changes: 13 additions & 1 deletion cocos2dx/particle_nodes/CCParticleSystemQuad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ THE SOFTWARE.
namespace cocos2d {

//implementation CCParticleSystemQuad

// overriding the init method
bool CCParticleSystemQuad::initWithTotalParticles(int numberOfParticles)
{
Expand Down Expand Up @@ -88,6 +87,19 @@ CCParticleSystemQuad::~CCParticleSystemQuad()
#endif
}

// implementation CCParticleSystemQuad
CCParticleSystemQuad * CCParticleSystemQuad::particleWithFile(const char *plistFile)
{
CCParticleSystemQuad *pRet = new CCParticleSystemQuad();
if (pRet && pRet->initWithFile(plistFile))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet)
return pRet;
}

// rect should be in Texture coordinates, not pixel coordinates
void CCParticleSystemQuad::initTexCoordsWithRect(CCRect pointRect)
{
Expand Down

0 comments on commit 145cbac

Please sign in to comment.