mirror of https://github.com/axmolengine/axmol.git
Merge pull request #350 from minggo/master
upgrade misc_nodes & particle_nodes to 1.0.0-rc3
This commit is contained in:
commit
89a845ebd7
|
@ -70,7 +70,7 @@ public:
|
|||
bool initWithFade(float fade, float seg, const char *imagePath, float width, float length, ccColor4B color);
|
||||
|
||||
/** polling function */
|
||||
void updateMotion(ccTime delta);
|
||||
void update(ccTime delta);
|
||||
protected:
|
||||
float m_fSegThreshold;
|
||||
float m_fWidth;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
CCParticleFire(){}
|
||||
virtual ~CCParticleFire(){}
|
||||
bool init(){ return initWithTotalParticles(250); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleFire * node()
|
||||
{
|
||||
CCParticleFire *pRet = new CCParticleFire();
|
||||
|
@ -58,7 +59,7 @@ public:
|
|||
CCParticleFireworks(){}
|
||||
virtual ~CCParticleFireworks(){}
|
||||
bool init(){ return initWithTotalParticles(1500); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleFireworks * node()
|
||||
{
|
||||
CCParticleFireworks *pRet = new CCParticleFireworks();
|
||||
|
@ -79,7 +80,7 @@ public:
|
|||
CCParticleSun(){}
|
||||
virtual ~CCParticleSun(){}
|
||||
bool init(){ return initWithTotalParticles(350); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleSun * node()
|
||||
{
|
||||
CCParticleSun *pRet = new CCParticleSun();
|
||||
|
@ -100,7 +101,7 @@ public:
|
|||
CCParticleGalaxy(){}
|
||||
virtual ~CCParticleGalaxy(){}
|
||||
bool init(){ return initWithTotalParticles(200); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleGalaxy * node()
|
||||
{
|
||||
CCParticleGalaxy *pRet = new CCParticleGalaxy();
|
||||
|
@ -121,7 +122,7 @@ public:
|
|||
CCParticleFlower(){}
|
||||
virtual ~CCParticleFlower(){}
|
||||
bool init(){ return initWithTotalParticles(250); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleFlower * node()
|
||||
{
|
||||
CCParticleFlower *pRet = new CCParticleFlower();
|
||||
|
@ -142,7 +143,7 @@ public:
|
|||
CCParticleMeteor(){}
|
||||
virtual ~CCParticleMeteor(){}
|
||||
bool init(){ return initWithTotalParticles(150); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleMeteor * node()
|
||||
{
|
||||
CCParticleMeteor *pRet = new CCParticleMeteor();
|
||||
|
@ -163,7 +164,7 @@ public:
|
|||
CCParticleSpiral(){}
|
||||
virtual ~CCParticleSpiral(){}
|
||||
bool init(){ return initWithTotalParticles(500); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleSpiral * node()
|
||||
{
|
||||
CCParticleSpiral *pRet = new CCParticleSpiral();
|
||||
|
@ -184,7 +185,7 @@ public:
|
|||
CCParticleExplosion(){}
|
||||
virtual ~CCParticleExplosion(){}
|
||||
bool init(){ return initWithTotalParticles(700); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleExplosion * node()
|
||||
{
|
||||
CCParticleExplosion *pRet = new CCParticleExplosion();
|
||||
|
@ -205,7 +206,7 @@ public:
|
|||
CCParticleSmoke(){}
|
||||
virtual ~CCParticleSmoke(){}
|
||||
bool init(){ return initWithTotalParticles(200); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleSmoke * node()
|
||||
{
|
||||
CCParticleSmoke *pRet = new CCParticleSmoke();
|
||||
|
@ -226,7 +227,7 @@ public:
|
|||
CCParticleSnow(){}
|
||||
virtual ~CCParticleSnow(){}
|
||||
bool init(){ return initWithTotalParticles(700); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleSnow * node()
|
||||
{
|
||||
CCParticleSnow *pRet = new CCParticleSnow();
|
||||
|
@ -247,7 +248,7 @@ public:
|
|||
CCParticleRain(){}
|
||||
virtual ~CCParticleRain(){}
|
||||
bool init(){ return initWithTotalParticles(1000); }
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
static CCParticleRain * node()
|
||||
{
|
||||
CCParticleRain *pRet = new CCParticleRain();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -358,7 +359,7 @@ public:
|
|||
bool initWithDictionary(CCDictionary<std::string, CCObject*> *dictionary);
|
||||
|
||||
//! Initializes a system with a fixed number of particles
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
//! Add a particle to the emitter
|
||||
bool addParticle();
|
||||
//! Initializes a particle
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -58,7 +59,7 @@ public:
|
|||
static CCParticleSystemPoint * particleWithFile(const char *plistFile);
|
||||
|
||||
// super methods
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
virtual void updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition);
|
||||
virtual void postStep();
|
||||
virtual void draw();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2009 Leonardo Kasperavičius
|
||||
Copyright (c) 2011 ynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -49,7 +50,7 @@ Special features and Limitations:
|
|||
class CC_DLL CCParticleSystemQuad : public CCParticleSystem
|
||||
{
|
||||
protected:
|
||||
ccV2F_C4F_T2F_Quad *m_pQuads; // quads to be rendered
|
||||
ccV2F_C4B_T2F_Quad *m_pQuads; // quads to be rendered
|
||||
GLushort *m_pIndices; // indices
|
||||
#if CC_USES_VBO
|
||||
GLuint m_uQuadsID; // VBO id
|
||||
|
@ -83,7 +84,7 @@ public:
|
|||
*/
|
||||
void setTextureWithRect(CCTexture2D *texture, CCRect rect);
|
||||
// super methods
|
||||
virtual bool initWithTotalParticles(int numberOfParticles);
|
||||
virtual bool initWithTotalParticles(unsigned int numberOfParticles);
|
||||
virtual void setTexture(CCTexture2D* var);
|
||||
virtual void updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition);
|
||||
virtual void postStep();
|
||||
|
|
|
@ -93,7 +93,7 @@ protected:
|
|||
float m_fPercentage;
|
||||
CCSprite *m_pSprite;
|
||||
int m_nVertexDataCount;
|
||||
ccV2F_C4F_T2F *m_pVertexData;
|
||||
ccV2F_C4B_T2F *m_pVertexData;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -97,11 +97,6 @@ protected:
|
|||
CCTexture2D* m_pTexture;
|
||||
|
||||
GLenum m_ePixelFormat;
|
||||
GLfloat m_aClearColor[4];
|
||||
|
||||
private:
|
||||
void saveGLstate();
|
||||
void restoreGLstate();
|
||||
};
|
||||
|
||||
} // namespace cocos2d
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -175,7 +176,7 @@ static inline ccTex2F tex2(const float u, const float v)
|
|||
typedef struct _ccPointSprite
|
||||
{
|
||||
ccVertex2F pos; // 8 bytes
|
||||
ccColor4F colors; // 16 bytes
|
||||
ccColor4B color; // 4 bytes
|
||||
GLfloat size; // 4 bytes
|
||||
} ccPointSprite;
|
||||
|
||||
|
@ -211,6 +212,17 @@ ccg(const int x, const int y)
|
|||
return v;
|
||||
}
|
||||
|
||||
//! a Point with a vertex point, a tex coord point and a color 4B
|
||||
typedef struct _ccV2F_C4B_T2F
|
||||
{
|
||||
//! vertices (2F)
|
||||
ccVertex2F vertices;
|
||||
//! colors (4B)
|
||||
ccColor4B colors;
|
||||
//! tex coords (2F)
|
||||
ccTex2F texCoords;
|
||||
} ccV2F_C4B_T2F;
|
||||
|
||||
//! a Point with a vertex point, a tex coord point and a color 4F
|
||||
typedef struct _ccV2F_C4F_T2F
|
||||
{
|
||||
|
@ -237,6 +249,19 @@ typedef struct _ccV3F_C4B_T2F
|
|||
ccTex2F texCoords; // 8 byts
|
||||
} ccV3F_C4B_T2F;
|
||||
|
||||
//! 4 ccVertex2FTex2FColor4B Quad
|
||||
typedef struct _ccV2F_C4B_T2F_Quad
|
||||
{
|
||||
//! bottom left
|
||||
ccV2F_C4B_T2F bl;
|
||||
//! bottom right
|
||||
ccV2F_C4B_T2F br;
|
||||
//! top left
|
||||
ccV2F_C4B_T2F tl;
|
||||
//! top right
|
||||
ccV2F_C4B_T2F tr;
|
||||
} ccV2F_C4B_T2F_Quad;
|
||||
|
||||
//! 4 ccVertex3FTex2FColor4B
|
||||
typedef struct _ccV3F_C4B_T2F_Quad
|
||||
{
|
||||
|
|
|
@ -58,12 +58,12 @@ bool CCMotionStreak::initWithFade(float fade, float seg, const char *imagePath,
|
|||
m_pRibbon = CCRibbon::ribbonWithWidth(m_fWidth, imagePath, length, color, fade);
|
||||
this->addChild(m_pRibbon);
|
||||
|
||||
// update ribbon position
|
||||
this->schedule(schedule_selector(CCMotionStreak::updateMotion), 0);
|
||||
// update ribbon position. Use schedule:interval and not scheduleUpdated. (cocos2d-iphone)issue #1075
|
||||
this->schedule(schedule_selector(CCMotionStreak::update), 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCMotionStreak::updateMotion(ccTime delta)
|
||||
void CCMotionStreak::update(ccTime delta)
|
||||
{
|
||||
CCPoint location = this->convertToWorldSpace(CCPointZero);
|
||||
m_pRibbon->setPosition(ccp(-1*location.x, -1*location.y));
|
||||
|
|
|
@ -96,19 +96,7 @@ void CCProgressTimer::setPercentage(float fPercentage)
|
|||
{
|
||||
if (m_fPercentage != fPercentage)
|
||||
{
|
||||
if (m_fPercentage < 0.f)
|
||||
{
|
||||
m_fPercentage = 0.f;
|
||||
} else
|
||||
if (fPercentage > 100.0f)
|
||||
{
|
||||
m_fPercentage = 100.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fPercentage = fPercentage;
|
||||
}
|
||||
|
||||
m_fPercentage = clampf(m_fPercentage, 0, 100);
|
||||
updateProgress();
|
||||
}
|
||||
}
|
||||
|
@ -176,18 +164,15 @@ ccVertex2F CCProgressTimer::vertexFromTexCoord(cocos2d::CCPoint texCoord)
|
|||
|
||||
void CCProgressTimer::updateColor(void)
|
||||
{
|
||||
ccColor4F color = ccc4FFromccc3B(m_pSprite->getColor());
|
||||
GLbyte op = m_pSprite->getOpacity();
|
||||
ccColor3B c3b = m_pSprite->getColor();
|
||||
|
||||
ccColor4B color = {c3b.r, c3b.g, c3b.b, op};
|
||||
if (m_pSprite->getTexture()->getHasPremultipliedAlpha())
|
||||
{
|
||||
float op = m_pSprite->getOpacity() / 255.f;
|
||||
color.r *= op;
|
||||
color.g *= op;
|
||||
color.b *= op;
|
||||
color.a = op;
|
||||
}
|
||||
else
|
||||
{
|
||||
color.a = m_pSprite->getOpacity() / 255.f;
|
||||
color.r *= op / 255;
|
||||
color.g *= op / 255;
|
||||
color.b *= op / 255;
|
||||
}
|
||||
|
||||
if (m_pVertexData)
|
||||
|
@ -344,7 +329,7 @@ void CCProgressTimer::updateRadial(void)
|
|||
if (! m_pVertexData)
|
||||
{
|
||||
m_nVertexDataCount = index + 3;
|
||||
m_pVertexData = new ccV2F_C4F_T2F[m_nVertexDataCount];
|
||||
m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount];
|
||||
assert(m_pVertexData);
|
||||
|
||||
updateColor();
|
||||
|
@ -420,6 +405,7 @@ void CCProgressTimer::updateBar(void)
|
|||
CCPoint tMax = ccp(m_pSprite->getTexture()->getMaxS(), m_pSprite->getTexture()->getMaxT());
|
||||
|
||||
unsigned char vIndexes[2] = {0, 0};
|
||||
unsigned char index = 0;
|
||||
|
||||
// We know vertex data is always equal to the 4 corners
|
||||
// If we don't have vertex data then we create it here and populate
|
||||
|
@ -427,7 +413,7 @@ void CCProgressTimer::updateBar(void)
|
|||
if (! m_pVertexData)
|
||||
{
|
||||
m_nVertexDataCount = kProgressTextureCoordsCount;
|
||||
m_pVertexData = new ccV2F_C4F_T2F[m_nVertexDataCount];
|
||||
m_pVertexData = new ccV2F_C4B_T2F[m_nVertexDataCount];
|
||||
assert(m_pVertexData);
|
||||
|
||||
if (m_eType == kCCProgressTimerTypeHorizontalBarLR)
|
||||
|
@ -451,7 +437,7 @@ void CCProgressTimer::updateBar(void)
|
|||
m_pVertexData[vIndexes[1] = 2].texCoords = tex2(tMax.x, 0);
|
||||
}
|
||||
|
||||
unsigned char index = vIndexes[0];
|
||||
index = vIndexes[0];
|
||||
m_pVertexData[index].vertices = vertexFromTexCoord(ccp(m_pVertexData[index].texCoords.u,
|
||||
m_pVertexData[index].texCoords.v));
|
||||
|
||||
|
@ -463,7 +449,7 @@ void CCProgressTimer::updateBar(void)
|
|||
{
|
||||
if (m_pSprite->isFlipX())
|
||||
{
|
||||
unsigned char index = vIndexes[0];
|
||||
index = vIndexes[0];
|
||||
m_pVertexData[index].texCoords.u = tMax.x - m_pVertexData[index].texCoords.u;
|
||||
index = vIndexes[1];
|
||||
m_pVertexData[index].texCoords.u = tMax.x - m_pVertexData[index].texCoords.u;
|
||||
|
@ -471,7 +457,7 @@ void CCProgressTimer::updateBar(void)
|
|||
|
||||
if (m_pSprite->isFlipY())
|
||||
{
|
||||
unsigned char index = vIndexes[0];
|
||||
index = vIndexes[0];
|
||||
m_pVertexData[index].texCoords.v = tMax.y - m_pVertexData[index].texCoords.v;
|
||||
index = vIndexes[1];
|
||||
m_pVertexData[index].texCoords.v = tMax.y - m_pVertexData[index].texCoords.v;
|
||||
|
@ -502,7 +488,7 @@ void CCProgressTimer::updateBar(void)
|
|||
m_pVertexData[vIndexes[1] = 3].texCoords = tex2(tMax.x, tMax.y*alpha);
|
||||
}
|
||||
|
||||
unsigned char index = vIndexes[0];
|
||||
index = vIndexes[0];
|
||||
m_pVertexData[index].vertices = vertexFromTexCoord(ccp(m_pVertexData[index].texCoords.u,
|
||||
m_pVertexData[index].texCoords.v));
|
||||
index = vIndexes[1];
|
||||
|
@ -513,7 +499,7 @@ void CCProgressTimer::updateBar(void)
|
|||
{
|
||||
if (m_pSprite->isFlipX())
|
||||
{
|
||||
unsigned char index = vIndexes[0];
|
||||
index = vIndexes[0];
|
||||
m_pVertexData[index].texCoords.u = tMax.x - m_pVertexData[index].texCoords.u;
|
||||
index = vIndexes[1];
|
||||
m_pVertexData[index].texCoords.u = tMax.x - m_pVertexData[index].texCoords.u;
|
||||
|
@ -521,7 +507,7 @@ void CCProgressTimer::updateBar(void)
|
|||
|
||||
if (m_pSprite->isFlipY())
|
||||
{
|
||||
unsigned char index = vIndexes[0];
|
||||
index = vIndexes[0];
|
||||
m_pVertexData[index].texCoords.v = tMax.y - m_pVertexData[index].texCoords.v;
|
||||
index = vIndexes[1];
|
||||
m_pVertexData[index].texCoords.v = tMax.y - m_pVertexData[index].texCoords.v;
|
||||
|
@ -570,9 +556,9 @@ void CCProgressTimer::draw(void)
|
|||
// Replaced [texture_ drawAtPoint:CCPointZero] with my own vertexData
|
||||
// Everything above me and below me is copied from CCTextureNode's draw
|
||||
glBindTexture(GL_TEXTURE_2D, m_pSprite->getTexture()->getName());
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(ccV2F_C4F_T2F), &m_pVertexData[0].vertices);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(ccV2F_C4F_T2F), &m_pVertexData[0].texCoords);
|
||||
glColorPointer(4, GL_FLOAT, sizeof(ccV2F_C4F_T2F), &m_pVertexData[0].colors);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(ccV2F_C4B_T2F), &m_pVertexData[0].vertices);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(ccV2F_C4B_T2F), &m_pVertexData[0].texCoords);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ccV2F_C4B_T2F), &m_pVertexData[0].colors);
|
||||
|
||||
if(m_eType == kCCProgressTimerTypeRadialCCW || m_eType == kCCProgressTimerTypeRadialCW)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,6 @@ CCRenderTexture::CCRenderTexture()
|
|||
, m_pTexture(0)
|
||||
, m_ePixelFormat(kCCPixelFormatRGBA8888)
|
||||
{
|
||||
memset(m_aClearColor, 0, sizeof(m_aClearColor));
|
||||
}
|
||||
|
||||
CCRenderTexture::~CCRenderTexture()
|
||||
|
@ -155,9 +154,6 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma
|
|||
|
||||
void CCRenderTexture::begin()
|
||||
{
|
||||
saveGLstate();
|
||||
|
||||
CC_DISABLE_DEFAULT_GL_STATES();
|
||||
// Save the current matrix
|
||||
glPushMatrix();
|
||||
|
||||
|
@ -176,36 +172,32 @@ void CCRenderTexture::begin()
|
|||
glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &m_nOldFBO);
|
||||
ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_uFBO);//Will direct drawing to the frame buffer created above
|
||||
|
||||
// Issue #1145
|
||||
// There is no need to enable the default GL states here
|
||||
// but since CCRenderTexture is mostly used outside the "render" loop
|
||||
// these states needs to be enabled.
|
||||
// Since this bug was discovered in API-freeze (very close of 1.0 release)
|
||||
// This bug won't be fixed to prevent incompatibilities with code.
|
||||
//
|
||||
// If you understand the above mentioned message, then you can comment the following line
|
||||
// and enable the gl states manually, in case you need them.
|
||||
|
||||
CC_ENABLE_DEFAULT_GL_STATES();
|
||||
}
|
||||
|
||||
void CCRenderTexture::beginWithClear(float r, float g, float b, float a)
|
||||
{
|
||||
this->saveGLstate();
|
||||
this->begin();
|
||||
|
||||
CC_DISABLE_DEFAULT_GL_STATES();
|
||||
// Save the current matrix
|
||||
glPushMatrix();
|
||||
// save clear color
|
||||
GLfloat clearColor[4];
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor);
|
||||
|
||||
CCSize texSize = m_pTexture->getContentSizeInPixels();
|
||||
glClearColor(r, g, b, a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Calculate the adjustment ratios based on the old and new projections
|
||||
CCSize size = CCDirector::sharedDirector()->getDisplaySizeInPixels();
|
||||
float widthRatio = size.width / texSize.width;
|
||||
float heightRatio = size.height / texSize.height;
|
||||
|
||||
// Adjust the orthographic propjection and viewport
|
||||
ccglOrtho((float)-1.0 / widthRatio, (float)1.0 / widthRatio, (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1);
|
||||
glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height);
|
||||
// CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, texSize.width, texSize.height);
|
||||
|
||||
glGetIntegerv(CC_GL_FRAMEBUFFER_BINDING, &m_nOldFBO);
|
||||
ccglBindFramebuffer(CC_GL_FRAMEBUFFER, m_uFBO);//Will direct drawing to the frame buffer created above
|
||||
|
||||
glClearColor(r, g, b, a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
CC_ENABLE_DEFAULT_GL_STATES();
|
||||
// restore clear color
|
||||
glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
|
||||
}
|
||||
|
||||
void CCRenderTexture::end()
|
||||
|
@ -216,28 +208,14 @@ void CCRenderTexture::end()
|
|||
CCSize size = CCDirector::sharedDirector()->getDisplaySizeInPixels();
|
||||
// glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height);
|
||||
CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
|
||||
this->restoreGLstate();
|
||||
}
|
||||
|
||||
void CCRenderTexture::clear(float r, float g, float b, float a)
|
||||
{
|
||||
this->begin();
|
||||
glClearColor(r, g, b, a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
this->beginWithClear(r, g, b, a);
|
||||
this->end();
|
||||
}
|
||||
|
||||
void CCRenderTexture::saveGLstate()
|
||||
{
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, m_aClearColor);
|
||||
}
|
||||
|
||||
void CCRenderTexture::restoreGLstate()
|
||||
{
|
||||
glClearColor(m_aClearColor[0], m_aClearColor[1], m_aClearColor[2], m_aClearColor[3]);
|
||||
}
|
||||
|
||||
|
||||
bool CCRenderTexture::saveBuffer(const char *name)
|
||||
{
|
||||
return this->saveBuffer(name, kCCImageFormatJPG);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -30,7 +31,7 @@ namespace cocos2d {
|
|||
//
|
||||
// ParticleFire
|
||||
//
|
||||
bool CCParticleFire::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -100,7 +101,7 @@ bool CCParticleFire::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleFireworks
|
||||
//
|
||||
bool CCParticleFireworks::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -168,7 +169,7 @@ bool CCParticleFireworks::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleSun
|
||||
//
|
||||
bool CCParticleSun::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -240,7 +241,7 @@ bool CCParticleSun::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleGalaxy
|
||||
//
|
||||
bool CCParticleGalaxy::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -314,7 +315,7 @@ bool CCParticleGalaxy::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleFlower
|
||||
//
|
||||
bool CCParticleFlower::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -387,7 +388,7 @@ bool CCParticleFlower::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleMeteor
|
||||
//
|
||||
bool CCParticleMeteor::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -461,7 +462,7 @@ bool CCParticleMeteor::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleSpiral
|
||||
//
|
||||
bool CCParticleSpiral::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -535,7 +536,7 @@ bool CCParticleSpiral::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleExplosion
|
||||
//
|
||||
bool CCParticleExplosion::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -608,7 +609,7 @@ bool CCParticleExplosion::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// ParticleSmoke
|
||||
//
|
||||
bool CCParticleSmoke::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -677,7 +678,7 @@ bool CCParticleSmoke::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// CCParticleSnow
|
||||
//
|
||||
bool CCParticleSnow::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -750,7 +751,7 @@ bool CCParticleSnow::initWithTotalParticles(int numberOfParticles)
|
|||
//
|
||||
// CCParticleRain
|
||||
//
|
||||
bool CCParticleRain::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( ARCH_OPTIMAL_PARTICLE_SYSTEM::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -203,6 +204,12 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
|
|||
m_tPosVar.x = (float)atof(valueForKey("sourcePositionVariancex", dictionary));
|
||||
m_tPosVar.y = (float)atof(valueForKey("sourcePositionVariancey", dictionary));
|
||||
|
||||
// Spinning
|
||||
m_fStartSpin = (float)atof(valueForKey("rotationStart", dictionary));
|
||||
m_fStartSpinVar = (float)atof(valueForKey("rotationStartVariance", dictionary));
|
||||
m_fEndSpin= (float)atof(valueForKey("rotationEnd", dictionary));
|
||||
m_fEndSpinVar= (float)atof(valueForKey("rotationEndVariance", dictionary));
|
||||
|
||||
m_nEmitterMode = atoi(valueForKey("emitterType", dictionary));
|
||||
|
||||
// Mode A: Gravity + tangential accel + radial accel
|
||||
|
@ -259,25 +266,32 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
|
|||
char *textureName = (char *)valueForKey("textureFileName", dictionary);
|
||||
std::string fullpath = CCFileUtils::fullPathFromRelativeFile(textureName, m_sPlistFile.c_str());
|
||||
|
||||
CCTexture2D *tex = NULL;
|
||||
|
||||
if (strlen(textureName) > 0)
|
||||
{
|
||||
// set not pop-up message box when load image failed
|
||||
bool bNotify = CCFileUtils::getIsPopupNotify();
|
||||
CCFileUtils::setIsPopupNotify(false);
|
||||
this->m_pTexture = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str());
|
||||
tex = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str());
|
||||
|
||||
// reset the value of UIImage notify
|
||||
CCFileUtils::setIsPopupNotify(bNotify);
|
||||
}
|
||||
|
||||
// if it fails, try to get it from the base64-gzipped data
|
||||
char *textureData = NULL;
|
||||
if ( ! m_pTexture &&
|
||||
(textureData = (char *)valueForKey("textureImageData", dictionary)))
|
||||
if (tex)
|
||||
{
|
||||
this->m_pTexture = tex;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *textureData = (char*)valueForKey("textureImageData", dictionary);
|
||||
assert(textureData);
|
||||
|
||||
int dataLen = strlen(textureData);
|
||||
if(dataLen != 0)
|
||||
{
|
||||
// if it fails, try to get it from the base64-gzipped data
|
||||
int decodeLen = base64Decode((unsigned char*)textureData, dataLen, &buffer);
|
||||
CCAssert( buffer != NULL, "CCParticleSystem: error decoding textureImageData");
|
||||
CC_BREAK_IF(!buffer);
|
||||
|
@ -306,7 +320,7 @@ bool CCParticleSystem::initWithDictionary(CCDictionary<std::string, CCObject*> *
|
|||
CC_SAFE_DELETE(image);
|
||||
return bRet;
|
||||
}
|
||||
bool CCParticleSystem::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
m_nTotalParticles = numberOfParticles;
|
||||
|
||||
|
@ -381,7 +395,8 @@ void CCParticleSystem::initParticle(tCCParticle* particle)
|
|||
{
|
||||
// timeToLive
|
||||
// no negative life. prevent division by 0
|
||||
particle->timeToLive = MAX(0, m_fLife + m_fLifeVar * CCRANDOM_MINUS1_1() );
|
||||
particle->timeToLive = m_fLife + m_fLifeVar * CCRANDOM_MINUS1_1();
|
||||
particle->timeToLive = MAX(0, particle->timeToLive);
|
||||
|
||||
// position
|
||||
particle->pos.x = m_tSourcePosition.x + m_tPosVar.x * CCRANDOM_MINUS1_1();
|
||||
|
@ -391,16 +406,16 @@ void CCParticleSystem::initParticle(tCCParticle* particle)
|
|||
|
||||
// Color
|
||||
ccColor4F start;
|
||||
start.r = MIN(1, MAX(0, m_tStartColor.r + m_tStartColorVar.r * CCRANDOM_MINUS1_1() ) );
|
||||
start.g = MIN(1, MAX(0, m_tStartColor.g + m_tStartColorVar.g * CCRANDOM_MINUS1_1() ) );
|
||||
start.b = MIN(1, MAX(0, m_tStartColor.b + m_tStartColorVar.b * CCRANDOM_MINUS1_1() ) );
|
||||
start.a = MIN(1, MAX(0, m_tStartColor.a + m_tStartColorVar.a * CCRANDOM_MINUS1_1() ) );
|
||||
start.r = clampf(m_tStartColor.r + m_tStartColorVar.r * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
start.g = clampf(m_tStartColor.g + m_tStartColorVar.g * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
start.b = clampf(m_tStartColor.b + m_tStartColorVar.b * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
start.a = clampf(m_tStartColor.a + m_tStartColorVar.a * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
|
||||
ccColor4F end;
|
||||
end.r = MIN(1, MAX(0, m_tEndColor.r + m_tEndColorVar.r * CCRANDOM_MINUS1_1() ) );
|
||||
end.g = MIN(1, MAX(0, m_tEndColor.g + m_tEndColorVar.g * CCRANDOM_MINUS1_1() ) );
|
||||
end.b = MIN(1, MAX(0, m_tEndColor.b + m_tEndColorVar.b * CCRANDOM_MINUS1_1() ) );
|
||||
end.a = MIN(1, MAX(0, m_tEndColor.a + m_tEndColorVar.a * CCRANDOM_MINUS1_1() ) );
|
||||
end.r = clampf(m_tEndColor.r + m_tEndColorVar.r * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
end.g = clampf(m_tEndColor.g + m_tEndColorVar.g * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
end.b = clampf(m_tEndColor.b + m_tEndColorVar.b * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
end.a = clampf(m_tEndColor.a + m_tEndColorVar.a * CCRANDOM_MINUS1_1(), 0, 1);
|
||||
|
||||
particle->color = start;
|
||||
particle->deltaColor.r = (end.r - start.r) / particle->timeToLive;
|
||||
|
@ -409,7 +424,8 @@ void CCParticleSystem::initParticle(tCCParticle* particle)
|
|||
particle->deltaColor.a = (end.a - start.a) / particle->timeToLive;
|
||||
|
||||
// size
|
||||
float startS = MAX(0, m_fStartSize + m_fStartSizeVar * CCRANDOM_MINUS1_1() ); // no negative size
|
||||
float startS = m_fStartSize + m_fStartSizeVar * CCRANDOM_MINUS1_1();
|
||||
startS = MAX(0, startS); // No negative value
|
||||
startS *= CC_CONTENT_SCALE_FACTOR();
|
||||
|
||||
particle->size = startS;
|
||||
|
@ -421,7 +437,7 @@ void CCParticleSystem::initParticle(tCCParticle* particle)
|
|||
else
|
||||
{
|
||||
float endS = m_fEndSize + m_fEndSizeVar * CCRANDOM_MINUS1_1();
|
||||
endS = MAX(0, endS);
|
||||
endS = MAX(0, endS); // No negative values
|
||||
endS *= CC_CONTENT_SCALE_FACTOR();
|
||||
particle->deltaSize = (endS - startS) / particle->timeToLive;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -28,7 +29,7 @@ THE SOFTWARE.
|
|||
namespace cocos2d {
|
||||
|
||||
//implementation CCParticleSystemPoint
|
||||
bool CCParticleSystemPoint::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleSystemPoint::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
if( CCParticleSystem::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
|
@ -79,7 +80,8 @@ void CCParticleSystemPoint::updateQuadWithParticle(tCCParticle* particle, CCPoin
|
|||
// place vertices and colos in array
|
||||
m_pVertices[m_nParticleIdx].pos = vertex2(newPosition.x, newPosition.y);
|
||||
m_pVertices[m_nParticleIdx].size = particle->size;
|
||||
m_pVertices[m_nParticleIdx].colors = particle->color;
|
||||
ccColor4B color = {(GLubyte)particle->color.r * 255, (GLubyte)particle->color.g * 255, (GLubyte)particle->color.b * 255, (GLubyte)particle->color.a * 255};
|
||||
m_pVertices[m_nParticleIdx].color = color;
|
||||
}
|
||||
void CCParticleSystemPoint::postStep()
|
||||
{
|
||||
|
@ -117,7 +119,7 @@ void CCParticleSystemPoint::draw()
|
|||
|
||||
glVertexPointer(2,GL_FLOAT,kPointSize,0);
|
||||
|
||||
glColorPointer(4, GL_FLOAT, kPointSize,(GLvoid*) offsetof(ccPointSprite,colors) );
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, kPointSize,(GLvoid*)offsetof(ccPointSprite,color) );
|
||||
|
||||
glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
|
||||
glPointSizePointerOES(GL_FLOAT,kPointSize,(GLvoid*) offsetof(ccPointSprite,size) );
|
||||
|
@ -125,8 +127,8 @@ void CCParticleSystemPoint::draw()
|
|||
int offset = (int)m_pVertices;
|
||||
glVertexPointer(2,GL_FLOAT, kPointSize, (GLvoid*) offset);
|
||||
|
||||
int diff = offsetof(ccPointSprite, colors);
|
||||
glColorPointer(4, GL_FLOAT, kPointSize, (GLvoid*) (offset+diff));
|
||||
int diff = offsetof(ccPointSprite, color);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, kPointSize, (GLvoid*) (offset+diff));
|
||||
|
||||
glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
|
||||
diff = offsetof(ccPointSprite, size);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2009 Leonardo Kasperavičius
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
|
@ -33,13 +34,13 @@ namespace cocos2d {
|
|||
|
||||
//implementation CCParticleSystemQuad
|
||||
// overriding the init method
|
||||
bool CCParticleSystemQuad::initWithTotalParticles(int numberOfParticles)
|
||||
bool CCParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
|
||||
{
|
||||
// base initialization
|
||||
if( CCParticleSystem::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// allocating data space
|
||||
m_pQuads = new ccV2F_C4F_T2F_Quad[m_nTotalParticles];
|
||||
m_pQuads = new ccV2F_C4B_T2F_Quad[m_nTotalParticles];
|
||||
m_pIndices = new GLushort[m_nTotalParticles * 6];
|
||||
|
||||
if( !m_pQuads || !m_pIndices)
|
||||
|
@ -100,10 +101,10 @@ CCParticleSystemQuad * CCParticleSystemQuad::particleWithFile(const char *plistF
|
|||
return pRet;
|
||||
}
|
||||
|
||||
// rect should be in Texture coordinates, not pixel coordinates
|
||||
// pointRect should be in Texture coordinates, not pixel coordinates
|
||||
void CCParticleSystemQuad::initTexCoordsWithRect(CCRect pointRect)
|
||||
{
|
||||
// convert to Tex coords
|
||||
// convert to pixels coords
|
||||
|
||||
CCRect rect = CCRectMake(
|
||||
pointRect.origin.x * CC_CONTENT_SCALE_FACTOR(),
|
||||
|
@ -163,9 +164,8 @@ void CCParticleSystemQuad::setTextureWithRect(CCTexture2D *texture, CCRect rect)
|
|||
}
|
||||
void CCParticleSystemQuad::setTexture(CCTexture2D* var)
|
||||
{
|
||||
this->setTextureWithRect(var, CCRectMake(0, 0,
|
||||
(float)(var->getPixelsWide() / CC_CONTENT_SCALE_FACTOR()),
|
||||
(float)(var->getPixelsHigh() / CC_CONTENT_SCALE_FACTOR())));
|
||||
CCSize s = m_pTexture->getContentSize();
|
||||
this->setTextureWithRect(var, CCRectMake(0, 0, s.width, s.height));
|
||||
}
|
||||
void CCParticleSystemQuad::setDisplayFrame(CCSpriteFrame *spriteFrame)
|
||||
{
|
||||
|
@ -181,8 +181,8 @@ void CCParticleSystemQuad::initIndices()
|
|||
{
|
||||
for( int i = 0; i < m_nTotalParticles; ++i)
|
||||
{
|
||||
const int i6 = i*6;
|
||||
const int i4 = i*4;
|
||||
const unsigned int i6 = i*6;
|
||||
const unsigned int i4 = i*4;
|
||||
m_pIndices[i6+0] = (GLushort) i4+0;
|
||||
m_pIndices[i6+1] = (GLushort) i4+1;
|
||||
m_pIndices[i6+2] = (GLushort) i4+2;
|
||||
|
@ -195,11 +195,14 @@ void CCParticleSystemQuad::initIndices()
|
|||
void CCParticleSystemQuad::updateQuadWithParticle(tCCParticle* particle, CCPoint newPosition)
|
||||
{
|
||||
// colors
|
||||
ccV2F_C4F_T2F_Quad *quad = &(m_pQuads[m_nParticleIdx]);
|
||||
quad->bl.colors = particle->color;
|
||||
quad->br.colors = particle->color;
|
||||
quad->tl.colors = particle->color;
|
||||
quad->tr.colors = particle->color;
|
||||
ccV2F_C4B_T2F_Quad *quad = &(m_pQuads[m_nParticleIdx]);
|
||||
|
||||
ccColor4B color = {(GLbyte)particle->color.r * 255, (GLbyte)particle->color.g * 255, (GLbyte)particle->color.b * 255,
|
||||
(GLbyte)particle->color.b * 255};
|
||||
quad->bl.colors = color;
|
||||
quad->br.colors = color;
|
||||
quad->tl.colors = color;
|
||||
quad->tr.colors = color;
|
||||
|
||||
// vertices
|
||||
GLfloat size_2 = particle->size/2;
|
||||
|
@ -286,23 +289,23 @@ void CCParticleSystemQuad::draw()
|
|||
|
||||
glVertexPointer(2,GL_FLOAT, kQuadSize, 0);
|
||||
|
||||
glColorPointer(4, GL_FLOAT, kQuadSize, (GLvoid*) offsetof(ccV2F_C4F_T2F,colors) );
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, kQuadSize, (GLvoid*) offsetof(ccV2F_C4B_T2F,colors) );
|
||||
|
||||
glTexCoordPointer(2, GL_FLOAT, kQuadSize, (GLvoid*) offsetof(ccV2F_C4F_T2F,texCoords) );
|
||||
glTexCoordPointer(2, GL_FLOAT, kQuadSize, (GLvoid*) offsetof(ccV2F_C4B_T2F,texCoords) );
|
||||
#else // vertex array list
|
||||
|
||||
int offset = (int) m_pQuads;
|
||||
|
||||
// vertex
|
||||
int diff = offsetof( ccV2F_C4F_T2F, vertices);
|
||||
int diff = offsetof( ccV2F_C4B_T2F, vertices);
|
||||
glVertexPointer(2,GL_FLOAT, kQuadSize, (GLvoid*) (offset+diff) );
|
||||
|
||||
// color
|
||||
diff = offsetof( ccV2F_C4F_T2F, colors);
|
||||
glColorPointer(4, GL_FLOAT, kQuadSize, (GLvoid*)(offset + diff));
|
||||
diff = offsetof( ccV2F_C4B_T2F, colors);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, kQuadSize, (GLvoid*)(offset + diff));
|
||||
|
||||
// tex coords
|
||||
diff = offsetof( ccV2F_C4F_T2F, texCoords);
|
||||
diff = offsetof( ccV2F_C4B_T2F, texCoords);
|
||||
glTexCoordPointer(2, GL_FLOAT, kQuadSize, (GLvoid*)(offset + diff));
|
||||
|
||||
#endif // ! CC_USES_VBO
|
||||
|
@ -315,7 +318,7 @@ void CCParticleSystemQuad::draw()
|
|||
|
||||
CCAssert( m_nParticleIdx == m_nParticleCount, "Abnormal error in particle quad");
|
||||
|
||||
glDrawElements(GL_TRIANGLES, m_nParticleIdx*6, GL_UNSIGNED_SHORT, m_pIndices);
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)m_nParticleIdx*6, GL_UNSIGNED_SHORT, m_pIndices);
|
||||
|
||||
// restore blend state
|
||||
if( newBlend )
|
||||
|
|
Loading…
Reference in New Issue