Merge pull request #3257 from minggo/iss2430-modify_enum

move enum into class
This commit is contained in:
minggo 2013-07-25 07:28:21 -07:00
commit 7dc710a77f
105 changed files with 1411 additions and 1201 deletions

View File

@ -1 +1 @@
61930829c286fd6ec795bccee6e841a60e8ba34f a30cd2dad1df734bd988309d3b344ff946601cb4

View File

@ -8,6 +8,7 @@ LOCAL_MODULE_FILENAME := libcocos2d
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
CCConfiguration.cpp \ CCConfiguration.cpp \
CCDeprecated.cpp \
CCScheduler.cpp \ CCScheduler.cpp \
CCCamera.cpp \ CCCamera.cpp \
ccFPSImages.c \ ccFPSImages.c \

View File

@ -35,15 +35,6 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
typedef enum _ccConfigurationType {
ConfigurationError,
ConfigurationString,
ConfigurationInt,
ConfigurationDouble,
ConfigurationBoolean
} ccConfigurationType;
/** /**
* @addtogroup global * @addtogroup global
* @{ * @{
@ -55,6 +46,15 @@ typedef enum _ccConfigurationType {
class CC_DLL Configuration : public Object class CC_DLL Configuration : public Object
{ {
public: public:
enum Type
{
ERROR,
STRING,
INT,
DOUBLE,
BOOLEAN,
};
/** returns a shared instance of Configuration */ /** returns a shared instance of Configuration */
static Configuration *getInstance(); static Configuration *getInstance();

159
cocos2dx/CCDeprecated.cpp Normal file
View File

@ -0,0 +1,159 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "cocos2d.h"
NS_CC_BEGIN
const Point CCPointZero = Point::ZERO;
/* The "zero" size -- equivalent to Size(0, 0). */
const Size CCSizeZero = Size::ZERO;
/* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */
const Rect CCRectZero = Rect::ZERO;
const Color3B ccWHITE = Color3B::WHITE;
const Color3B ccYELLOW = Color3B::YELLOW;
const Color3B ccGREEN = Color3B::GREEN;
const Color3B ccBLUE = Color3B::BLUE;
const Color3B ccRED = Color3B::RED;
const Color3B ccMAGENTA = Color3B::MAGENTA;
const Color3B ccBLACK = Color3B::BLACK;
const Color3B ccORANGE = Color3B::ORANGE;
const Color3B ccGRAY = Color3B::GRAY;
const BlendFunc kCCBlendFuncDisable = BlendFunc::BLEND_FUNC_DISABLE;
const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION;
const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR;
const int kCCVertexAttrib_TexCoords = GLProgram::VERTEX_ATTRIB_TEX_COORDS;
const int kCCVertexAttrib_MAX = GLProgram::VERTEX_ATTRIB_MAX;
const int kCCUniformPMatrix = GLProgram::UNIFORM_P_MATRIX;
const int kCCUniformMVMatrix = GLProgram::UNIFORM_MV_MATRIX;
const int kCCUniformMVPMatrix = GLProgram::UNIFORM_MVP_MATRIX;
const int kCCUniformTime = GLProgram::UNIFORM_TIME;
const int kCCUniformSinTime = GLProgram::UNIFORM_SIN_TIME;
const int kCCUniformCosTime = GLProgram::UNIFORM_COS_TIME;
const int kCCUniformRandom01 = GLProgram::UNIFORM_RANDOM01;
const int kCCUniformSampler = GLProgram::UNIFORM_SAMPLER;
const int kCCUniform_MAX = GLProgram::UNIFORM_MAX;
const char* kCCShader_PositionTextureColor = GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR;
const char* kCCShader_PositionTextureColorAlphaTest = GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST;
const char* kCCShader_PositionColor = GLProgram::SHADER_NAME_POSITION_COLOR;
const char* kCCShader_PositionTexture = GLProgram::SHADER_NAME_POSITION_TEXTURE;
const char* kCCShader_PositionTexture_uColor = GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR;
const char* kCCShader_PositionTextureA8Color = GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR;
const char* kCCShader_Position_uColor = GLProgram::SHADER_NAME_POSITION_U_COLOR;
const char* kCCShader_PositionLengthTexureColor = GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR;
// uniform names
const char* kCCUniformPMatrix_s = GLProgram::UNIFORM_NAME_P_MATRIX;
const char* kCCUniformMVMatrix_s = GLProgram::UNIFORM_NAME_MV_MATRIX;
const char* kCCUniformMVPMatrix_s = GLProgram::UNIFORM_NAME_MVP_MATRIX;
const char* kCCUniformTime_s = GLProgram::UNIFORM_NAME_TIME;
const char* kCCUniformSinTime_s = GLProgram::UNIFORM_NAME_SIN_TIME;
const char* kCCUniformCosTime_s = GLProgram::UNIFORM_NAME_COS_TIME;
const char* kCCUniformRandom01_s = GLProgram::UNIFORM_NAME_RANDOM01;
const char* kCCUniformSampler_s = GLProgram::UNIFORM_NAME_SAMPLER;
const char* kCCUniformAlphaTestValue = GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE;
// Attribute names
const char* kCCAttributeNameColor = GLProgram::ATTRIBUTE_NAME_COLOR;
const char* kCCAttributeNamePosition = GLProgram::ATTRIBUTE_NAME_POSITION;
const char* kCCAttributeNameTexCoord = GLProgram::ATTRIBUTE_NAME_TEX_COORD;
const int kCCVertexAttribFlag_None = VERTEX_ATTRIB_FLAT_NONE;
const int kCCVertexAttribFlag_Position = VERTEX_ATTRIB_FLAG_POSITION;
const int kCCVertexAttribFlag_Color = VERTEX_ATTRIB_FLAG_COLOR;
const int kCCVertexAttribFlag_TexCoords = VERTEX_ATTRIB_FLAG_TEX_COORDS;
const int kCCVertexAttribFlag_PosColorTex = VERTEX_ATTRIB_FLAG_POS_COLOR_TEX;
const int kCCProgressTimerTypeRadial = ProgressTimer::RADIAL;
const int kCCProgressTimerTypeBar = ProgressTimer::BAR;
const int kCCDirectorProjection2D = Director::PROJECTION_2D;
const int kCCDirectorProjection3D = Director::PROJECTION_3D;
const int kCCDirectorProjectionCustom = Director::PROJECTION_CUSTOM;
const int kCCDirectorProjectionDefault = Director::PROJECTION_DEFAULT;
const int ConfigurationError = Configuration::ERROR;
const int ConfigurationString = Configuration::STRING;
const int ConfigurationInt = Configuration::INT;
const int ConfigurationDouble = Configuration::DOUBLE;
const int ConfigurationBoolean = Configuration::BOOLEAN;
const int kCCParticleDurationInfinity = ParticleSystem::DURATION_INFINITY;
const int kCCParticleStartSizeEqualToEndSize = ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE;
const int kCCParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS;
const int kCCParticleModeGravity = ParticleSystem::MODE_GRAVITY;
const int kCCParticleModeRadius = ParticleSystem::MODE_RADIUS;
const int kCCPositionTypeFree = ParticleSystem::POSITION_TYPE_FREE;
const int kCCPositionTypeRelative = ParticleSystem::POSITION_TYPE_RELATIVE;
const int kCCPositionTypeGrouped = ParticleSystem::POSITION_TYPE_GROUPED;
const int kCCVerticalTextAlignmentTop = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
const int kCCVerticalTextAlignmentCenter = Label::VERTICAL_TEXT_ALIGNMENT_CENTER;
const int kCCVerticalTextAlignmentBottom = Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM;
const int kCCTextAlignmentLeft = Label::TEXT_ALIGNMENT_LEFT;
const int kCCTextAlignmentCenter = Label::TEXT_ALIGNMENT_CENTER;
const int kCCTextAlignmentRight = Label::TEXT_ALIGNMENT_RIGHT;
const int kCCTexture2DPixelFormat_RGBA8888 = Texture2D::PIXEL_FORMAT_RGBA8888;
const int kCCTexture2DPixelFormat_RGB888 = Texture2D::PIXEL_FORMAT_RGB888;
const int kCCTexture2DPixelFormat_RGB565 = Texture2D::PIXEL_FORMAT_RGB565;
const int kCCTexture2DPixelFormat_A8 = Texture2D::PIXEL_FORMAT_A8;
const int kCCTexture2DPixelFormat_I8 = Texture2D::PIXEL_FORMAT_I8;
const int kCCTexture2DPixelFormat_AI88 = Texture2D::PIXEL_FORMAT_AI88;
const int kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PIXEL_FORMAT_RGBA4444;
const int kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PIXEL_FORMAT_RGB5A1;
const int kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PIXEL_FORMAT_PRVTC4;
const int kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PIXEL_FORMAT_PRVTC2;
const int kCCTexture2DPixelFormat_Default = Texture2D::PIXEL_FORMAT_DEFAULT;
const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY;
const int kCCMenuStateWaiting = Menu::STATE_WAITING;
const int kCCMenuStateTrackingTouch = Menu::STATE_TRACKING_TOUCH;
const int kCCTouchesOneByOne = Layer::TOUCHES_ONE_BY_ONE;
const int kCCTouchesAllAtOnce = Layer::TOUCHES_ALL_AT_ONCE;
const int kCCImageFormatPNG = Image::FORMAT_PNG;
const int kCCImageFormatJPEG = Image::FORMAT_JPG;
const int kCCTransitionOrientationLeftOver = TransitionScene::ORIENTATION_LEFT_OVER;
const int kCCTransitionOrientationRightOver = TransitionScene::ORIENTATION_RIGHT_OVER;
const int kCCTransitionOrientationUpOver = TransitionScene::ORIENTATION_UP_OVER;
const int kCCTransitionOrientationDownOver = TransitionScene::ORIENTATION_DOWN_OVER;
const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM;
const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN;
NS_CC_END

View File

@ -146,7 +146,7 @@ bool Director::init(void)
_scheduler = new Scheduler(); _scheduler = new Scheduler();
// action manager // action manager
_actionManager = new ActionManager(); _actionManager = new ActionManager();
_scheduler->scheduleUpdateForTarget(_actionManager, kPrioritySystem, false); _scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false);
// touchDispatcher // touchDispatcher
_touchDispatcher = new TouchDispatcher(); _touchDispatcher = new TouchDispatcher();
_touchDispatcher->init(); _touchDispatcher->init();
@ -210,22 +210,22 @@ void Director::setDefaultValues(void)
// GL projection // GL projection
const char *projection = conf->getCString("cocos2d.x.gl.projection", "3d"); const char *projection = conf->getCString("cocos2d.x.gl.projection", "3d");
if( strcmp(projection, "3d") == 0 ) if( strcmp(projection, "3d") == 0 )
_projection = kDirectorProjection3D; _projection = PROJECTION_3D;
else if (strcmp(projection, "2d") == 0) else if (strcmp(projection, "2d") == 0)
_projection = kDirectorProjection2D; _projection = PROJECTION_2D;
else if (strcmp(projection, "custom") == 0) else if (strcmp(projection, "custom") == 0)
_projection = kDirectorProjectionCustom; _projection = PROJECTION_CUSTOM;
else else
CCASSERT(false, "Invalid projection value"); CCASSERT(false, "Invalid projection value");
// Default pixel format for PNG images with alpha // Default pixel format for PNG images with alpha
const char *pixel_format = conf->getCString("cocos2d.x.texture.pixel_format_for_png", "rgba8888"); const char *pixel_format = conf->getCString("cocos2d.x.texture.pixel_format_for_png", "rgba8888");
if( strcmp(pixel_format, "rgba8888") == 0 ) if( strcmp(pixel_format, "rgba8888") == 0 )
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
else if( strcmp(pixel_format, "rgba4444") == 0 ) else if( strcmp(pixel_format, "rgba4444") == 0 )
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
else if( strcmp(pixel_format, "rgba5551") == 0 ) else if( strcmp(pixel_format, "rgba5551") == 0 )
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB5A1);
// PVR v2 has alpha premultiplied ? // PVR v2 has alpha premultiplied ?
bool pvr_alpha_premultipled = conf->getBool("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", false); bool pvr_alpha_premultipled = conf->getBool("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", false);
@ -385,7 +385,7 @@ void Director::setNextDeltaTimeZero(bool bNextDeltaTimeZero)
_nextDeltaTimeZero = bNextDeltaTimeZero; _nextDeltaTimeZero = bNextDeltaTimeZero;
} }
void Director::setProjection(ccDirectorProjection kProjection) void Director::setProjection(Projection kProjection)
{ {
Size size = _winSizeInPoints; Size size = _winSizeInPoints;
@ -393,7 +393,7 @@ void Director::setProjection(ccDirectorProjection kProjection)
switch (kProjection) switch (kProjection)
{ {
case kDirectorProjection2D: case PROJECTION_2D:
{ {
kmGLMatrixMode(KM_GL_PROJECTION); kmGLMatrixMode(KM_GL_PROJECTION);
kmGLLoadIdentity(); kmGLLoadIdentity();
@ -405,7 +405,7 @@ void Director::setProjection(ccDirectorProjection kProjection)
} }
break; break;
case kDirectorProjection3D: case PROJECTION_3D:
{ {
float zeye = this->getZEye(); float zeye = this->getZEye();
@ -431,7 +431,7 @@ void Director::setProjection(ccDirectorProjection kProjection)
} }
break; break;
case kDirectorProjectionCustom: case PROJECTION_CUSTOM:
if (_projectionDelegate) if (_projectionDelegate)
{ {
_projectionDelegate->updateProjection(); _projectionDelegate->updateProjection();
@ -864,8 +864,8 @@ void Director::createStatsLabel()
FileUtils::getInstance()->purgeCachedEntries(); FileUtils::getInstance()->purgeCachedEntries();
} }
Texture2DPixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
unsigned char *data = NULL; unsigned char *data = NULL;
unsigned int data_len = 0; unsigned int data_len = 0;
getFPSImageData(&data, &data_len); getFPSImageData(&data, &data_len);

View File

@ -46,23 +46,6 @@ NS_CC_BEGIN
* @{ * @{
*/ */
/** @typedef ccDirectorProjection
Possible OpenGL projections used by director
*/
typedef enum {
/// sets a 2D projection (orthogonal projection)
kDirectorProjection2D,
/// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
kDirectorProjection3D,
/// it calls "updateProjection" on the projection delegate.
kDirectorProjectionCustom,
/// Default projection is 3D projection
kDirectorProjectionDefault = kDirectorProjection3D,
} ccDirectorProjection;
/* Forward declarations. */ /* Forward declarations. */
class LabelAtlas; class LabelAtlas;
class Scene; class Scene;
@ -99,6 +82,24 @@ and when to execute the Scenes.
class CC_DLL Director : public Object, public TypeInfo class CC_DLL Director : public Object, public TypeInfo
{ {
public: public:
/** @typedef ccDirectorProjection
Possible OpenGL projections used by director
*/
enum Projection
{
/// sets a 2D projection (orthogonal projection)
PROJECTION_2D,
/// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
PROJECTION_3D,
/// it calls "updateProjection" on the projection delegate.
PROJECTION_CUSTOM,
/// Default projection is 3D projection
PROJECTION_DEFAULT = PROJECTION_3D,
};
/** returns a shared instance of the director */ /** returns a shared instance of the director */
static Director* getInstance(); static Director* getInstance();
@ -147,8 +148,8 @@ public:
/** Sets an OpenGL projection /** Sets an OpenGL projection
@since v0.8.2 @since v0.8.2
*/ */
inline ccDirectorProjection getProjection(void) { return _projection; } inline Projection getProjection(void) { return _projection; }
void setProjection(ccDirectorProjection kProjection); void setProjection(Projection kProjection);
/** Sets the glViewport*/ /** Sets the glViewport*/
void setViewport(); void setViewport();
@ -477,7 +478,7 @@ protected:
bool _nextDeltaTimeZero; bool _nextDeltaTimeZero;
/* projection used */ /* projection used */
ccDirectorProjection _projection; Projection _projection;
/* window size in points */ /* window size in points */
Size _winSizeInPoints; Size _winSizeInPoints;

View File

@ -240,6 +240,12 @@ SEL_SCHEDULE Timer::getSelector() const
// implementation of Scheduler // implementation of Scheduler
// Priority level reserved for system services.
const int Scheduler::PRIORITY_SYSTEM = INT_MIN;
// Minimum priority level for user scheduling.
const int Scheduler::PRIORITY_NON_SYSTEM_MIN = PRIORITY_SYSTEM + 1;
Scheduler::Scheduler(void) Scheduler::Scheduler(void)
: _timeScale(1.0f) : _timeScale(1.0f)
, _updatesNegList(NULL) , _updatesNegList(NULL)
@ -577,7 +583,7 @@ void Scheduler::unscheduleUpdateForTarget(const Object *target)
void Scheduler::unscheduleAll(void) void Scheduler::unscheduleAll(void)
{ {
unscheduleAllWithMinPriority(kPrioritySystem); unscheduleAllWithMinPriority(PRIORITY_SYSTEM);
} }
void Scheduler::unscheduleAllWithMinPriority(int nMinPriority) void Scheduler::unscheduleAllWithMinPriority(int nMinPriority)
@ -759,7 +765,7 @@ bool Scheduler::isTargetPaused(Object *target)
Set* Scheduler::pauseAllTargets() Set* Scheduler::pauseAllTargets()
{ {
return pauseAllTargetsWithMinPriority(kPrioritySystem); return pauseAllTargetsWithMinPriority(PRIORITY_SYSTEM);
} }
Set* Scheduler::pauseAllTargetsWithMinPriority(int nMinPriority) Set* Scheduler::pauseAllTargetsWithMinPriority(int nMinPriority)

View File

@ -37,12 +37,6 @@ NS_CC_BEGIN
* @{ * @{
*/ */
// Priority level reserved for system services.
#define kPrioritySystem INT_MIN
// Minimum priority level for user scheduling.
#define kPriorityNonSystemMin (kPrioritySystem+1)
class Set; class Set;
// //
// Timer // Timer
@ -121,6 +115,12 @@ The 'custom selectors' should be avoided when possible. It is faster, and consum
class CC_DLL Scheduler : public Object class CC_DLL Scheduler : public Object
{ {
public: public:
// Priority level reserved for system services.
static const int PRIORITY_SYSTEM;
// Minimum priority level for user scheduling.
static const int PRIORITY_NON_SYSTEM_MIN;
Scheduler(); Scheduler();
~Scheduler(void); ~Scheduler(void);

View File

@ -110,7 +110,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, unsigned int tileWidth, unsi
_quadsToDraw = itemsToRender; _quadsToDraw = itemsToRender;
// shader stuff // shader stuff
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTexture_uColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR));
_uniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color"); _uniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color");
return true; return true;

View File

@ -823,7 +823,7 @@ public:
* Since v2.0, each rendering node must set its shader program. * Since v2.0, each rendering node must set its shader program.
* It should be set in initialize phase. * It should be set in initialize phase.
* @code * @code
* node->setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); * node->setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
* @endcode * @endcode
* *
* @param The shader program which fetchs from ShaderCache. * @param The shader program which fetchs from ShaderCache.

View File

@ -157,7 +157,7 @@ bool DrawNode::init()
_blendFunc.src = CC_BLEND_SRC; _blendFunc.src = CC_BLEND_SRC;
_blendFunc.dst = CC_BLEND_DST; _blendFunc.dst = CC_BLEND_DST;
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionLengthTexureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR));
ensureCapacity(512); ensureCapacity(512);
@ -170,14 +170,14 @@ bool DrawNode::init()
glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
glEnableVertexAttribArray(kVertexAttrib_Position); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
glEnableVertexAttribArray(kVertexAttrib_Color); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
glEnableVertexAttribArray(kVertexAttrib_TexCoords); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -211,17 +211,17 @@ void DrawNode::render()
#if CC_TEXTURE_ATLAS_USE_VAO #if CC_TEXTURE_ATLAS_USE_VAO
ccGLBindVAO(_vao); ccGLBindVAO(_vao);
#else #else
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo);
// vertex // vertex
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color // color
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// texcood // texcood
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
#endif #endif
glDrawArrays(GL_TRIANGLES, 0, _bufferCount); glDrawArrays(GL_TRIANGLES, 0, _bufferCount);

View File

@ -93,7 +93,7 @@ static void lazy_init( void )
// //
// Position and 1 color passed as a uniform (to simulate glColor4ub ) // Position and 1 color passed as a uniform (to simulate glColor4ub )
// //
s_pShader = ShaderCache::getInstance()->programForKey(kShader_Position_uColor); s_pShader = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR);
s_pShader->retain(); s_pShader->retain();
s_nColorLocation = glGetUniformLocation( s_pShader->getProgram(), "u_color"); s_nColorLocation = glGetUniformLocation( s_pShader->getProgram(), "u_color");
@ -125,7 +125,7 @@ void ccDrawPoint( const Point& point )
p.x = point.x; p.x = point.x;
p.y = point.y; p.y = point.y;
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
s_pShader->use(); s_pShader->use();
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
@ -134,9 +134,9 @@ void ccDrawPoint( const Point& point )
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(&p, 8); setGLBufferData(&p, 8);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, &p); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, &p);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_POINTS, 0, 1); glDrawArrays(GL_POINTS, 0, 1);
@ -148,7 +148,7 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
{ {
lazy_init(); lazy_init();
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
s_pShader->use(); s_pShader->use();
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
@ -162,9 +162,9 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
{ {
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData((void*) points, numberOfPoints * sizeof(Point)); setGLBufferData((void*) points, numberOfPoints * sizeof(Point));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, points); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
} }
else else
@ -178,9 +178,9 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
// Suspect Emscripten won't be emitting 64-bit code for a while yet, // Suspect Emscripten won't be emitting 64-bit code for a while yet,
// but want to make sure this continues to work even if they do. // but want to make sure this continues to work even if they do.
setGLBufferData(newPoints, numberOfPoints * sizeof(Vertex2F)); setGLBufferData(newPoints, numberOfPoints * sizeof(Vertex2F));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
} }
@ -205,12 +205,12 @@ void ccDrawLine( const Point& origin, const Point& destination )
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, 16); setGLBufferData(vertices, 16);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_LINES, 0, 2); glDrawArrays(GL_LINES, 0, 2);
@ -245,16 +245,16 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
// iPhone and 32-bit machines optimization // iPhone and 32-bit machines optimization
if( sizeof(Point) == sizeof(Vertex2F) ) if( sizeof(Point) == sizeof(Vertex2F) )
{ {
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point)); setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
if( closePolygon ) if( closePolygon )
@ -273,9 +273,9 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg
} }
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F)); setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
if( closePolygon ) if( closePolygon )
@ -297,7 +297,7 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &color.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &color.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
Vertex2F* newPoli = new Vertex2F[numberOfPoints]; Vertex2F* newPoli = new Vertex2F[numberOfPoints];
@ -307,9 +307,9 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co
{ {
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point)); setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
} }
else else
@ -321,9 +321,9 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co
} }
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F)); setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
} }
@ -362,13 +362,13 @@ void ccDrawCircle( const Point& center, float radius, float angle, unsigned int
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2)); setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments+additionalSegment); glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments+additionalSegment);
@ -407,13 +407,13 @@ void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2)); setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) segments+1); glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) segments+1);
@ -448,13 +448,13 @@ void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& de
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);
CC_SAFE_DELETE_ARRAY(vertices); CC_SAFE_DELETE_ARRAY(vertices);
@ -505,13 +505,13 @@ void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segm
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*)&s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*)&s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);
@ -539,13 +539,13 @@ void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point&
s_pShader->setUniformsForBuiltins(); s_pShader->setUniformsForBuiltins();
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);
CC_SAFE_DELETE_ARRAY(vertices); CC_SAFE_DELETE_ARRAY(vertices);

View File

@ -102,7 +102,7 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFli
bRet = false; bRet = false;
} }
_shaderProgram = ShaderCache::getInstance()->programForKey(kShader_PositionTexture); _shaderProgram = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE);
calculateVertexPoints(); calculateVertexPoints();
return bRet; return bRet;
@ -117,7 +117,7 @@ bool GridBase::initWithSize(const Size& gridSize)
unsigned long POTHigh = ccNextPOT((unsigned int)s.height); unsigned long POTHigh = ccNextPOT((unsigned int)s.height);
// we only use rgba8888 // we only use rgba8888
Texture2DPixelFormat format = kTexture2DPixelFormat_RGBA8888; Texture2D::PixelFormat format = Texture2D::PIXEL_FORMAT_RGBA8888;
void *data = calloc((int)(POTWide * POTHigh * 4), 1); void *data = calloc((int)(POTWide * POTHigh * 4), 1);
if (! data) if (! data)
@ -161,7 +161,7 @@ void GridBase::setActive(bool bActive)
if (! bActive) if (! bActive)
{ {
Director *pDirector = Director::getInstance(); Director *pDirector = Director::getInstance();
ccDirectorProjection proj = pDirector->getProjection(); Director::Projection proj = pDirector->getProjection();
pDirector->setProjection(proj); pDirector->setProjection(proj);
} }
} }
@ -203,7 +203,7 @@ void GridBase::beforeDraw(void)
_directorProjection = director->getProjection(); _directorProjection = director->getProjection();
// 2d projection // 2d projection
// [director setProjection:kDirectorProjection2D]; // [director setProjection:Director::PROJECTION_2D];
set2DProjection(); set2DProjection();
_grabber->beforeRender(_texture); _grabber->beforeRender(_texture);
} }
@ -315,7 +315,7 @@ void Grid3D::blit(void)
{ {
int n = _gridSize.width * _gridSize.height; int n = _gridSize.width * _gridSize.height;
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_TEX_COORDS );
_shaderProgram->use(); _shaderProgram->use();
_shaderProgram->setUniformsForBuiltins();; _shaderProgram->setUniformsForBuiltins();;
@ -328,20 +328,20 @@ void Grid3D::blit(void)
// position // position
setGLBufferData(_vertices, numOfPoints * sizeof(Vertex3F), 0); setGLBufferData(_vertices, numOfPoints * sizeof(Vertex3F), 0);
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
// texCoords // texCoords
setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vertex2F), 1); setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vertex2F), 1);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLIndexData(_indices, n * 12, 0); setGLIndexData(_indices, n * 12, 0);
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0);
#else #else
// position // position
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, _vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices);
// texCoords // texCoords
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates);
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, _indices); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, _indices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
@ -537,26 +537,26 @@ void TiledGrid3D::blit(void)
// //
// Attributes // Attributes
// //
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_TEX_COORDS );
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
int numQuads = _gridSize.width * _gridSize.height; int numQuads = _gridSize.width * _gridSize.height;
// position // position
setGLBufferData(_vertices, (numQuads*4*sizeof(Vertex3F)), 0); setGLBufferData(_vertices, (numQuads*4*sizeof(Vertex3F)), 0);
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
// texCoords // texCoords
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vertex2F)), 1); setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vertex2F)), 1);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLIndexData(_indices, n * 12, 0); setGLIndexData(_indices, n * 12, 0);
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0);
#else #else
// position // position
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, _vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices);
// texCoords // texCoords
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates);
glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, _indices); glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, _indices);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN

View File

@ -99,7 +99,7 @@ protected:
Grabber *_grabber; Grabber *_grabber;
bool _isTextureFlipped; bool _isTextureFlipped;
GLProgram* _shaderProgram; GLProgram* _shaderProgram;
ccDirectorProjection _directorProjection; Director::Projection _directorProjection;
}; };
/** /**

View File

@ -390,26 +390,26 @@ CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, fl
} }
CC_DEPRECATED_ATTRIBUTE const Point CCPointZero = Point::ZERO; CC_DEPRECATED_ATTRIBUTE extern const Point CCPointZero;
/* The "zero" size -- equivalent to Size(0, 0). */ /* The "zero" size -- equivalent to Size(0, 0). */
CC_DEPRECATED_ATTRIBUTE const Size CCSizeZero = Size::ZERO; CC_DEPRECATED_ATTRIBUTE extern const Size CCSizeZero;
/* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */ /* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */
CC_DEPRECATED_ATTRIBUTE const Rect CCRectZero = Rect::ZERO; CC_DEPRECATED_ATTRIBUTE extern const Rect CCRectZero;
CC_DEPRECATED_ATTRIBUTE const Color3B ccWHITE = Color3B::WHITE; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccWHITE;
CC_DEPRECATED_ATTRIBUTE const Color3B ccYELLOW = Color3B::YELLOW; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccYELLOW;
CC_DEPRECATED_ATTRIBUTE const Color3B ccGREEN = Color3B::GREEN; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGREEN;
CC_DEPRECATED_ATTRIBUTE const Color3B ccBLUE = Color3B::BLUE; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLUE;
CC_DEPRECATED_ATTRIBUTE const Color3B ccRED = Color3B::RED; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccRED;
CC_DEPRECATED_ATTRIBUTE const Color3B ccMAGENTA = Color3B::MAGENTA; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccMAGENTA;
CC_DEPRECATED_ATTRIBUTE const Color3B ccBLACK = Color3B::BLACK; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLACK;
CC_DEPRECATED_ATTRIBUTE const Color3B ccORANGE = Color3B::ORANGE; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccORANGE;
CC_DEPRECATED_ATTRIBUTE const Color3B ccGRAY = Color3B::GRAY; CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGRAY;
CC_DEPRECATED_ATTRIBUTE const BlendFunc kBlendFuncDisable = BlendFunc::BLEND_FUNC_DISABLE; CC_DEPRECATED_ATTRIBUTE extern const BlendFunc kCCBlendFuncDisable;
CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(GLubyte r, GLubyte g, GLubyte b) CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(GLubyte r, GLubyte g, GLubyte b)
{ {
@ -471,9 +471,20 @@ CC_DEPRECATED_ATTRIBUTE static inline Tex2F tex2(const float u, const float v)
return t; return t;
} }
#define CCAffineTransformMake AffineTransformMake CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty)
#define CCPointApplyAffineTransform PointApplyAffineTransform {
#define CCSizeApplyAffineTransform SizeApplyAffineTransform return AffineTransformMake(a, b, c, d, tx, ty);
}
CC_DEPRECATED_ATTRIBUTE static inline Point CCPointApplyAffineTransform(const Point& point, const AffineTransform& t)
{
return PointApplyAffineTransform(point, t);
}
CC_DEPRECATED_ATTRIBUTE static inline Size CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t)
{
return SizeApplyAffineTransform(size, t);
}
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMakeIdentity() CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMakeIdentity()
{ {
@ -515,8 +526,10 @@ CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformInvert(co
return AffineTransformInvert(t); return AffineTransformInvert(t);
} }
#define CCAffineTransformIdentity AffineTransformIdentity CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformIdentity()
{
return AffineTransformMakeIdentity();
}
// CC prefix compatibility // CC prefix compatibility
CC_DEPRECATED_ATTRIBUTE typedef Object CCObject; CC_DEPRECATED_ATTRIBUTE typedef Object CCObject;
@ -791,119 +804,131 @@ CC_DEPRECATED_ATTRIBUTE typedef FontShadow ccFontShadow;
CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke; CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke;
CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition; CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition;
CC_DEPRECATED_ATTRIBUTE typedef VerticalTextAlignment CCVerticalTextAlignment; CC_DEPRECATED_ATTRIBUTE typedef Label::VerticalTextAlignment CCVerticalTextAlignment;
CC_DEPRECATED_ATTRIBUTE typedef TextAlignment CCTextAlignment; CC_DEPRECATED_ATTRIBUTE typedef Label::TextAlignment CCTextAlignment;
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimerType CCProgressTimerType; CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType;
CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
#define kCCVertexAttrib_Position kVertexAttrib_Position CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Position;
#define kCCVertexAttrib_Color kVertexAttrib_Color CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Color;
#define kCCVertexAttrib_TexCoords kVertexAttrib_TexCoords CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_TexCoords;
#define kCCVertexAttrib_MAX kVertexAttrib_MAX CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_MAX;
#define kCCUniformPMatrix kUniformPMatrix CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformPMatrix;
#define kCCUniformMVMatrix kUniformMVMatrix CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVMatrix;
#define kCCUniformMVPMatrix kUniformMVPMatrix CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVPMatrix;
#define kCCUniformTime kUniformTime CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformTime;
#define kCCUniformSinTime kUniformSinTime CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSinTime;
#define kCCUniformCosTime kUniformCosTime CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformCosTime;
#define kCCUniformRandom01 kUniformRandom01 CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformRandom01;
#define kCCUniformSampler kUniformSampler CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSampler;
#define kCCUniform_MAX kUniform_MAX CC_DEPRECATED_ATTRIBUTE extern const int kCCUniform_MAX;
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColor;
#define kCCShader_PositionTextureColor kShader_PositionTextureColor CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColorAlphaTest;
#define kCCShader_PositionTextureColorAlphaTest kShader_PositionTextureColorAlphaTest CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionColor;
#define kCCShader_PositionColor kShader_PositionColor CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture;
#define kCCShader_PositionTexture kShader_PositionTexture CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture_uColor;
#define kCCShader_PositionTexture_uColor kShader_PositionTexture_uColor CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureA8Color;
#define kCCShader_PositionTextureA8Color kShader_PositionTextureA8Color CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_Position_uColor;
#define kCCShader_Position_uColor kShader_Position_uColor CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionLengthTexureColor;
#define kCCShader_PositionLengthTexureColor kShader_PositionLengthTexureColor
// uniform names // uniform names
#define kCCUniformPMatrix_s kUniformPMatrix_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformPMatrix_s;
#define kCCUniformMVMatrix_s kUniformMVMatrix_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVMatrix_s;
#define kCCUniformMVPMatrix_s kUniformMVPMatrix_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVPMatrix_s;
#define kCCUniformTime_s kUniformTime_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformTime_s;
#define kCCUniformSinTime_s kUniformSinTime_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSinTime_s;
#define kCCUniformCosTime_s kUniformCosTime_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformCosTime_s;
#define kCCUniformRandom01_s kUniformRandom01_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformRandom01_s;
#define kCCUniformSampler_s kUniformSampler_s CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSampler_s;
#define kCCUniformAlphaTestValue kUniformAlphaTestValue CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformAlphaTestValue;
// Attribute names // Attribute names
#define kCCAttributeNameColor kAttributeNameColor CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameColor;
#define kCCAttributeNamePosition kAttributeNamePosition CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNamePosition;
#define kCCAttributeNameTexCoord kAttributeNameTexCoord CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameTexCoord;
#define kCCVertexAttribFlag_None kVertexAttribFlag_None CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_None;
#define kCCVertexAttribFlag_Position kVertexAttribFlag_Position CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Position;
#define kCCVertexAttribFlag_Color kVertexAttribFlag_Color CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Color;
#define kCCVertexAttribFlag_TexCoords kVertexAttribFlag_TexCoords CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_TexCoords;
#define kCCVertexAttribFlag_PosColorTex kVertexAttribFlag_PosColorTex CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_PosColorTex;
#define kCCProgressTimerTypeRadial kProgressTimerTypeRadial CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeRadial;
#define kCCProgressTimerTypeBar kProgressTimerTypeBar CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeBar;
CC_DEPRECATED_ATTRIBUTE typedef enum ProgressTimer::Type ProgressTimerType;
#define kCCDirectorProjection2D kDirectorProjection2D CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjection2D;
#define kCCDirectorProjection3D kDirectorProjection3D CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjection3D;
#define kCCDirectorProjectionCustom kDirectorProjectionCustom CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjectionCustom;
#define kCCDirectorProjectionDefault kDirectorProjectionDefault CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjectionDefault;
CC_DEPRECATED_ATTRIBUTE typedef enum Director::Projection ccDirectorProjection;
#define kCCVerticalTextAlignmentTop kVerticalTextAlignmentTop CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationError;
#define kCCVerticalTextAlignmentCenter kVerticalTextAlignmentCenter CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationString;
#define kCCVerticalTextAlignmentBottom kVerticalTextAlignmentBottom CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationInt;
CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationDouble;
CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationBoolean;
CC_DEPRECATED_ATTRIBUTE typedef enum Configuration::Type ccConfigurationType;
#define kCCTextAlignmentLeft kTextAlignmentLeft CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentTop;
#define kCCTextAlignmentCenter kTextAlignmentCenter CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentCenter;
#define kCCTextAlignmentRight kTextAlignmentRight CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentBottom;
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentLeft;
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentCenter;
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentRight;
#define kCCTexture2DPixelFormat_RGBA8888 kTexture2DPixelFormat_RGBA8888 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGBA8888;
#define kCCTexture2DPixelFormat_RGB888 kTexture2DPixelFormat_RGB888 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGB888;
#define kCCTexture2DPixelFormat_RGB565 kTexture2DPixelFormat_RGB565 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGB565;
#define kCCTexture2DPixelFormat_A8 kTexture2DPixelFormat_A8 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_A8;
#define kCCTexture2DPixelFormat_I8 kTexture2DPixelFormat_I8 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_I8;
#define kCCTexture2DPixelFormat_AI88 kTexture2DPixelFormat_AI88 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_AI88;
#define kCCTexture2DPixelFormat_RGBA4444 kTexture2DPixelFormat_RGBA4444 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGBA4444;
#define kCCTexture2DPixelFormat_RGB5A1 kTexture2DPixelFormat_RGB5A1 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGB5A1;
#define kCCTexture2DPixelFormat_PVRTC4 kTexture2DPixelFormat_PVRTC4 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_PVRTC4;
#define kCCTexture2DPixelFormat_PVRTC2 kTexture2DPixelFormat_PVRTC2 CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_PVRTC2;
#define kCCTexture2DPixelFormat_Default kTexture2DPixelFormat_Default CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_Default;
CC_DEPRECATED_ATTRIBUTE typedef enum Texture2D::PixelFormat CCTexture2DPixelFormat;
#define kCCLabelAutomaticWidth kLabelAutomaticWidth #define kCCLabelAutomaticWidth kLabelAutomaticWidth
#define kCCParticleDurationInfinity kParticleDurationInfinity CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleDurationInfinity;
#define kCCParticleStartSizeEqualToEndSize kParticleStartSizeEqualToEndSize CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartSizeEqualToEndSize;
#define kCCParticleStartRadiusEqualToEndRadius kParticleStartRadiusEqualToEndRadius CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartRadiusEqualToEndRadius;
#define kCCParticleModeGravity kParticleModeGravity CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleModeGravity;
#define kCCParticleModeRadius kParticleModeRadius CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleModeRadius;
#define kCCPositionTypeFree kPositionTypeFree
#define kCCPositionTypeRelative kPositionTypeRelative
#define kCCPositionTypeGrouped kPositionTypeGrouped
#define kCCBlendFuncDisable kBlendFuncDisable CC_DEPRECATED_ATTRIBUTE extern const int kCCPositionTypeFree;
CC_DEPRECATED_ATTRIBUTE extern const int kCCPositionTypeRelative;
CC_DEPRECATED_ATTRIBUTE extern const int kCCPositionTypeGrouped;
CC_DEPRECATED_ATTRIBUTE typedef enum ParticleSystem::PositionType tPositionType;
#define kCCMenuHandlerPriority kMenuHandlerPriority CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuHandlerPriority;
#define kCCMenuStateWaiting kMenuStateWaiting CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuStateWaiting;
#define kCCMenuStateTrackingTouch kMenuStateTrackingTouch CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuStateTrackingTouch;
CC_DEPRECATED_ATTRIBUTE typedef enum Menu::State tMenuState;
#define kCCTouchesOneByOne kTouchesOneByOne CC_DEPRECATED_ATTRIBUTE extern const int kCCTouchesOneByOne;
#define kCCTouchesAllAtOnce kTouchesAllAtOnce CC_DEPRECATED_ATTRIBUTE extern const int kCCTouchesAllAtOnce;
CC_DEPRECATED_ATTRIBUTE typedef enum Layer::TouchesMode ccTouchesMode;
#define kCCImageFormatPNG kImageFormatPNG CC_DEPRECATED_ATTRIBUTE extern const int kCCImageFormatPNG;
#define kCCImageFormatJPEG kImageFormatJPEG CC_DEPRECATED_ATTRIBUTE extern const int kCCImageFormatJPEG;
CC_DEPRECATED_ATTRIBUTE typedef enum Image::Format tImageFormat;
#define kCCTransitionOrientationLeftOver kTransitionOrientationLeftOver CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationLeftOver;
#define kCCTransitionOrientationRightOver kTransitionOrientationRightOver CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationRightOver;
#define kCCTransitionOrientationUpOver kTransitionOrientationUpOver CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationUpOver;
#define kCCTransitionOrientationDownOver kTransitionOrientationDownOver CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationDownOver;
CC_DEPRECATED_ATTRIBUTE typedef enum TransitionScene::Orientation tOrientation;
#define kCCPrioritySystem kPrioritySystem CC_DEPRECATED_ATTRIBUTE extern const int kCCPrioritySystem;
#define kCCPriorityNonSystemMin kPriorityNonSystemMin CC_DEPRECATED_ATTRIBUTE extern const int kCCPriorityNonSystemMin;
#define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag #define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag
#define kCCTMXTileVerticalFlag kTMXTileVerticalFlag #define kCCTMXTileVerticalFlag kTMXTileVerticalFlag

View File

@ -304,23 +304,27 @@ struct BlendFunc
const static BlendFunc BLEND_FUNC_DISABLE; const static BlendFunc BLEND_FUNC_DISABLE;
}; };
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m class Label : public Object
//! Vertical text alignment type
typedef enum
{ {
kVerticalTextAlignmentTop, public:
kVerticalTextAlignmentCenter, // XXX: If any of these enums are edited and/or reordered, update Texture2D.m
kVerticalTextAlignmentBottom, //! Vertical text alignment type
} VerticalTextAlignment; enum VerticalTextAlignment
{
VERTICAL_TEXT_ALIGNMENT_TOP,
VERTICAL_TEXT_ALIGNMENT_CENTER,
VERTICAL_TEXT_ALIGNMENT_BOTTOM,
};
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m // XXX: If any of these enums are edited and/or reordered, update Texture2D.m
//! Horizontal text alignment type //! Horizontal text alignment type
typedef enum enum TextAlignment
{ {
kTextAlignmentLeft, TEXT_ALIGNMENT_LEFT,
kTextAlignmentCenter, TEXT_ALIGNMENT_CENTER,
kTextAlignmentRight, TEXT_ALIGNMENT_RIGHT,
} TextAlignment; };
};
// types for animation in particle systems // types for animation in particle systems
@ -345,8 +349,6 @@ struct AnimationFrameData
Size size; Size size;
}; };
/** /**
types used for defining fonts properties (i.e. font name, size, stroke or shadow) types used for defining fonts properties (i.e. font name, size, stroke or shadow)
*/ */
@ -398,8 +400,8 @@ struct FontDefinition
public: public:
FontDefinition():_fontSize(0), FontDefinition():_fontSize(0),
_alignment(kTextAlignmentCenter), _alignment(Label::TEXT_ALIGNMENT_CENTER),
_vertAlignment(kVerticalTextAlignmentTop), _vertAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP),
_fontFillColor(Color3B::WHITE) _fontFillColor(Color3B::WHITE)
{ _dimensions = Size(0,0); } { _dimensions = Size(0,0); }
@ -408,9 +410,9 @@ public:
// font size // font size
int _fontSize; int _fontSize;
// horizontal alignment // horizontal alignment
TextAlignment _alignment; Label::Label::Label::TextAlignment _alignment;
// vertical alignment // vertical alignment
VerticalTextAlignment _vertAlignment; Label::Label::Label::VerticalTextAlignment _vertAlignment;
// renering box // renering box
Size _dimensions; Size _dimensions;
// font color // font color

View File

@ -430,23 +430,23 @@ LabelBMFont * LabelBMFont::create()
return NULL; return NULL;
} }
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, TextAlignment alignment) LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, Label::TextAlignment alignment)
{ {
return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO); return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO);
} }
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width) LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width)
{ {
return LabelBMFont::create(str, fntFile, width, kTextAlignmentLeft, Point::ZERO); return LabelBMFont::create(str, fntFile, width, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
} }
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile) LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile)
{ {
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
} }
//LabelBMFont - Creation & Init //LabelBMFont - Creation & Init
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/) LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::TextAlignment alignment/* = Label::TEXT_ALIGNMENT_LEFT*/, Point imageOffset/* = Point::ZERO*/)
{ {
LabelBMFont *pRet = new LabelBMFont(); LabelBMFont *pRet = new LabelBMFont();
if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset)) if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset))
@ -460,10 +460,10 @@ LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float wid
bool LabelBMFont::init() bool LabelBMFont::init()
{ {
return initWithString(NULL, NULL, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); return initWithString(NULL, NULL, kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
} }
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/) bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::TextAlignment alignment/* = Label::TEXT_ALIGNMENT_LEFT*/, Point imageOffset/* = Point::ZERO*/)
{ {
CCASSERT(!_configuration, "re-init is no longer supported"); CCASSERT(!_configuration, "re-init is no longer supported");
CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont"); CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont");
@ -530,7 +530,7 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo
LabelBMFont::LabelBMFont() LabelBMFont::LabelBMFont()
: _string(NULL) : _string(NULL)
, _initialString(NULL) , _initialString(NULL)
, _alignment(kTextAlignmentCenter) , _alignment(Label::TEXT_ALIGNMENT_CENTER)
, _width(-1.0f) , _width(-1.0f)
, _configuration(NULL) , _configuration(NULL)
, _lineBreakWithoutSpaces(false) , _lineBreakWithoutSpaces(false)
@ -1094,7 +1094,7 @@ void LabelBMFont::updateLabel()
} }
// Step 2: Make alignment // Step 2: Make alignment
if (_alignment != kTextAlignmentLeft) if (_alignment != Label::TEXT_ALIGNMENT_LEFT)
{ {
int i = 0; int i = 0;
@ -1125,10 +1125,10 @@ void LabelBMFont::updateLabel()
float shift = 0; float shift = 0;
switch (_alignment) switch (_alignment)
{ {
case kTextAlignmentCenter: case Label::TEXT_ALIGNMENT_CENTER:
shift = getContentSize().width/2.0f - lineWidth/2.0f; shift = getContentSize().width/2.0f - lineWidth/2.0f;
break; break;
case kTextAlignmentRight: case Label::TEXT_ALIGNMENT_RIGHT:
shift = getContentSize().width - lineWidth; shift = getContentSize().width - lineWidth;
break; break;
default: default:
@ -1160,7 +1160,7 @@ void LabelBMFont::updateLabel()
} }
// LabelBMFont - Alignment // LabelBMFont - Alignment
void LabelBMFont::setAlignment(TextAlignment alignment) void LabelBMFont::setAlignment(Label::TextAlignment alignment)
{ {
this->_alignment = alignment; this->_alignment = alignment;
updateLabel(); updateLabel();

View File

@ -192,9 +192,9 @@ public:
static void purgeCachedData(); static void purgeCachedData();
/** creates a bitmap font atlas with an initial string and the FNT file */ /** creates a bitmap font atlas with an initial string and the FNT file */
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextAlignment alignment, Point imageOffset); static LabelBMFont * create(const char *str, const char *fntFile, float width, Label::TextAlignment alignment, Point imageOffset);
static LabelBMFont * create(const char *str, const char *fntFile, float width, TextAlignment alignment); static LabelBMFont * create(const char *str, const char *fntFile, float width, Label::TextAlignment alignment);
static LabelBMFont * create(const char *str, const char *fntFile, float width); static LabelBMFont * create(const char *str, const char *fntFile, float width);
@ -206,7 +206,7 @@ public:
bool init(); bool init();
/** init a bitmap font atlas with an initial string and the FNT file */ /** init a bitmap font atlas with an initial string and the FNT file */
bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, TextAlignment alignment = kTextAlignmentLeft, Point imageOffset = Point::ZERO); bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, Label::TextAlignment alignment = Label::TEXT_ALIGNMENT_LEFT, Point imageOffset = Point::ZERO);
/** updates the font chars based on the string to render */ /** updates the font chars based on the string to render */
void createFontChars(); void createFontChars();
@ -218,7 +218,7 @@ public:
virtual void setCString(const char *label); virtual void setCString(const char *label);
virtual void setAnchorPoint(const Point& var); virtual void setAnchorPoint(const Point& var);
virtual void updateLabel(); virtual void updateLabel();
virtual void setAlignment(TextAlignment alignment); virtual void setAlignment(Label::TextAlignment alignment);
virtual void setWidth(float width); virtual void setWidth(float width);
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace); virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
virtual void setScale(float scale); virtual void setScale(float scale);
@ -265,7 +265,7 @@ protected:
std::string _initialStringUTF8; std::string _initialStringUTF8;
// alignment of all lines // alignment of all lines
TextAlignment _alignment; Label::TextAlignment _alignment;
// max width until a line break is added // max width until a line break is added
float _width; float _width;

View File

@ -31,17 +31,17 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
#if CC_USE_LA88_LABELS #if CC_USE_LA88_LABELS
#define SHADER_PROGRAM kShader_PositionTextureColor #define SHADER_PROGRAM GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR
#else #else
#define SHADER_PROGRAM kShader_PositionTextureA8Color #define SHADER_PROGRAM GLProgram::SHADER_NAME_POSITION_TEXTUREA8Color
#endif #endif
// //
//CCLabelTTF //CCLabelTTF
// //
LabelTTF::LabelTTF() LabelTTF::LabelTTF()
: _alignment(kTextAlignmentCenter) : _alignment(Label::TEXT_ALIGNMENT_CENTER)
, _vAlignment(kVerticalTextAlignmentTop) , _vAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP)
, _fontName(NULL) , _fontName(NULL)
, _fontSize(0.0) , _fontSize(0.0)
, _string("") , _string("")
@ -73,18 +73,18 @@ LabelTTF * LabelTTF::create()
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize) LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize)
{ {
return LabelTTF::create(string, fontName, fontSize, return LabelTTF::create(string, fontName, fontSize,
Size::ZERO, kTextAlignmentCenter, kVerticalTextAlignmentTop); Size::ZERO, Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize, LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment) const Size& dimensions, Label::TextAlignment hAlignment)
{ {
return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, kVerticalTextAlignmentTop); return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
LabelTTF* LabelTTF::create(const char *string, const char *fontName, float fontSize, LabelTTF* LabelTTF::create(const char *string, const char *fontName, float fontSize,
const Size &dimensions, TextAlignment hAlignment, const Size &dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment) Label::VerticalTextAlignment vAlignment)
{ {
LabelTTF *pRet = new LabelTTF(); LabelTTF *pRet = new LabelTTF();
if(pRet && pRet->initWithString(string, fontName, fontSize, dimensions, hAlignment, vAlignment)) if(pRet && pRet->initWithString(string, fontName, fontSize, dimensions, hAlignment, vAlignment))
@ -114,20 +114,20 @@ bool LabelTTF::init()
} }
bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize, bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment alignment) const Size& dimensions, Label::TextAlignment alignment)
{ {
return this->initWithString(label, fontName, fontSize, dimensions, alignment, kVerticalTextAlignmentTop); return this->initWithString(label, fontName, fontSize, dimensions, alignment, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize) bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
{ {
return this->initWithString(label, fontName, fontSize, return this->initWithString(label, fontName, fontSize,
Size::ZERO, kTextAlignmentLeft, kVerticalTextAlignmentTop); Size::ZERO, Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
} }
bool LabelTTF::initWithString(const char *string, const char *fontName, float fontSize, bool LabelTTF::initWithString(const char *string, const char *fontName, float fontSize,
const cocos2d::Size &dimensions, TextAlignment hAlignment, const cocos2d::Size &dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment) Label::VerticalTextAlignment vAlignment)
{ {
if (Sprite::init()) if (Sprite::init())
{ {
@ -193,12 +193,12 @@ const char* LabelTTF::description() const
return String::createWithFormat("<LabelTTF | FontName = %s, FontSize = %.1f>", _fontName->c_str(), _fontSize)->getCString(); return String::createWithFormat("<LabelTTF | FontName = %s, FontSize = %.1f>", _fontName->c_str(), _fontSize)->getCString();
} }
TextAlignment LabelTTF::getHorizontalAlignment() const Label::TextAlignment LabelTTF::getHorizontalAlignment() const
{ {
return _alignment; return _alignment;
} }
void LabelTTF::setHorizontalAlignment(TextAlignment alignment) void LabelTTF::setHorizontalAlignment(Label::TextAlignment alignment)
{ {
if (alignment != _alignment) if (alignment != _alignment)
{ {
@ -212,12 +212,12 @@ void LabelTTF::setHorizontalAlignment(TextAlignment alignment)
} }
} }
VerticalTextAlignment LabelTTF::getVerticalAlignment() const Label::VerticalTextAlignment LabelTTF::getVerticalAlignment() const
{ {
return _vAlignment; return _vAlignment;
} }
void LabelTTF::setVerticalAlignment(VerticalTextAlignment verticalAlignment) void LabelTTF::setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment)
{ {
if (verticalAlignment != _vAlignment) if (verticalAlignment != _vAlignment)
{ {

View File

@ -48,9 +48,9 @@ NS_CC_BEGIN
* Custom ttf file can be put in assets/ or external storage that the Application can access. * Custom ttf file can be put in assets/ or external storage that the Application can access.
* @code * @code
* LabelTTF *label1 = LabelTTF::create("alignment left", "A Damn Mess", fontSize, blockSize, * LabelTTF *label1 = LabelTTF::create("alignment left", "A Damn Mess", fontSize, blockSize,
* kTextAlignmentLeft, kVerticalTextAlignmentCenter); * Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_CENTER);
* LabelTTF *label2 = LabelTTF::create("alignment right", "/mnt/sdcard/Scissor Cuts.ttf", fontSize, blockSize, * LabelTTF *label2 = LabelTTF::create("alignment right", "/mnt/sdcard/Scissor Cuts.ttf", fontSize, blockSize,
* kTextAlignmentLeft, kVerticalTextAlignmentCenter); * Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_CENTER);
* @endcode * @endcode
* *
*/ */
@ -70,14 +70,14 @@ public:
@since v2.0.1 @since v2.0.1
*/ */
static LabelTTF * create(const char *string, const char *fontName, float fontSize, static LabelTTF * create(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment); const Size& dimensions, Label::TextAlignment hAlignment);
/** creates a Label from a fontname, alignment, dimension in points and font size in points /** creates a Label from a fontname, alignment, dimension in points and font size in points
@since v2.0.1 @since v2.0.1
*/ */
static LabelTTF * create(const char *string, const char *fontName, float fontSize, static LabelTTF * create(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment, const Size& dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment); Label::VerticalTextAlignment vAlignment);
/** Create a lable with string and a font definition*/ /** Create a lable with string and a font definition*/
@ -88,12 +88,12 @@ public:
/** initializes the LabelTTF with a font name, alignment, dimension and font size */ /** initializes the LabelTTF with a font name, alignment, dimension and font size */
bool initWithString(const char *string, const char *fontName, float fontSize, bool initWithString(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment); const Size& dimensions, Label::TextAlignment hAlignment);
/** initializes the LabelTTF with a font name, alignment, dimension and font size */ /** initializes the LabelTTF with a font name, alignment, dimension and font size */
bool initWithString(const char *string, const char *fontName, float fontSize, bool initWithString(const char *string, const char *fontName, float fontSize,
const Size& dimensions, TextAlignment hAlignment, const Size& dimensions, Label::TextAlignment hAlignment,
VerticalTextAlignment vAlignment); Label::VerticalTextAlignment vAlignment);
/** initializes the LabelTTF with a font name, alignment, dimension and font size */ /** initializes the LabelTTF with a font name, alignment, dimension and font size */
bool initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition); bool initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition);
@ -136,11 +136,11 @@ public:
virtual void setString(const char *label); virtual void setString(const char *label);
virtual const char* getString(void) const; virtual const char* getString(void) const;
TextAlignment getHorizontalAlignment() const; Label::TextAlignment getHorizontalAlignment() const;
void setHorizontalAlignment(TextAlignment alignment); void setHorizontalAlignment(Label::TextAlignment alignment);
VerticalTextAlignment getVerticalAlignment() const; Label::VerticalTextAlignment getVerticalAlignment() const;
void setVerticalAlignment(VerticalTextAlignment verticalAlignment); void setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment);
const Size& getDimensions() const; const Size& getDimensions() const;
void setDimensions(const Size &dim); void setDimensions(const Size &dim);
@ -162,9 +162,9 @@ protected:
/** Dimensions of the label in Points */ /** Dimensions of the label in Points */
Size _dimensions; Size _dimensions;
/** The alignment of the label */ /** The alignment of the label */
TextAlignment _alignment; Label::TextAlignment _alignment;
/** The vertical alignment of the label */ /** The vertical alignment of the label */
VerticalTextAlignment _vAlignment; Label::VerticalTextAlignment _vAlignment;
/** Font name used in the label */ /** Font name used in the label */
std::string * _fontName; std::string * _fontName;
/** Font size of the label */ /** Font size of the label */

View File

@ -48,7 +48,7 @@ Layer::Layer()
, _keyboardEnabled(false) , _keyboardEnabled(false)
, _keypadEnabled(false) , _keypadEnabled(false)
, _touchPriority(0) , _touchPriority(0)
, _touchMode(kTouchesAllAtOnce) , _touchMode(Layer::TOUCHES_ALL_AT_ONCE)
{ {
_ignoreAnchorPointForPosition = true; _ignoreAnchorPointForPosition = true;
setAnchorPoint(Point(0.5f, 0.5f)); setAnchorPoint(Point(0.5f, 0.5f));
@ -96,7 +96,7 @@ void Layer::registerWithTouchDispatcher()
{ {
TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher(); TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher();
if( _touchMode == kTouchesAllAtOnce ) { if( _touchMode == Layer::TOUCHES_ALL_AT_ONCE ) {
pDispatcher->addStandardDelegate(this, 0); pDispatcher->addStandardDelegate(this, 0);
} else { } else {
pDispatcher->addTargetedDelegate(this, _touchPriority, true); pDispatcher->addTargetedDelegate(this, _touchPriority, true);
@ -155,7 +155,7 @@ void Layer::setTouchEnabled(bool enabled)
} }
} }
void Layer::setTouchMode(ccTouchesMode mode) void Layer::setTouchMode(TouchesMode mode)
{ {
if(_touchMode != mode) if(_touchMode != mode)
{ {
@ -708,7 +708,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h)
updateColor(); updateColor();
setContentSize(Size(w, h)); setContentSize(Size(w, h));
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_COLOR));
return true; return true;
} }
return false; return false;
@ -762,20 +762,20 @@ void LayerColor::draw()
{ {
CC_NODE_DRAW_SETUP(); CC_NODE_DRAW_SETUP();
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_Color ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_COLOR );
// //
// Attributes // Attributes
// //
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(_squareVertices, 4 * sizeof(Vertex2F), 0); setGLBufferData(_squareVertices, 4 * sizeof(Vertex2F), 0);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1); setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, _squareColors); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );

View File

@ -39,11 +39,6 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
typedef enum {
kTouchesAllAtOnce,
kTouchesOneByOne,
} ccTouchesMode;
/** /**
* @addtogroup layer * @addtogroup layer
* @{ * @{
@ -63,6 +58,12 @@ All features from Node are valid, plus the following new features:
class CC_DLL Layer : public Node, public TouchDelegate, public KeypadDelegate class CC_DLL Layer : public Node, public TouchDelegate, public KeypadDelegate
{ {
public: public:
enum TouchesMode
{
TOUCHES_ALL_AT_ONCE,
TOUCHES_ONE_BY_ONE,
};
/** creates a fullscreen black layer */ /** creates a fullscreen black layer */
static Layer *create(void); static Layer *create(void);
Layer(); Layer();
@ -103,7 +104,7 @@ public:
virtual bool isTouchEnabled() const; virtual bool isTouchEnabled() const;
virtual void setTouchEnabled(bool value); virtual void setTouchEnabled(bool value);
virtual void setTouchMode(ccTouchesMode mode); virtual void setTouchMode(TouchesMode mode);
virtual int getTouchMode() const; virtual int getTouchMode() const;
/** priority of the touch events. Default is 0 */ /** priority of the touch events. Default is 0 */
@ -148,7 +149,7 @@ protected:
private: private:
int _touchPriority; int _touchPriority;
ccTouchesMode _touchMode; TouchesMode _touchMode;
int executeScriptTouchHandler(int eventType, Touch* touch); int executeScriptTouchHandler(int eventType, Touch* touch);
int executeScriptTouchesHandler(int eventType, Set* touches); int executeScriptTouchesHandler(int eventType, Set* touches);

View File

@ -206,7 +206,7 @@ TransitionSceneOriented::~TransitionSceneOriented()
{ {
} }
TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene, tOrientation orientation) TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene, Orientation orientation)
{ {
TransitionSceneOriented * pScene = new TransitionSceneOriented(); TransitionSceneOriented * pScene = new TransitionSceneOriented();
pScene->initWithDuration(t,scene,orientation); pScene->initWithDuration(t,scene,orientation);
@ -214,7 +214,7 @@ TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene,
return pScene; return pScene;
} }
bool TransitionSceneOriented::initWithDuration(float t, Scene *scene, tOrientation orientation) bool TransitionSceneOriented::initWithDuration(float t, Scene *scene, Orientation orientation)
{ {
if ( TransitionScene::initWithDuration(t, scene) ) if ( TransitionScene::initWithDuration(t, scene) )
{ {
@ -740,7 +740,7 @@ void TransitionFlipX::onEnter()
float inDeltaZ, inAngleZ; float inDeltaZ, inAngleZ;
float outDeltaZ, outAngleZ; float outDeltaZ, outAngleZ;
if( _orientation == kTransitionOrientationRightOver ) if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER )
{ {
inDeltaZ = 90; inDeltaZ = 90;
inAngleZ = 270; inAngleZ = 270;
@ -776,7 +776,7 @@ void TransitionFlipX::onEnter()
_outScene->runAction(outA); _outScene->runAction(outA);
} }
TransitionFlipX* TransitionFlipX::create(float t, Scene* s, tOrientation o) TransitionFlipX* TransitionFlipX::create(float t, Scene* s, Orientation o)
{ {
TransitionFlipX* pScene = new TransitionFlipX(); TransitionFlipX* pScene = new TransitionFlipX();
pScene->initWithDuration(t, s, o); pScene->initWithDuration(t, s, o);
@ -787,7 +787,7 @@ TransitionFlipX* TransitionFlipX::create(float t, Scene* s, tOrientation o)
TransitionFlipX* TransitionFlipX::create(float t, Scene* s) TransitionFlipX* TransitionFlipX::create(float t, Scene* s)
{ {
return TransitionFlipX::create(t, s, kTransitionOrientationRightOver); return TransitionFlipX::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
// //
@ -810,7 +810,7 @@ void TransitionFlipY::onEnter()
float inDeltaZ, inAngleZ; float inDeltaZ, inAngleZ;
float outDeltaZ, outAngleZ; float outDeltaZ, outAngleZ;
if( _orientation == kTransitionOrientationUpOver ) if( _orientation == TransitionScene::ORIENTATION_UP_OVER )
{ {
inDeltaZ = 90; inDeltaZ = 90;
inAngleZ = 270; inAngleZ = 270;
@ -846,7 +846,7 @@ void TransitionFlipY::onEnter()
} }
TransitionFlipY* TransitionFlipY::create(float t, Scene* s, tOrientation o) TransitionFlipY* TransitionFlipY::create(float t, Scene* s, Orientation o)
{ {
TransitionFlipY* pScene = new TransitionFlipY(); TransitionFlipY* pScene = new TransitionFlipY();
pScene->initWithDuration(t, s, o); pScene->initWithDuration(t, s, o);
@ -857,7 +857,7 @@ TransitionFlipY* TransitionFlipY::create(float t, Scene* s, tOrientation o)
TransitionFlipY* TransitionFlipY::create(float t, Scene* s) TransitionFlipY* TransitionFlipY::create(float t, Scene* s)
{ {
return TransitionFlipY::create(t, s, kTransitionOrientationUpOver); return TransitionFlipY::create(t, s, TransitionScene::ORIENTATION_UP_OVER);
} }
// //
@ -881,7 +881,7 @@ void TransitionFlipAngular::onEnter()
float inDeltaZ, inAngleZ; float inDeltaZ, inAngleZ;
float outDeltaZ, outAngleZ; float outDeltaZ, outAngleZ;
if( _orientation == kTransitionOrientationRightOver ) if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER )
{ {
inDeltaZ = 90; inDeltaZ = 90;
inAngleZ = 270; inAngleZ = 270;
@ -916,7 +916,7 @@ void TransitionFlipAngular::onEnter()
_outScene->runAction(outA); _outScene->runAction(outA);
} }
TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, tOrientation o) TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, Orientation o)
{ {
TransitionFlipAngular* pScene = new TransitionFlipAngular(); TransitionFlipAngular* pScene = new TransitionFlipAngular();
pScene->initWithDuration(t, s, o); pScene->initWithDuration(t, s, o);
@ -927,7 +927,7 @@ TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, tOrienta
TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s) TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s)
{ {
return TransitionFlipAngular::create(t, s, kTransitionOrientationRightOver); return TransitionFlipAngular::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
// //
@ -950,7 +950,7 @@ void TransitionZoomFlipX::onEnter()
float inDeltaZ, inAngleZ; float inDeltaZ, inAngleZ;
float outDeltaZ, outAngleZ; float outDeltaZ, outAngleZ;
if( _orientation == kTransitionOrientationRightOver ) { if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER ) {
inDeltaZ = 90; inDeltaZ = 90;
inAngleZ = 270; inAngleZ = 270;
outDeltaZ = 90; outDeltaZ = 90;
@ -994,7 +994,7 @@ void TransitionZoomFlipX::onEnter()
_outScene->runAction(outA); _outScene->runAction(outA);
} }
TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, tOrientation o) TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, Orientation o)
{ {
TransitionZoomFlipX* pScene = new TransitionZoomFlipX(); TransitionZoomFlipX* pScene = new TransitionZoomFlipX();
pScene->initWithDuration(t, s, o); pScene->initWithDuration(t, s, o);
@ -1005,7 +1005,7 @@ TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, tOrientation
TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s) TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s)
{ {
return TransitionZoomFlipX::create(t, s, kTransitionOrientationRightOver); return TransitionZoomFlipX::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
// //
@ -1029,7 +1029,7 @@ void TransitionZoomFlipY::onEnter()
float inDeltaZ, inAngleZ; float inDeltaZ, inAngleZ;
float outDeltaZ, outAngleZ; float outDeltaZ, outAngleZ;
if( _orientation== kTransitionOrientationUpOver ) { if( _orientation== TransitionScene::ORIENTATION_UP_OVER ) {
inDeltaZ = 90; inDeltaZ = 90;
inAngleZ = 270; inAngleZ = 270;
outDeltaZ = 90; outDeltaZ = 90;
@ -1073,7 +1073,7 @@ void TransitionZoomFlipY::onEnter()
_outScene->runAction(outA); _outScene->runAction(outA);
} }
TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, tOrientation o) TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, Orientation o)
{ {
TransitionZoomFlipY* pScene = new TransitionZoomFlipY(); TransitionZoomFlipY* pScene = new TransitionZoomFlipY();
pScene->initWithDuration(t, s, o); pScene->initWithDuration(t, s, o);
@ -1084,7 +1084,7 @@ TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, tOrientation
TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s) TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s)
{ {
return TransitionZoomFlipY::create(t, s, kTransitionOrientationUpOver); return TransitionZoomFlipY::create(t, s, TransitionScene::ORIENTATION_UP_OVER);
} }
// //
@ -1108,7 +1108,7 @@ void TransitionZoomFlipAngular::onEnter()
float inDeltaZ, inAngleZ; float inDeltaZ, inAngleZ;
float outDeltaZ, outAngleZ; float outDeltaZ, outAngleZ;
if( _orientation == kTransitionOrientationRightOver ) { if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER ) {
inDeltaZ = 90; inDeltaZ = 90;
inAngleZ = 270; inAngleZ = 270;
outDeltaZ = 90; outDeltaZ = 90;
@ -1154,7 +1154,7 @@ void TransitionZoomFlipAngular::onEnter()
_outScene->runAction(outA); _outScene->runAction(outA);
} }
TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s, tOrientation o) TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s, Orientation o)
{ {
TransitionZoomFlipAngular* pScene = new TransitionZoomFlipAngular(); TransitionZoomFlipAngular* pScene = new TransitionZoomFlipAngular();
pScene->initWithDuration(t, s, o); pScene->initWithDuration(t, s, o);
@ -1165,7 +1165,7 @@ TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s,
TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s) TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s)
{ {
return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationRightOver); return TransitionZoomFlipAngular::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
// //

View File

@ -56,31 +56,25 @@ public:
virtual ActionInterval * easeActionWithAction(ActionInterval * action) = 0; virtual ActionInterval * easeActionWithAction(ActionInterval * action) = 0;
}; };
/** Orientation Type used by some transitions
*/
typedef enum {
/// An horizontal orientation where the Left is nearer
kTransitionOrientationLeftOver = 0,
/// An horizontal orientation where the Right is nearer
kTransitionOrientationRightOver = 1,
/// A vertical orientation where the Up is nearer
kTransitionOrientationUpOver = 0,
/// A vertical orientation where the Bottom is nearer
kTransitionOrientationDownOver = 1,
// Deprecated
// kOrientationLeftOver = kTransitionOrientationLeftOver,
// kOrientationRightOver = kTransitionOrientationRightOver,
// kOrientationUpOver = kTransitionOrientationUpOver,
// kOrientationDownOver = kTransitionOrientationDownOver,
} tOrientation;
/** @brief Base class for Transition scenes /** @brief Base class for Transition scenes
*/ */
class CC_DLL TransitionScene : public Scene class CC_DLL TransitionScene : public Scene
{ {
public: public:
/** Orientation Type used by some transitions
*/
enum Orientation
{
/// An horizontal orientation where the Left is nearer
ORIENTATION_LEFT_OVER = 0,
/// An horizontal orientation where the Right is nearer
ORIENTATION_RIGHT_OVER = 1,
/// A vertical orientation where the Up is nearer
ORIENTATION_UP_OVER = 0,
/// A vertical orientation where the Bottom is nearer
ORIENTATION_DOWN_OVER = 1,
};
/** creates a base transition with duration and incoming scene */ /** creates a base transition with duration and incoming scene */
static TransitionScene * create(float t, Scene *scene); static TransitionScene * create(float t, Scene *scene);
@ -125,16 +119,16 @@ class CC_DLL TransitionSceneOriented : public TransitionScene
{ {
public: public:
/** creates a base transition with duration and incoming scene */ /** creates a base transition with duration and incoming scene */
static TransitionSceneOriented * create(float t,Scene* scene, tOrientation orientation); static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation);
TransitionSceneOriented(); TransitionSceneOriented();
virtual ~TransitionSceneOriented(); virtual ~TransitionSceneOriented();
/** initializes a transition with duration and incoming scene */ /** initializes a transition with duration and incoming scene */
bool initWithDuration(float t,Scene* scene,tOrientation orientation); bool initWithDuration(float t,Scene* scene,Orientation orientation);
protected: protected:
tOrientation _orientation; Orientation _orientation;
}; };
/** @brief TransitionRotoZoom: /** @brief TransitionRotoZoom:
@ -345,7 +339,7 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionFlipX : public TransitionSceneOriented class CC_DLL TransitionFlipX : public TransitionSceneOriented
{ {
public: public:
static TransitionFlipX* create(float t, Scene* s, tOrientation o); static TransitionFlipX* create(float t, Scene* s, Orientation o);
static TransitionFlipX* create(float t, Scene* s); static TransitionFlipX* create(float t, Scene* s);
TransitionFlipX(); TransitionFlipX();
@ -364,7 +358,7 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionFlipY : public TransitionSceneOriented class CC_DLL TransitionFlipY : public TransitionSceneOriented
{ {
public: public:
static TransitionFlipY* create(float t, Scene* s, tOrientation o); static TransitionFlipY* create(float t, Scene* s, Orientation o);
static TransitionFlipY* create(float t, Scene* s); static TransitionFlipY* create(float t, Scene* s);
TransitionFlipY(); TransitionFlipY();
@ -383,7 +377,7 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionFlipAngular : public TransitionSceneOriented class CC_DLL TransitionFlipAngular : public TransitionSceneOriented
{ {
public: public:
static TransitionFlipAngular* create(float t, Scene* s, tOrientation o); static TransitionFlipAngular* create(float t, Scene* s, Orientation o);
static TransitionFlipAngular* create(float t, Scene* s); static TransitionFlipAngular* create(float t, Scene* s);
TransitionFlipAngular(); TransitionFlipAngular();
@ -402,7 +396,7 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented
{ {
public: public:
static TransitionZoomFlipX* create(float t, Scene* s, tOrientation o); static TransitionZoomFlipX* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipX* create(float t, Scene* s); static TransitionZoomFlipX* create(float t, Scene* s);
TransitionZoomFlipX(); TransitionZoomFlipX();
@ -421,7 +415,7 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented
{ {
public: public:
static TransitionZoomFlipY* create(float t, Scene* s, tOrientation o); static TransitionZoomFlipY* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipY* create(float t, Scene* s); static TransitionZoomFlipY* create(float t, Scene* s);
TransitionZoomFlipY(); TransitionZoomFlipY();
@ -440,7 +434,7 @@ The front face is the outgoing scene and the back face is the incoming scene.
class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented
{ {
public: public:
static TransitionZoomFlipAngular* create(float t, Scene* s, tOrientation o); static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o);
static TransitionZoomFlipAngular* create(float t, Scene* s); static TransitionZoomFlipAngular* create(float t, Scene* s);
TransitionZoomFlipAngular(); TransitionZoomFlipAngular();

View File

@ -140,7 +140,7 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R
// but it is flipped upside down so we flip the sprite // but it is flipped upside down so we flip the sprite
pNode->getSprite()->setFlipY(true); pNode->getSprite()->setFlipY(true);
pNode->setType(kProgressTimerTypeRadial); pNode->setType(ProgressTimer::RADIAL);
// Return the radial type that we want to use // Return the radial type that we want to use
pNode->setReverseDirection(false); pNode->setReverseDirection(false);
@ -184,7 +184,7 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re
// but it is flipped upside down so we flip the sprite // but it is flipped upside down so we flip the sprite
pNode->getSprite()->setFlipY(true); pNode->getSprite()->setFlipY(true);
pNode->setType( kProgressTimerTypeRadial ); pNode->setType( ProgressTimer::RADIAL );
// Return the radial type that we want to use // Return the radial type that we want to use
pNode->setReverseDirection(true); pNode->setReverseDirection(true);
@ -216,7 +216,7 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(
// but it is flipped upside down so we flip the sprite // but it is flipped upside down so we flip the sprite
pNode->getSprite()->setFlipY(true); pNode->getSprite()->setFlipY(true);
pNode->setType( kProgressTimerTypeBar); pNode->setType( ProgressTimer::BAR);
pNode->setMidpoint(Point(1, 0)); pNode->setMidpoint(Point(1, 0));
pNode->setBarChangeRate(Point(1,0)); pNode->setBarChangeRate(Point(1,0));
@ -249,7 +249,7 @@ ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(Re
// but it is flipped upside down so we flip the sprite // but it is flipped upside down so we flip the sprite
pNode->getSprite()->setFlipY(true); pNode->getSprite()->setFlipY(true);
pNode->setType(kProgressTimerTypeBar); pNode->setType(ProgressTimer::BAR);
pNode->setMidpoint(Point(0, 0)); pNode->setMidpoint(Point(0, 0));
pNode->setBarChangeRate(Point(0,1)); pNode->setBarChangeRate(Point(0,1));
@ -295,7 +295,7 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende
// but it is flipped upside down so we flip the sprite // but it is flipped upside down so we flip the sprite
pNode->getSprite()->setFlipY(true); pNode->getSprite()->setFlipY(true);
pNode->setType( kProgressTimerTypeBar); pNode->setType( ProgressTimer::BAR);
pNode->setMidpoint(Point(0.5f, 0.5f)); pNode->setMidpoint(Point(0.5f, 0.5f));
pNode->setBarChangeRate(Point(1, 1)); pNode->setBarChangeRate(Point(1, 1));
@ -329,7 +329,7 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende
// but it is flipped upside down so we flip the sprite // but it is flipped upside down so we flip the sprite
pNode->getSprite()->setFlipY(true); pNode->getSprite()->setFlipY(true);
pNode->setType( kProgressTimerTypeBar ); pNode->setType( ProgressTimer::BAR );
pNode->setMidpoint(Point(0.5f, 0.5f)); pNode->setMidpoint(Point(0.5f, 0.5f));
pNode->setBarChangeRate(Point(1, 1)); pNode->setBarChangeRate(Point(1, 1));

View File

@ -121,8 +121,8 @@ bool Menu::initWithArray(Array* pArrayOfItems)
{ {
if (Layer::init()) if (Layer::init())
{ {
setTouchPriority(kMenuHandlerPriority); setTouchPriority(Menu::HANDLER_PRIORITY);
setTouchMode(kTouchesOneByOne); setTouchMode(Layer::TOUCHES_ONE_BY_ONE);
setTouchEnabled(true); setTouchEnabled(true);
_enabled = true; _enabled = true;
@ -149,7 +149,7 @@ bool Menu::initWithArray(Array* pArrayOfItems)
// [self alignItemsVertically]; // [self alignItemsVertically];
_selectedItem = NULL; _selectedItem = NULL;
_state = kMenuStateWaiting; _state = Menu::STATE_WAITING;
// enable cascade color and opacity on menus // enable cascade color and opacity on menus
setCascadeColorEnabled(true); setCascadeColorEnabled(true);
@ -181,7 +181,7 @@ void Menu::addChild(Node * child, int zOrder, int tag)
void Menu::onExit() void Menu::onExit()
{ {
if (_state == kMenuStateTrackingTouch) if (_state == Menu::STATE_TRACKING_TOUCH)
{ {
if (_selectedItem) if (_selectedItem)
{ {
@ -189,7 +189,7 @@ void Menu::onExit()
_selectedItem = NULL; _selectedItem = NULL;
} }
_state = kMenuStateWaiting; _state = Menu::STATE_WAITING;
} }
Layer::onExit(); Layer::onExit();
@ -225,7 +225,7 @@ void Menu::registerWithTouchDispatcher()
bool Menu::ccTouchBegan(Touch* touch, Event* event) bool Menu::ccTouchBegan(Touch* touch, Event* event)
{ {
CC_UNUSED_PARAM(event); CC_UNUSED_PARAM(event);
if (_state != kMenuStateWaiting || ! _visible || !_enabled) if (_state != Menu::STATE_WAITING || ! _visible || !_enabled)
{ {
return false; return false;
} }
@ -241,7 +241,7 @@ bool Menu::ccTouchBegan(Touch* touch, Event* event)
_selectedItem = this->itemForTouch(touch); _selectedItem = this->itemForTouch(touch);
if (_selectedItem) if (_selectedItem)
{ {
_state = kMenuStateTrackingTouch; _state = Menu::STATE_TRACKING_TOUCH;
_selectedItem->selected(); _selectedItem->selected();
return true; return true;
} }
@ -252,31 +252,31 @@ void Menu::ccTouchEnded(Touch *touch, Event* event)
{ {
CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(touch);
CC_UNUSED_PARAM(event); CC_UNUSED_PARAM(event);
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state"); CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchEnded] -- invalid state");
if (_selectedItem) if (_selectedItem)
{ {
_selectedItem->unselected(); _selectedItem->unselected();
_selectedItem->activate(); _selectedItem->activate();
} }
_state = kMenuStateWaiting; _state = Menu::STATE_WAITING;
} }
void Menu::ccTouchCancelled(Touch *touch, Event* event) void Menu::ccTouchCancelled(Touch *touch, Event* event)
{ {
CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(touch);
CC_UNUSED_PARAM(event); CC_UNUSED_PARAM(event);
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchCancelled] -- invalid state");
if (_selectedItem) if (_selectedItem)
{ {
_selectedItem->unselected(); _selectedItem->unselected();
} }
_state = kMenuStateWaiting; _state = Menu::STATE_WAITING;
} }
void Menu::ccTouchMoved(Touch* touch, Event* event) void Menu::ccTouchMoved(Touch* touch, Event* event)
{ {
CC_UNUSED_PARAM(event); CC_UNUSED_PARAM(event);
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state"); CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchMoved] -- invalid state");
MenuItem *currentItem = this->itemForTouch(touch); MenuItem *currentItem = this->itemForTouch(touch);
if (currentItem != _selectedItem) if (currentItem != _selectedItem)
{ {

View File

@ -36,16 +36,8 @@ NS_CC_BEGIN
* @addtogroup menu * @addtogroup menu
* @{ * @{
*/ */
typedef enum
{
kMenuStateWaiting,
kMenuStateTrackingTouch
} tMenuState;
enum {
//* priority used by the menu for the event handler
kMenuHandlerPriority = -128,
};
/** @brief A Menu /** @brief A Menu
* *
@ -56,6 +48,17 @@ enum {
class CC_DLL Menu : public LayerRGBA class CC_DLL Menu : public LayerRGBA
{ {
public: public:
enum
{
HANDLER_PRIORITY = -128,
};
enum State
{
STATE_WAITING,
STATE_TRACKING_TOUCH,
};
/** creates an empty Menu */ /** creates an empty Menu */
static Menu* create(); static Menu* create();
@ -133,7 +136,7 @@ protected:
bool _enabled; bool _enabled;
MenuItem* itemForTouch(Touch * touch); MenuItem* itemForTouch(Touch * touch);
tMenuState _state; State _state;
MenuItem *_selectedItem; MenuItem *_selectedItem;
}; };

View File

@ -308,8 +308,8 @@ void ClippingNode::visit()
#else #else
// since glAlphaTest do not exists in OES, use a shader that writes // since glAlphaTest do not exists in OES, use a shader that writes
// pixel only if greater than an alpha threshold // pixel only if greater than an alpha threshold
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
// set our alphaThreshold // set our alphaThreshold
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
// we need to recursively apply this shader to all the nodes in the stencil node // we need to recursively apply this shader to all the nodes in the stencil node

View File

@ -127,7 +127,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
// shader program // shader program
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
setTexture(texture); setTexture(texture);
setColor(color); setColor(color);
@ -331,7 +331,7 @@ void MotionStreak::draw()
CC_NODE_DRAW_SETUP(); CC_NODE_DRAW_SETUP();
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex ); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
ccGLBindTexture2D( _texture->getName() ); ccGLBindTexture2D( _texture->getName() );
@ -339,17 +339,17 @@ void MotionStreak::draw()
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
// Size calculations from ::initWithFade // Size calculations from ::initWithFade
setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0); setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1); setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2); setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoords); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoords);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2); glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2);

View File

@ -45,7 +45,7 @@ const char kProgressTextureCoords = 0x4b;
ProgressTimer::ProgressTimer() ProgressTimer::ProgressTimer()
:_type(kProgressTimerTypeRadial) :_type(RADIAL)
,_percentage(0.0f) ,_percentage(0.0f)
,_sprite(NULL) ,_sprite(NULL)
,_vertexDataCount(0) ,_vertexDataCount(0)
@ -78,13 +78,13 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
_vertexDataCount = 0; _vertexDataCount = 0;
setAnchorPoint(Point(0.5f,0.5f)); setAnchorPoint(Point(0.5f,0.5f));
_type = kProgressTimerTypeRadial; _type = RADIAL;
_reverseDirection = false; _reverseDirection = false;
setMidpoint(Point(0.5f, 0.5f)); setMidpoint(Point(0.5f, 0.5f));
setBarChangeRate(Point(1,1)); setBarChangeRate(Point(1,1));
setSprite(sp); setSprite(sp);
// shader program // shader program
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
return true; return true;
} }
@ -121,7 +121,7 @@ void ProgressTimer::setSprite(Sprite *pSprite)
} }
} }
void ProgressTimer::setType(ProgressTimerType type) void ProgressTimer::setType(Type type)
{ {
if (type != _type) if (type != _type)
{ {
@ -225,10 +225,10 @@ void ProgressTimer::updateProgress(void)
{ {
switch (_type) switch (_type)
{ {
case kProgressTimerTypeRadial: case RADIAL:
updateRadial(); updateRadial();
break; break;
case kProgressTimerTypeBar: case BAR:
updateBar(); updateBar();
break; break;
default: default:
@ -506,7 +506,7 @@ void ProgressTimer::draw(void)
ccGLBlendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst ); ccGLBlendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst );
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex ); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
ccGLBindTexture2D( _sprite->getTexture()->getName() ); ccGLBindTexture2D( _sprite->getTexture()->getName() );
@ -514,24 +514,24 @@ void ProgressTimer::draw(void)
setGLBufferData((void*) _vertexData, (_vertexDataCount * sizeof(V2F_C4B_T2F)), 0); setGLBufferData((void*) _vertexData, (_vertexDataCount * sizeof(V2F_C4B_T2F)), 0);
int offset = 0; int offset = 0;
glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
offset += sizeof(Vertex2F); offset += sizeof(Vertex2F);
glVertexAttribPointer( kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
offset += sizeof(Color4B); offset += sizeof(Color4B);
glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
#else #else
glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices);
glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords);
glVertexAttribPointer( kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors); glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
if(_type == kProgressTimerTypeRadial) if(_type == RADIAL)
{ {
glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount); glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount);
} }
else if (_type == kProgressTimerTypeBar) else if (_type == BAR)
{ {
if (!_reverseDirection) if (!_reverseDirection)
{ {

View File

@ -37,16 +37,6 @@ NS_CC_BEGIN
* @{ * @{
*/ */
/** Types of progress
@since v0.99.1
*/
typedef enum {
/// Radial Counter-Clockwise
kProgressTimerTypeRadial,
/// Bar
kProgressTimerTypeBar,
} ProgressTimerType;
/** /**
@brief ProgressTimer is a subclass of Node. @brief ProgressTimer is a subclass of Node.
It renders the inner sprite according to the percentage. It renders the inner sprite according to the percentage.
@ -59,6 +49,17 @@ class CC_DLL ProgressTimer : public NodeRGBA
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
{ {
public: public:
/** Types of progress
@since v0.99.1
*/
enum Type
{
/// Radial Counter-Clockwise
RADIAL,
/// Bar
BAR,
};
/** Creates a progress timer with the sprite as the shape the timer goes through */ /** Creates a progress timer with the sprite as the shape the timer goes through */
static ProgressTimer* create(Sprite* sp); static ProgressTimer* create(Sprite* sp);
@ -69,7 +70,7 @@ public:
bool initWithSprite(Sprite* sp); bool initWithSprite(Sprite* sp);
/** Change the percentage to change progress. */ /** Change the percentage to change progress. */
inline ProgressTimerType getType() const { return _type; } inline Type getType() const { return _type; }
/** Percentages are from 0 to 100 */ /** Percentages are from 0 to 100 */
inline float getPercentage() const {return _percentage; } inline float getPercentage() const {return _percentage; }
@ -79,7 +80,7 @@ public:
void setPercentage(float fPercentage); void setPercentage(float fPercentage);
void setSprite(Sprite *pSprite); void setSprite(Sprite *pSprite);
void setType(ProgressTimerType type); void setType(Type type);
void setReverseProgress(bool reverse); void setReverseProgress(bool reverse);
inline bool isReverseDirection() { return _reverseDirection; }; inline bool isReverseDirection() { return _reverseDirection; };
@ -126,7 +127,7 @@ protected:
void updateColor(void); void updateColor(void);
Point boundaryTexCoord(char index); Point boundaryTexCoord(char index);
ProgressTimerType _type; Type _type;
Point _midpoint; Point _midpoint;
Point _barChangeRate; Point _barChangeRate;
float _percentage; float _percentage;

View File

@ -51,7 +51,7 @@ RenderTexture::RenderTexture()
, _texture(0) , _texture(0)
, _textureCopy(0) , _textureCopy(0)
, _UITextureImage(NULL) , _UITextureImage(NULL)
, _pixelFormat(kTexture2DPixelFormat_RGBA8888) , _pixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888)
, _clearFlags(0) , _clearFlags(0)
, _clearColor(Color4F(0,0,0,0)) , _clearColor(Color4F(0,0,0,0))
, _clearDepth(0.0f) , _clearDepth(0.0f)
@ -102,11 +102,11 @@ void RenderTexture::listenToBackground(cocos2d::Object *obj)
if (_UITextureImage) if (_UITextureImage)
{ {
const Size& s = _texture->getContentSizeInPixels(); const Size& s = _texture->getContentSizeInPixels();
VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s); VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), Texture2D::PIXEL_FORMAT_RGBA8888, s);
if ( _textureCopy ) if ( _textureCopy )
{ {
VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s); VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), Texture2D::PIXEL_FORMAT_RGBA8888, s);
} }
} }
else else
@ -140,7 +140,7 @@ void RenderTexture::listenToForeground(cocos2d::Object *obj)
#endif #endif
} }
RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat) RenderTexture * RenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat)
{ {
RenderTexture *pRet = new RenderTexture(); RenderTexture *pRet = new RenderTexture();
@ -153,7 +153,7 @@ RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat
return NULL; return NULL;
} }
RenderTexture * RenderTexture::create(int w ,int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat) RenderTexture * RenderTexture::create(int w ,int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat)
{ {
RenderTexture *pRet = new RenderTexture(); RenderTexture *pRet = new RenderTexture();
@ -170,7 +170,7 @@ RenderTexture * RenderTexture::create(int w, int h)
{ {
RenderTexture *pRet = new RenderTexture(); RenderTexture *pRet = new RenderTexture();
if(pRet && pRet->initWithWidthAndHeight(w, h, kTexture2DPixelFormat_RGBA8888, 0)) if(pRet && pRet->initWithWidthAndHeight(w, h, Texture2D::PIXEL_FORMAT_RGBA8888, 0))
{ {
pRet->autorelease(); pRet->autorelease();
return pRet; return pRet;
@ -179,14 +179,14 @@ RenderTexture * RenderTexture::create(int w, int h)
return NULL; return NULL;
} }
bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat) bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat)
{ {
return initWithWidthAndHeight(w, h, eFormat, 0); return initWithWidthAndHeight(w, h, eFormat, 0);
} }
bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat) bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat)
{ {
CCASSERT(eFormat != kTexture2DPixelFormat_A8, "only RGB and RGBA formats are valid for a render texture"); CCASSERT(eFormat != Texture2D::PIXEL_FORMAT_A8, "only RGB and RGBA formats are valid for a render texture");
bool bRet = false; bool bRet = false;
void *data = NULL; void *data = NULL;
@ -221,7 +221,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
_texture = new Texture2D(); _texture = new Texture2D();
if (_texture) if (_texture)
{ {
_texture->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); _texture->initWithData(data, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
} }
else else
{ {
@ -235,7 +235,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
_textureCopy = new Texture2D(); _textureCopy = new Texture2D();
if (_textureCopy) if (_textureCopy)
{ {
_textureCopy->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); _textureCopy->initWithData(data, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
} }
else else
{ {
@ -550,16 +550,16 @@ bool RenderTexture::saveToFile(const char *szFilePath)
Image *pImage = newImage(true); Image *pImage = newImage(true);
if (pImage) if (pImage)
{ {
bRet = pImage->saveToFile(szFilePath, kImageFormatJPEG); bRet = pImage->saveToFile(szFilePath, Image::FORMAT_JPG);
} }
CC_SAFE_DELETE(pImage); CC_SAFE_DELETE(pImage);
return bRet; return bRet;
} }
bool RenderTexture::saveToFile(const char *fileName, tImageFormat format) bool RenderTexture::saveToFile(const char *fileName, Image::Format format)
{ {
bool bRet = false; bool bRet = false;
CCASSERT(format == kImageFormatJPEG || format == kImageFormatPNG, CCASSERT(format == Image::FORMAT_JPG || format == Image::FORMAT_PNG,
"the image can only be saved as JPG or PNG format"); "the image can only be saved as JPG or PNG format");
Image *pImage = newImage(true); Image *pImage = newImage(true);
@ -578,7 +578,7 @@ bool RenderTexture::saveToFile(const char *fileName, tImageFormat format)
/* get buffer as Image */ /* get buffer as Image */
Image* RenderTexture::newImage(bool flipImage) Image* RenderTexture::newImage(bool flipImage)
{ {
CCASSERT(_pixelFormat == kTexture2DPixelFormat_RGBA8888, "only RGBA8888 can be saved as image"); CCASSERT(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA8888, "only RGBA8888 can be saved as image");
if (NULL == _texture) if (NULL == _texture)
{ {
@ -624,11 +624,11 @@ Image* RenderTexture::newImage(bool flipImage)
nSavedBufferWidth * 4); nSavedBufferWidth * 4);
} }
pImage->initWithImageData(pBuffer, nSavedBufferWidth * nSavedBufferHeight * 4, Image::kFmtRawData, nSavedBufferWidth, nSavedBufferHeight, 8); pImage->initWithImageData(pBuffer, nSavedBufferWidth * nSavedBufferHeight * 4, Image::FORMAT_RAW_DATA, nSavedBufferWidth, nSavedBufferHeight, 8);
} }
else else
{ {
pImage->initWithImageData(pTempData, nSavedBufferWidth * nSavedBufferHeight * 4, Image::kFmtRawData, nSavedBufferWidth, nSavedBufferHeight, 8); pImage->initWithImageData(pTempData, nSavedBufferWidth * nSavedBufferHeight * 4, Image::FORMAT_RAW_DATA, nSavedBufferWidth, nSavedBufferHeight, 8);
} }
} while (0); } while (0);

View File

@ -28,6 +28,7 @@ THE SOFTWARE.
#include "base_nodes/CCNode.h" #include "base_nodes/CCNode.h"
#include "sprite_nodes/CCSprite.h" #include "sprite_nodes/CCSprite.h"
#include "kazmath/mat4.h" #include "kazmath/mat4.h"
#include "platform/CCImage.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -36,11 +37,6 @@ NS_CC_BEGIN
* @{ * @{
*/ */
typedef enum eImageFormat
{
kImageFormatJPEG = 0,
kImageFormatPNG = 1,
} tImageFormat;
/** /**
@brief RenderTexture is a generic rendering target. To render things into it, @brief RenderTexture is a generic rendering target. To render things into it,
simply construct a render target, call begin on it, call visit on any cocos simply construct a render target, call begin on it, call visit on any cocos
@ -55,10 +51,10 @@ class CC_DLL RenderTexture : public Node
{ {
public: public:
/** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/
static RenderTexture * create(int w ,int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat); static RenderTexture * create(int w ,int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat);
/** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */
static RenderTexture * create(int w, int h, Texture2DPixelFormat eFormat); static RenderTexture * create(int w, int h, Texture2D::PixelFormat eFormat);
/** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */ /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */
static RenderTexture * create(int w, int h); static RenderTexture * create(int w, int h);
@ -67,10 +63,10 @@ public:
virtual ~RenderTexture(); virtual ~RenderTexture();
/** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */
bool initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat); bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat);
/** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/
bool initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat); bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat);
/** starts grabbing */ /** starts grabbing */
void begin(); void begin();
@ -117,7 +113,7 @@ public:
/** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder. /** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder.
Returns YES if the operation is successful. Returns YES if the operation is successful.
*/ */
bool saveToFile(const char *name, tImageFormat format); bool saveToFile(const char *name, Image::Format format);
/** Listen "come to background" message, and save render texture. /** Listen "come to background" message, and save render texture.
It only has effect on Android. It only has effect on Android.

View File

@ -102,7 +102,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, unsigned int capacity)
_blendFunc.src = CC_BLEND_SRC; _blendFunc.src = CC_BLEND_SRC;
_blendFunc.dst = CC_BLEND_DST; _blendFunc.dst = CC_BLEND_DST;
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
return true; return true;
} }

View File

@ -47,7 +47,7 @@ static Texture2D* getDefaultTexture()
pImage = new Image(); pImage = new Image();
CC_BREAK_IF(NULL == pImage); CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), Image::kFmtPng); bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), Image::FORMAT_PNG);
CC_BREAK_IF(!bRet); CC_BREAK_IF(!bRet);
pTexture = TextureCache::getInstance()->addUIImage(pImage, key); pTexture = TextureCache::getInstance()->addUIImage(pImage, key);
@ -91,10 +91,10 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// Gravity Mode // Gravity Mode
this->_emitterMode = kParticleModeGravity; this->_emitterMode = MODE_GRAVITY;
// Gravity Mode: gravity // Gravity Mode: gravity
this->modeA.gravity = Point(0,0); this->modeA.gravity = Point(0,0);
@ -124,7 +124,7 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 54.0f; _startSize = 54.0f;
_startSizeVar = 10.0f; _startSizeVar = 10.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per frame // emits per frame
_emissionRate = _totalParticles/_life; _emissionRate = _totalParticles/_life;
@ -196,10 +196,10 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration= kParticleDurationInfinity; _duration= DURATION_INFINITY;
// Gravity Mode // Gravity Mode
this->_emitterMode = kParticleModeGravity; this->_emitterMode = MODE_GRAVITY;
// Gravity Mode: gravity // Gravity Mode: gravity
this->modeA.gravity = Point(0,-90); this->modeA.gravity = Point(0,-90);
@ -248,7 +248,7 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 8.0f; _startSize = 8.0f;
_startSizeVar = 2.0f; _startSizeVar = 2.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
Texture2D* pTexture = getDefaultTexture(); Texture2D* pTexture = getDefaultTexture();
if (pTexture != NULL) if (pTexture != NULL)
@ -300,10 +300,10 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
this->setBlendAdditive(true); this->setBlendAdditive(true);
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// Gravity Mode // Gravity Mode
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,0)); setGravity(Point(0,0));
@ -333,7 +333,7 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 30.0f; _startSize = 30.0f;
_startSizeVar = 10.0f; _startSizeVar = 10.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per seconds // emits per seconds
_emissionRate = _totalParticles/_life; _emissionRate = _totalParticles/_life;
@ -404,10 +404,10 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// Gravity Mode // Gravity Mode
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,0)); setGravity(Point(0,0));
@ -440,7 +440,7 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 37.0f; _startSize = 37.0f;
_startSizeVar = 10.0f; _startSizeVar = 10.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per second // emits per second
_emissionRate = _totalParticles/_life; _emissionRate = _totalParticles/_life;
@ -513,10 +513,10 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// Gravity Mode // Gravity Mode
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,0)); setGravity(Point(0,0));
@ -549,7 +549,7 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 30.0f; _startSize = 30.0f;
_startSizeVar = 10.0f; _startSizeVar = 10.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per second // emits per second
_emissionRate = _totalParticles/_life; _emissionRate = _totalParticles/_life;
@ -621,10 +621,10 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// Gravity Mode // Gravity Mode
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(-200,200)); setGravity(Point(-200,200));
@ -657,7 +657,7 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 60.0f; _startSize = 60.0f;
_startSizeVar = 10.0f; _startSizeVar = 10.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per second // emits per second
_emissionRate = _totalParticles/_life; _emissionRate = _totalParticles/_life;
@ -730,10 +730,10 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// Gravity Mode // Gravity Mode
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,0)); setGravity(Point(0,0));
@ -766,7 +766,7 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 20.0f; _startSize = 20.0f;
_startSizeVar = 0.0f; _startSizeVar = 0.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per second // emits per second
_emissionRate = _totalParticles/_life; _emissionRate = _totalParticles/_life;
@ -841,7 +841,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
// duration // duration
_duration = 0.1f; _duration = 0.1f;
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,0)); setGravity(Point(0,0));
@ -874,7 +874,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 15.0f; _startSize = 15.0f;
_startSizeVar = 10.0f; _startSizeVar = 10.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per second // emits per second
_emissionRate = _totalParticles/_duration; _emissionRate = _totalParticles/_duration;
@ -947,10 +947,10 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// Emitter mode: Gravity Mode // Emitter mode: Gravity Mode
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,0)); setGravity(Point(0,0));
@ -979,7 +979,7 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 60.0f; _startSize = 60.0f;
_startSizeVar = 10.0f; _startSizeVar = 10.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per frame // emits per frame
_emissionRate = _totalParticles/_life; _emissionRate = _totalParticles/_life;
@ -1052,10 +1052,10 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
// set gravity mode. // set gravity mode.
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,-1)); setGravity(Point(0,-1));
@ -1088,7 +1088,7 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 10.0f; _startSize = 10.0f;
_startSizeVar = 5.0f; _startSizeVar = 5.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per second // emits per second
_emissionRate = 10; _emissionRate = 10;
@ -1160,9 +1160,9 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
{ {
// duration // duration
_duration = kParticleDurationInfinity; _duration = DURATION_INFINITY;
setEmitterMode(kParticleModeGravity); setEmitterMode(MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(10,-10)); setGravity(Point(10,-10));
@ -1196,7 +1196,7 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
_startSize = 4.0f; _startSize = 4.0f;
_startSizeVar = 2.0f; _startSizeVar = 2.0f;
_endSize = kParticleStartSizeEqualToEndSize; _endSize = START_SIZE_EQUAL_TO_END_SIZE;
// emits per second // emits per second
_emissionRate = 20; _emissionRate = 20;

View File

@ -42,6 +42,9 @@ THE SOFTWARE.
// //
#include "CCParticleSystem.h" #include "CCParticleSystem.h"
#include <string>
#include "CCParticleBatchNode.h" #include "CCParticleBatchNode.h"
#include "ccTypes.h" #include "ccTypes.h"
#include "textures/CCTextureCache.h" #include "textures/CCTextureCache.h"
@ -55,8 +58,6 @@ THE SOFTWARE.
// opengl // opengl
#include "CCGL.h" #include "CCGL.h"
#include <string>
using namespace std; using namespace std;
@ -111,9 +112,9 @@ ParticleSystem::ParticleSystem()
, _texture(NULL) , _texture(NULL)
, _opacityModifyRGB(false) , _opacityModifyRGB(false)
, _isBlendAdditive(false) , _isBlendAdditive(false)
, _positionType(kPositionTypeFree) , _positionType(POSITION_TYPE_FREE)
, _isAutoRemoveOnFinish(false) , _isAutoRemoveOnFinish(false)
, _emitterMode(kParticleModeGravity) , _emitterMode(MODE_GRAVITY)
{ {
modeA.gravity = Point::ZERO; modeA.gravity = Point::ZERO;
modeA.speed = 0; modeA.speed = 0;
@ -259,7 +260,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
_emitterMode = dictionary->valueForKey("emitterType")->intValue(); _emitterMode = dictionary->valueForKey("emitterType")->intValue();
// Mode A: Gravity + tangential accel + radial accel // Mode A: Gravity + tangential accel + radial accel
if( _emitterMode == kParticleModeGravity ) if (_emitterMode == MODE_GRAVITY)
{ {
// gravity // gravity
modeA.gravity.x = dictionary->valueForKey("gravityx")->floatValue(); modeA.gravity.x = dictionary->valueForKey("gravityx")->floatValue();
@ -282,7 +283,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
} }
// or Mode B: radius movement // or Mode B: radius movement
else if( _emitterMode == kParticleModeRadius ) else if (_emitterMode == MODE_RADIUS)
{ {
modeB.startRadius = dictionary->valueForKey("maxRadius")->floatValue(); modeB.startRadius = dictionary->valueForKey("maxRadius")->floatValue();
modeB.startRadiusVar = dictionary->valueForKey("maxRadiusVariance")->floatValue(); modeB.startRadiusVar = dictionary->valueForKey("maxRadiusVariance")->floatValue();
@ -418,10 +419,10 @@ bool ParticleSystem::initWithTotalParticles(unsigned int numberOfParticles)
_blendFunc.dst = CC_BLEND_DST; _blendFunc.dst = CC_BLEND_DST;
// default movement type; // default movement type;
_positionType = kPositionTypeFree; _positionType = POSITION_TYPE_FREE;
// by default be in mode A: // by default be in mode A:
_emitterMode = kParticleModeGravity; _emitterMode = MODE_GRAVITY;
// default: modulate // default: modulate
// XXX: not used // XXX: not used
@ -501,7 +502,7 @@ void ParticleSystem::initParticle(tParticle* particle)
particle->size = startS; particle->size = startS;
if( _endSize == kParticleStartSizeEqualToEndSize ) if (_endSize == START_SIZE_EQUAL_TO_END_SIZE)
{ {
particle->deltaSize = 0; particle->deltaSize = 0;
} }
@ -519,11 +520,11 @@ void ParticleSystem::initParticle(tParticle* particle)
particle->deltaRotation = (endA - startA) / particle->timeToLive; particle->deltaRotation = (endA - startA) / particle->timeToLive;
// position // position
if( _positionType == kPositionTypeFree ) if (_positionType == POSITION_TYPE_FREE)
{ {
particle->startPos = this->convertToWorldSpace(Point::ZERO); particle->startPos = this->convertToWorldSpace(Point::ZERO);
} }
else if ( _positionType == kPositionTypeRelative ) else if (_positionType == POSITION_TYPE_RELATIVE)
{ {
particle->startPos = _position; particle->startPos = _position;
} }
@ -532,7 +533,7 @@ void ParticleSystem::initParticle(tParticle* particle)
float a = CC_DEGREES_TO_RADIANS( _angle + _angleVar * CCRANDOM_MINUS1_1() ); float a = CC_DEGREES_TO_RADIANS( _angle + _angleVar * CCRANDOM_MINUS1_1() );
// Mode Gravity: A // Mode Gravity: A
if (_emitterMode == kParticleModeGravity) if (_emitterMode == MODE_GRAVITY)
{ {
Point v(cosf( a ), sinf( a )); Point v(cosf( a ), sinf( a ));
float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1(); float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1();
@ -561,7 +562,7 @@ void ParticleSystem::initParticle(tParticle* particle)
particle->modeB.radius = startRadius; particle->modeB.radius = startRadius;
if(modeB.endRadius == kParticleStartRadiusEqualToEndRadius) if (modeB.endRadius == START_RADIUS_EQUAL_TO_END_RADIUS)
{ {
particle->modeB.deltaRadius = 0; particle->modeB.deltaRadius = 0;
} }
@ -627,11 +628,11 @@ void ParticleSystem::update(float dt)
_particleIdx = 0; _particleIdx = 0;
Point currentPosition = Point::ZERO; Point currentPosition = Point::ZERO;
if (_positionType == kPositionTypeFree) if (_positionType == POSITION_TYPE_FREE)
{ {
currentPosition = this->convertToWorldSpace(Point::ZERO); currentPosition = this->convertToWorldSpace(Point::ZERO);
} }
else if (_positionType == kPositionTypeRelative) else if (_positionType == POSITION_TYPE_RELATIVE)
{ {
currentPosition = _position; currentPosition = _position;
} }
@ -648,7 +649,7 @@ void ParticleSystem::update(float dt)
if (p->timeToLive > 0) if (p->timeToLive > 0)
{ {
// Mode A: gravity, direction, tangential accel & radial accel // Mode A: gravity, direction, tangential accel & radial accel
if (_emitterMode == kParticleModeGravity) if (_emitterMode == MODE_GRAVITY)
{ {
Point tmp, radial, tangential; Point tmp, radial, tangential;
@ -705,7 +706,7 @@ void ParticleSystem::update(float dt)
Point newPos; Point newPos;
if (_positionType == kPositionTypeFree || _positionType == kPositionTypeRelative) if (_positionType == POSITION_TYPE_FREE || _positionType == POSITION_TYPE_RELATIVE)
{ {
Point diff = currentPosition - p->startPos; Point diff = currentPosition - p->startPos;
newPos = p->pos - diff; newPos = p->pos - diff;
@ -857,170 +858,170 @@ bool ParticleSystem::isBlendAdditive() const
// ParticleSystem - Properties of Gravity Mode // ParticleSystem - Properties of Gravity Mode
void ParticleSystem::setTangentialAccel(float t) void ParticleSystem::setTangentialAccel(float t)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT( _emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.tangentialAccel = t; modeA.tangentialAccel = t;
} }
float ParticleSystem::getTangentialAccel() const float ParticleSystem::getTangentialAccel() const
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT( _emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.tangentialAccel; return modeA.tangentialAccel;
} }
void ParticleSystem::setTangentialAccelVar(float t) void ParticleSystem::setTangentialAccelVar(float t)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.tangentialAccelVar = t; modeA.tangentialAccelVar = t;
} }
float ParticleSystem::getTangentialAccelVar() const float ParticleSystem::getTangentialAccelVar() const
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.tangentialAccelVar; return modeA.tangentialAccelVar;
} }
void ParticleSystem::setRadialAccel(float t) void ParticleSystem::setRadialAccel(float t)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.radialAccel = t; modeA.radialAccel = t;
} }
float ParticleSystem::getRadialAccel() const float ParticleSystem::getRadialAccel() const
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.radialAccel; return modeA.radialAccel;
} }
void ParticleSystem::setRadialAccelVar(float t) void ParticleSystem::setRadialAccelVar(float t)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.radialAccelVar = t; modeA.radialAccelVar = t;
} }
float ParticleSystem::getRadialAccelVar() const float ParticleSystem::getRadialAccelVar() const
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.radialAccelVar; return modeA.radialAccelVar;
} }
void ParticleSystem::setRotationIsDir(bool t) void ParticleSystem::setRotationIsDir(bool t)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.rotationIsDir = t; modeA.rotationIsDir = t;
} }
bool ParticleSystem::getRotationIsDir() const bool ParticleSystem::getRotationIsDir() const
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.rotationIsDir; return modeA.rotationIsDir;
} }
void ParticleSystem::setGravity(const Point& g) void ParticleSystem::setGravity(const Point& g)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.gravity = g; modeA.gravity = g;
} }
const Point& ParticleSystem::getGravity() const Point& ParticleSystem::getGravity()
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.gravity; return modeA.gravity;
} }
void ParticleSystem::setSpeed(float speed) void ParticleSystem::setSpeed(float speed)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.speed = speed; modeA.speed = speed;
} }
float ParticleSystem::getSpeed() const float ParticleSystem::getSpeed() const
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.speed; return modeA.speed;
} }
void ParticleSystem::setSpeedVar(float speedVar) void ParticleSystem::setSpeedVar(float speedVar)
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
modeA.speedVar = speedVar; modeA.speedVar = speedVar;
} }
float ParticleSystem::getSpeedVar() const float ParticleSystem::getSpeedVar() const
{ {
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
return modeA.speedVar; return modeA.speedVar;
} }
// ParticleSystem - Properties of Radius Mode // ParticleSystem - Properties of Radius Mode
void ParticleSystem::setStartRadius(float startRadius) void ParticleSystem::setStartRadius(float startRadius)
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
modeB.startRadius = startRadius; modeB.startRadius = startRadius;
} }
float ParticleSystem::getStartRadius() const float ParticleSystem::getStartRadius() const
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
return modeB.startRadius; return modeB.startRadius;
} }
void ParticleSystem::setStartRadiusVar(float startRadiusVar) void ParticleSystem::setStartRadiusVar(float startRadiusVar)
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
modeB.startRadiusVar = startRadiusVar; modeB.startRadiusVar = startRadiusVar;
} }
float ParticleSystem::getStartRadiusVar() const float ParticleSystem::getStartRadiusVar() const
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
return modeB.startRadiusVar; return modeB.startRadiusVar;
} }
void ParticleSystem::setEndRadius(float endRadius) void ParticleSystem::setEndRadius(float endRadius)
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
modeB.endRadius = endRadius; modeB.endRadius = endRadius;
} }
float ParticleSystem::getEndRadius() const float ParticleSystem::getEndRadius() const
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
return modeB.endRadius; return modeB.endRadius;
} }
void ParticleSystem::setEndRadiusVar(float endRadiusVar) void ParticleSystem::setEndRadiusVar(float endRadiusVar)
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
modeB.endRadiusVar = endRadiusVar; modeB.endRadiusVar = endRadiusVar;
} }
float ParticleSystem::getEndRadiusVar() const float ParticleSystem::getEndRadiusVar() const
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
return modeB.endRadiusVar; return modeB.endRadiusVar;
} }
void ParticleSystem::setRotatePerSecond(float degrees) void ParticleSystem::setRotatePerSecond(float degrees)
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
modeB.rotatePerSecond = degrees; modeB.rotatePerSecond = degrees;
} }
float ParticleSystem::getRotatePerSecond() const float ParticleSystem::getRotatePerSecond() const
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
return modeB.rotatePerSecond; return modeB.rotatePerSecond;
} }
void ParticleSystem::setRotatePerSecondVar(float degrees) void ParticleSystem::setRotatePerSecondVar(float degrees)
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
modeB.rotatePerSecondVar = degrees; modeB.rotatePerSecondVar = degrees;
} }
float ParticleSystem::getRotatePerSecondVar() const float ParticleSystem::getRotatePerSecondVar() const
{ {
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
return modeB.rotatePerSecondVar; return modeB.rotatePerSecondVar;
} }

View File

@ -40,45 +40,6 @@ NS_CC_BEGIN
class ParticleBatchNode; class ParticleBatchNode;
//* @enum
enum {
/** The Particle emitter lives forever */
kParticleDurationInfinity = -1,
/** The starting size of the particle is equal to the ending size */
kParticleStartSizeEqualToEndSize = -1,
/** The starting radius of the particle is equal to the ending radius */
kParticleStartRadiusEqualToEndRadius = -1
};
//* @enum
enum {
/** Gravity mode (A mode) */
kParticleModeGravity,
/** Radius mode (B mode) */
kParticleModeRadius,
};
/** @typedef tPositionType
possible types of particle positions
*/
typedef enum {
/** Living particles are attached to the world and are unaffected by emitter repositioning. */
kPositionTypeFree,
/** Living particles are attached to the world but will follow the emitter repositioning.
Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
*/
kPositionTypeRelative,
/** Living particles are attached to the emitter and are translated along with it. */
kPositionTypeGrouped,
}tPositionType;
/** /**
Structure that contains the values of each particle Structure that contains the values of each particle
*/ */
@ -166,6 +127,41 @@ emitter.startSpin = 0;
class CC_DLL ParticleSystem : public Node, public TextureProtocol class CC_DLL ParticleSystem : public Node, public TextureProtocol
{ {
public: public:
enum
{
MODE_GRAVITY,
MODE_RADIUS,
};
/** @typedef PositionType
possible types of particle positions
*/
enum PositionType
{
/** Living particles are attached to the world and are unaffected by emitter repositioning. */
POSITION_TYPE_FREE,
/** Living particles are attached to the world but will follow the emitter repositioning.
Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
*/
POSITION_TYPE_RELATIVE,
/** Living particles are attached to the emitter and are translated along with it. */
POSITION_TYPE_GROUPED,
};
//* @enum
enum {
/** The Particle emitter lives forever */
DURATION_INFINITY = -1,
/** The starting size of the particle is equal to the ending size */
START_SIZE_EQUAL_TO_END_SIZE = -1,
/** The starting radius of the particle is equal to the ending radius */
START_RADIUS_EQUAL_TO_END_RADIUS = -1,
};
/** creates an initializes a ParticleSystem from a plist file. /** creates an initializes a ParticleSystem from a plist file.
This plist files can be created manually or with Particle Designer: This plist files can be created manually or with Particle Designer:
http://particledesigner.71squared.com/ http://particledesigner.71squared.com/
@ -371,8 +367,8 @@ public:
/** particles movement type: Free or Grouped /** particles movement type: Free or Grouped
@since v0.8 @since v0.8
*/ */
inline tPositionType getPositionType() const { return _positionType; }; inline PositionType getPositionType() const { return _positionType; };
inline void setPositionType(tPositionType type) { _positionType = type; }; inline void setPositionType(PositionType type) { _positionType = type; };
// Overrides // Overrides
virtual void update(float dt) override; virtual void update(float dt) override;
@ -531,7 +527,7 @@ protected:
/** particles movement type: Free or Grouped /** particles movement type: Free or Grouped
@since v0.8 @since v0.8
*/ */
tPositionType _positionType; PositionType _positionType;
}; };
// end of particle_nodes group // end of particle_nodes group

View File

@ -63,7 +63,7 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
setupVBO(); setupVBO();
#endif #endif
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO // Need to listen the event only when not use batchnode, because it will use VBO
@ -378,15 +378,15 @@ void ParticleSystemQuad::draw()
#define kQuadSize sizeof(_quads[0].bl) #define kQuadSize sizeof(_quads[0].bl)
ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
// vertices // vertices
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
// colors // colors
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
// tex coords // tex coords
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
@ -487,16 +487,16 @@ void ParticleSystemQuad::setupVBOandVAO()
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW);
// vertices // vertices
glEnableVertexAttribArray(kVertexAttrib_Position); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
// colors // colors
glEnableVertexAttribArray(kVertexAttrib_Color); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
// tex coords // tex coords
glEnableVertexAttribArray(kVertexAttrib_TexCoords); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW);

View File

@ -50,15 +50,15 @@ public:
Image(); Image();
virtual ~Image(); virtual ~Image();
typedef enum enum Format
{ {
kFmtJpg = 0, FORMAT_JPG,
kFmtPng, FORMAT_PNG,
kFmtTiff, FORMAT_TIFF,
kFmtWebp, FORMAT_WEBP,
kFmtRawData, FORMAT_RAW_DATA,
kFmtUnKnown FORMAT_UNKOWN
}EImageFormat; };
typedef enum typedef enum
{ {
@ -79,7 +79,7 @@ public:
@param imageType the type of image, currently only supporting two types. @param imageType the type of image, currently only supporting two types.
@return true if loaded correctly. @return true if loaded correctly.
*/ */
bool initWithImageFile(const char * strPath, EImageFormat imageType = kFmtPng); bool initWithImageFile(const char * strPath, Format imageType = FORMAT_PNG);
/** /**
@brief Load image from stream buffer. @brief Load image from stream buffer.
@ -92,7 +92,7 @@ public:
*/ */
bool initWithImageData(void * pData, bool initWithImageData(void * pData,
int nDataLen, int nDataLen,
EImageFormat eFmt = kFmtUnKnown, Format eFmt = FORMAT_UNKOWN,
int nWidth = 0, int nWidth = 0,
int nHeight = 0, int nHeight = 0,
int nBitsPerComponent = 8); int nBitsPerComponent = 8);
@ -194,7 +194,7 @@ private:
@param imageType the type of image, currently only supporting two types. @param imageType the type of image, currently only supporting two types.
@return true if loaded correctly. @return true if loaded correctly.
*/ */
bool initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType = kFmtPng); bool initWithImageFileThreadSafe(const char *fullpath, Format imageType = FORMAT_PNG);
}; };
// end of platform group // end of platform group

View File

@ -91,7 +91,7 @@ Image::~Image()
CC_SAFE_DELETE_ARRAY(_data); CC_SAFE_DELETE_ARRAY(_data);
} }
bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/)
{ {
bool bRet = false; bool bRet = false;
@ -128,7 +128,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
return bRet; return bRet;
} }
bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType)
{ {
bool bRet = false; bool bRet = false;
unsigned long nSize = 0; unsigned long nSize = 0;
@ -148,7 +148,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image
bool Image::initWithImageData(void * pData, bool Image::initWithImageData(void * pData,
int nDataLen, int nDataLen,
EImageFormat eFmt/* = eSrcFmtPng*/, Format eFmt/* = eSrcFmtPng*/,
int nWidth/* = 0*/, int nWidth/* = 0*/,
int nHeight/* = 0*/, int nHeight/* = 0*/,
int nBitsPerComponent/* = 8*/) int nBitsPerComponent/* = 8*/)
@ -158,27 +158,27 @@ bool Image::initWithImageData(void * pData,
{ {
CC_BREAK_IF(! pData || nDataLen <= 0); CC_BREAK_IF(! pData || nDataLen <= 0);
if (kFmtPng == eFmt) if (FORMAT_PNG == eFmt)
{ {
bRet = _initWithPngData(pData, nDataLen); bRet = _initWithPngData(pData, nDataLen);
break; break;
} }
else if (kFmtJpg == eFmt) else if (FORMAT_JPG == eFmt)
{ {
bRet = _initWithJpgData(pData, nDataLen); bRet = _initWithJpgData(pData, nDataLen);
break; break;
} }
else if (kFmtTiff == eFmt) else if (FORMAT_TIFF == eFmt)
{ {
bRet = _initWithTiffData(pData, nDataLen); bRet = _initWithTiffData(pData, nDataLen);
break; break;
} }
else if (kFmtWebp == eFmt) else if (FORMAT_WEBP == eFmt)
{ {
bRet = _initWithWebpData(pData, nDataLen); bRet = _initWithWebpData(pData, nDataLen);
break; break;
} }
else if (kFmtRawData == eFmt) else if (FORMAT_RAW_DATA == eFmt)
{ {
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false); bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
break; break;

View File

@ -416,7 +416,7 @@ Image::~Image()
CC_SAFE_DELETE_ARRAY(_data); CC_SAFE_DELETE_ARRAY(_data);
} }
bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/)
{ {
bool bRet = false; bool bRet = false;
unsigned long nSize = 0; unsigned long nSize = 0;
@ -433,7 +433,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
return bRet; return bRet;
} }
bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType)
{ {
/* /*
* FileUtils::fullPathFromRelativePath() is not thread-safe. * FileUtils::fullPathFromRelativePath() is not thread-safe.
@ -451,7 +451,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image
bool Image::initWithImageData(void * pData, bool Image::initWithImageData(void * pData,
int nDataLen, int nDataLen,
EImageFormat eFmt, Format eFmt,
int nWidth, int nWidth,
int nHeight, int nHeight,
int nBitsPerComponent) int nBitsPerComponent)
@ -465,11 +465,11 @@ bool Image::initWithImageData(void * pData,
do do
{ {
CC_BREAK_IF(! pData || nDataLen <= 0); CC_BREAK_IF(! pData || nDataLen <= 0);
if (eFmt == kFmtRawData) if (eFmt == FORMAT_RAW_DATA)
{ {
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false); bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
} }
else if (eFmt == kFmtWebp) else if (eFmt == FORMAT_WEBP)
{ {
bRet = _initWithWebpData(pData, nDataLen); bRet = _initWithWebpData(pData, nDataLen);
} }

View File

@ -68,7 +68,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
bool hasAlpha; bool hasAlpha;
CGImageAlphaInfo info; CGImageAlphaInfo info;
CGSize imageSize; CGSize imageSize;
Texture2DPixelFormat pixelFormat; Texture2D::PixelFormat pixelFormat;
info = CGImageGetAlphaInfo(image); info = CGImageGetAlphaInfo(image);
hasAlpha = ((info == kCGImageAlphaPremultipliedLast) || (info == kCGImageAlphaPremultipliedFirst) || (info == kCGImageAlphaLast) || (info == kCGImageAlphaFirst) ? YES : NO); hasAlpha = ((info == kCGImageAlphaPremultipliedLast) || (info == kCGImageAlphaPremultipliedFirst) || (info == kCGImageAlphaLast) || (info == kCGImageAlphaFirst) ? YES : NO);
@ -80,17 +80,17 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
{ {
if(hasAlpha || bpp >= 8) if(hasAlpha || bpp >= 8)
{ {
pixelFormat = kTexture2DPixelFormat_Default; pixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
} }
else else
{ {
pixelFormat = kTexture2DPixelFormat_RGB565; pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
} }
} }
else else
{ {
// NOTE: No colorspace means a mask image // NOTE: No colorspace means a mask image
pixelFormat = kTexture2DPixelFormat_A8; pixelFormat = Texture2D::PIXEL_FORMAT_A8;
} }
imageSize.width = CGImageGetWidth(image); imageSize.width = CGImageGetWidth(image);
@ -100,9 +100,9 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
switch(pixelFormat) switch(pixelFormat)
{ {
case kTexture2DPixelFormat_RGBA8888: case Texture2D::PIXEL_FORMAT_RGBA8888:
case kTexture2DPixelFormat_RGBA4444: case Texture2D::PIXEL_FORMAT_RGBA4444:
case kTexture2DPixelFormat_RGB5A1: case Texture2D::PIXEL_FORMAT_RGB5A1:
colorSpace = CGColorSpaceCreateDeviceRGB(); colorSpace = CGColorSpaceCreateDeviceRGB();
data = new unsigned char[POTHigh * POTWide * 4]; data = new unsigned char[POTHigh * POTWide * 4];
info = hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast; info = hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast;
@ -110,14 +110,14 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
CGColorSpaceRelease(colorSpace); CGColorSpaceRelease(colorSpace);
break; break;
case kTexture2DPixelFormat_RGB565: case Texture2D::PIXEL_FORMAT_RGB565:
colorSpace = CGColorSpaceCreateDeviceRGB(); colorSpace = CGColorSpaceCreateDeviceRGB();
data = new unsigned char[POTHigh * POTWide * 4]; data = new unsigned char[POTHigh * POTWide * 4];
info = kCGImageAlphaNoneSkipLast; info = kCGImageAlphaNoneSkipLast;
context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big); context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace); CGColorSpaceRelease(colorSpace);
break; break;
case kTexture2DPixelFormat_A8: case Texture2D::PIXEL_FORMAT_A8:
data = new unsigned char[POTHigh * POTWide]; data = new unsigned char[POTHigh * POTWide];
info = kCGImageAlphaOnly; info = kCGImageAlphaOnly;
context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info); context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
@ -138,7 +138,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
// Repack the pixel data into the right format // Repack the pixel data into the right format
if(pixelFormat == kTexture2DPixelFormat_RGB565) if(pixelFormat == Texture2D::PIXEL_FORMAT_RGB565)
{ {
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB" //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
tempData = new unsigned char[POTHigh * POTWide * 2]; tempData = new unsigned char[POTHigh * POTWide * 2];
@ -153,7 +153,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
data = tempData; data = tempData;
} }
else if (pixelFormat == kTexture2DPixelFormat_RGBA4444) else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444)
{ {
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
tempData = new unsigned char[POTHigh * POTWide * 2]; tempData = new unsigned char[POTHigh * POTWide * 2];
@ -172,7 +172,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
data = tempData; data = tempData;
} }
else if (pixelFormat == kTexture2DPixelFormat_RGB5A1) else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1)
{ {
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA" //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
tempData = new unsigned char[POTHigh * POTWide * 2]; tempData = new unsigned char[POTHigh * POTWide * 2];
@ -542,7 +542,7 @@ Image::~Image()
CC_SAFE_DELETE_ARRAY(_data); CC_SAFE_DELETE_ARRAY(_data);
} }
bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/)
{ {
std::string strTemp = FileUtils::getInstance()->fullPathForFilename(strPath); std::string strTemp = FileUtils::getInstance()->fullPathForFilename(strPath);
if (_enabledScale) if (_enabledScale)
@ -585,7 +585,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
return ret; return ret;
} }
bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType)
{ {
/* /*
* FileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease(). * FileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease().
@ -612,7 +612,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
unsigned int* inPixel32 = NULL; unsigned int* inPixel32 = NULL;
unsigned short* outPixel16 = NULL; unsigned short* outPixel16 = NULL;
bool hasAlpha; bool hasAlpha;
Texture2DPixelFormat pixelFormat; Texture2D::PixelFormat pixelFormat;
hasAlpha = this->hasAlpha(); hasAlpha = this->hasAlpha();
@ -627,21 +627,21 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
{ {
if (bpp >= 8) if (bpp >= 8)
{ {
pixelFormat = kTexture2DPixelFormat_RGB888; pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
} }
else else
{ {
CCLOG("cocos2d: Texture2D: Using RGB565 texture since image has no alpha"); CCLOG("cocos2d: Texture2D: Using RGB565 texture since image has no alpha");
pixelFormat = kTexture2DPixelFormat_RGB565; pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
} }
} }
switch(pixelFormat) { switch(pixelFormat) {
case kTexture2DPixelFormat_RGBA8888: case Texture2D::PIXEL_FORMAT_RGBA8888:
case kTexture2DPixelFormat_RGBA4444: case Texture2D::PIXEL_FORMAT_RGBA4444:
case kTexture2DPixelFormat_RGB5A1: case Texture2D::PIXEL_FORMAT_RGB5A1:
case kTexture2DPixelFormat_RGB565: case Texture2D::PIXEL_FORMAT_RGB565:
case kTexture2DPixelFormat_A8: case Texture2D::PIXEL_FORMAT_A8:
tempData = (unsigned char*)(this->getData()); tempData = (unsigned char*)(this->getData());
CCASSERT(tempData != NULL, "NULL image data."); CCASSERT(tempData != NULL, "NULL image data.");
@ -666,7 +666,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
} }
break; break;
case kTexture2DPixelFormat_RGB888: case Texture2D::PIXEL_FORMAT_RGB888:
tempData = (unsigned char*)(this->getData()); tempData = (unsigned char*)(this->getData());
CCASSERT(tempData != NULL, "NULL image data."); CCASSERT(tempData != NULL, "NULL image data.");
if(this->getWidth() == (short)POTWide && this->getHeight() == (short)POTHigh) if(this->getWidth() == (short)POTWide && this->getHeight() == (short)POTHigh)
@ -695,7 +695,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
// Repack the pixel data into the right format // Repack the pixel data into the right format
if(pixelFormat == kTexture2DPixelFormat_RGB565) { if(pixelFormat == Texture2D::PIXEL_FORMAT_RGB565) {
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB" //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
tempData = new unsigned char[POTHigh * POTWide * 2]; tempData = new unsigned char[POTHigh * POTWide * 2];
inPixel32 = (unsigned int*)data; inPixel32 = (unsigned int*)data;
@ -713,7 +713,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
delete [] data; delete [] data;
data = tempData; data = tempData;
} }
else if (pixelFormat == kTexture2DPixelFormat_RGBA4444) { else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444) {
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
tempData = new unsigned char[POTHigh * POTWide * 2]; tempData = new unsigned char[POTHigh * POTWide * 2];
inPixel32 = (unsigned int*)data; inPixel32 = (unsigned int*)data;
@ -732,7 +732,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
delete [] data; delete [] data;
data = tempData; data = tempData;
} }
else if (pixelFormat == kTexture2DPixelFormat_RGB5A1) { else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1) {
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA" //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
tempData = new unsigned char[POTHigh * POTWide * 2]; tempData = new unsigned char[POTHigh * POTWide * 2];
inPixel32 = (unsigned int*)data; inPixel32 = (unsigned int*)data;
@ -751,10 +751,10 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
delete []data; delete []data;
data = tempData; data = tempData;
} }
else if (pixelFormat == kTexture2DPixelFormat_A8) else if (pixelFormat == Texture2D::PIXEL_FORMAT_A8)
{ {
// fix me, how to convert to A8 // fix me, how to convert to A8
pixelFormat = kTexture2DPixelFormat_RGBA8888; pixelFormat = Texture2D::PIXEL_FORMAT_RGBA8888;
// //
//The code can not work, how to convert to A8? //The code can not work, how to convert to A8?
@ -786,7 +786,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
//bool Image::initWithImageData(void * pData, int nDataLen, EImageFormat eFmt/* = eSrcFmtPng*/) //bool Image::initWithImageData(void * pData, int nDataLen, EImageFormat eFmt/* = eSrcFmtPng*/)
bool Image::initWithImageData(void * pData, bool Image::initWithImageData(void * pData,
int nDataLen, int nDataLen,
EImageFormat eFmt, Format eFmt,
int nWidth, int nWidth,
int nHeight, int nHeight,
int nBitsPerComponent) int nBitsPerComponent)
@ -797,11 +797,11 @@ bool Image::initWithImageData(void * pData,
{ {
CC_BREAK_IF(! pData || nDataLen <= 0); CC_BREAK_IF(! pData || nDataLen <= 0);
if (eFmt == kFmtRawData) if (eFmt == FORMAT_RAW_DATA)
{ {
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false); bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
} }
else if (eFmt == Image::kFmtWebp) else if (eFmt == Image::FORMAT_WEBP)
{ {
bRet = _initWithWebpData(pData, nDataLen); bRet = _initWithWebpData(pData, nDataLen);
} }
@ -813,7 +813,7 @@ bool Image::initWithImageData(void * pData,
_height = (short)info.height; _height = (short)info.height;
_width = (short)info.width; _width = (short)info.width;
_bitsPerComponent = info.bitsPerComponent; _bitsPerComponent = info.bitsPerComponent;
if (eFmt == kFmtJpg) if (eFmt == FORMAT_JPG)
{ {
_hasAlpha = true; _hasAlpha = true;
_preMulti = false; _preMulti = false;

View File

@ -136,7 +136,8 @@ SOURCES = ../actions/CCAction.cpp \
../CCScheduler.cpp \ ../CCScheduler.cpp \
../ccFPSImages.c \ ../ccFPSImages.c \
../ccTypes.cpp \ ../ccTypes.cpp \
../cocos2d.cpp ../cocos2d.cpp \
../CCDeprecated.cpp
COCOS_ROOT = ../.. COCOS_ROOT = ../..

View File

@ -130,7 +130,8 @@ SOURCES = ../actions/CCAction.cpp \
../CCScheduler.cpp \ ../CCScheduler.cpp \
../ccFPSImages.c \ ../ccFPSImages.c \
../ccTypes.cpp \ ../ccTypes.cpp \
../cocos2d.cpp ../cocos2d.cpp \
../CCDeprecated.cpp
include cocos2dx.mk include cocos2dx.mk

View File

@ -45,6 +45,31 @@ typedef struct _hashUniformEntry
UT_hash_handle hh; // hash entry UT_hash_handle hh; // hash entry
} tHashUniformEntry; } tHashUniformEntry;
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest";
const char* GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR = "ShaderPositionTextureA8Color";
const char* GLProgram::SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor";
const char* GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR = "ShaderPositionLengthTextureColor";
// uniform names
const char* GLProgram::UNIFORM_NAME_P_MATRIX = "CC_PMatrix";
const char* GLProgram::UNIFORM_NAME_MV_MATRIX = "CC_MVMatrix";
const char* GLProgram::UNIFORM_NAME_MVP_MATRIX = "CC_MVPMatrix";
const char* GLProgram::UNIFORM_NAME_TIME = "CC_Time";
const char* GLProgram::UNIFORM_NAME_SIN_TIME = "CC_SinTime";
const char* GLProgram::UNIFORM_NAME_COS_TIME = "CC_CosTime";
const char* GLProgram::UNIFORM_NAME_RANDOM01 = "CC_Random01";
const char* GLProgram::UNIFORM_NAME_SAMPLER = "CC_Texture0";
const char* GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE = "CC_alpha_value";
// Attribute names
const char* GLProgram::ATTRIBUTE_NAME_COLOR = "a_color";
const char* GLProgram::ATTRIBUTE_NAME_POSITION = "a_position";
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
GLProgram::GLProgram() GLProgram::GLProgram()
: _program(0) : _program(0)
, _vertShader(0) , _vertShader(0)
@ -197,28 +222,28 @@ void GLProgram::addAttribute(const char* attributeName, GLuint index)
void GLProgram::updateUniforms() void GLProgram::updateUniforms()
{ {
_uniforms[kUniformPMatrix] = glGetUniformLocation(_program, kUniformPMatrix_s); _uniforms[UNIFORM_P_MATRIX] = glGetUniformLocation(_program, UNIFORM_NAME_P_MATRIX);
_uniforms[kUniformMVMatrix] = glGetUniformLocation(_program, kUniformMVMatrix_s); _uniforms[UNIFORM_MV_MATRIX] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_MV_MATRIX);
_uniforms[kUniformMVPMatrix] = glGetUniformLocation(_program, kUniformMVPMatrix_s); _uniforms[UNIFORM_MVP_MATRIX] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_MVP_MATRIX);
_uniforms[kUniformTime] = glGetUniformLocation(_program, kUniformTime_s); _uniforms[GLProgram::UNIFORM_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_TIME);
_uniforms[kUniformSinTime] = glGetUniformLocation(_program, kUniformSinTime_s); _uniforms[GLProgram::UNIFORM_SIN_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_SIN_TIME);
_uniforms[kUniformCosTime] = glGetUniformLocation(_program, kUniformCosTime_s); _uniforms[GLProgram::UNIFORM_COS_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_COS_TIME);
_usesTime = ( _usesTime = (
_uniforms[kUniformTime] != -1 || _uniforms[GLProgram::UNIFORM_TIME] != -1 ||
_uniforms[kUniformSinTime] != -1 || _uniforms[GLProgram::UNIFORM_SIN_TIME] != -1 ||
_uniforms[kUniformCosTime] != -1 _uniforms[GLProgram::UNIFORM_COS_TIME] != -1
); );
_uniforms[kUniformRandom01] = glGetUniformLocation(_program, kUniformRandom01_s); _uniforms[UNIFORM_RANDOM01] = glGetUniformLocation(_program, UNIFORM_NAME_RANDOM01);
_uniforms[kUniformSampler] = glGetUniformLocation(_program, kUniformSampler_s); _uniforms[UNIFORM_SAMPLER] = glGetUniformLocation(_program, UNIFORM_NAME_SAMPLER);
this->use(); this->use();
// Since sample most probably won't change, set it to 0 now. // Since sample most probably won't change, set it to 0 now.
this->setUniformLocationWith1i(_uniforms[kUniformSampler], 0); this->setUniformLocationWith1i(_uniforms[GLProgram::UNIFORM_SAMPLER], 0);
} }
bool GLProgram::link() bool GLProgram::link()
@ -509,9 +534,9 @@ void GLProgram::setUniformsForBuiltins()
kmMat4Multiply(&matrixMVP, &matrixP, &matrixMV); kmMat4Multiply(&matrixMVP, &matrixP, &matrixMV);
setUniformLocationWithMatrix4fv(_uniforms[kUniformPMatrix], matrixP.mat, 1); setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_P_MATRIX], matrixP.mat, 1);
setUniformLocationWithMatrix4fv(_uniforms[kUniformMVMatrix], matrixMV.mat, 1); setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MV_MATRIX], matrixMV.mat, 1);
setUniformLocationWithMatrix4fv(_uniforms[kUniformMVPMatrix], matrixMVP.mat, 1); setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MVP_MATRIX], matrixMVP.mat, 1);
if(_usesTime) if(_usesTime)
{ {
@ -521,14 +546,14 @@ void GLProgram::setUniformsForBuiltins()
// Getting Mach time per frame per shader using time could be extremely expensive. // Getting Mach time per frame per shader using time could be extremely expensive.
float time = director->getTotalFrames() * director->getAnimationInterval(); float time = director->getTotalFrames() * director->getAnimationInterval();
setUniformLocationWith4f(_uniforms[kUniformTime], time/10.0, time, time*2, time*4); setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_TIME], time/10.0, time, time*2, time*4);
setUniformLocationWith4f(_uniforms[kUniformSinTime], time/8.0, time/4.0, time/2.0, sinf(time)); setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_SIN_TIME], time/8.0, time/4.0, time/2.0, sinf(time));
setUniformLocationWith4f(_uniforms[kUniformCosTime], time/8.0, time/4.0, time/2.0, cosf(time)); setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_COS_TIME], time/8.0, time/4.0, time/2.0, cosf(time));
} }
if (_uniforms[kUniformRandom01] != -1) if (_uniforms[GLProgram::UNIFORM_RANDOM01] != -1)
{ {
setUniformLocationWith4f(_uniforms[kUniformRandom01], CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_RANDOM01], CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1());
} }
} }

View File

@ -40,52 +40,6 @@ NS_CC_BEGIN
* @{ * @{
*/ */
enum {
kVertexAttrib_Position,
kVertexAttrib_Color,
kVertexAttrib_TexCoords,
kVertexAttrib_MAX,
};
enum {
kUniformPMatrix,
kUniformMVMatrix,
kUniformMVPMatrix,
kUniformTime,
kUniformSinTime,
kUniformCosTime,
kUniformRandom01,
kUniformSampler,
kUniform_MAX,
};
#define kShader_PositionTextureColor "ShaderPositionTextureColor"
#define kShader_PositionTextureColorAlphaTest "ShaderPositionTextureColorAlphaTest"
#define kShader_PositionColor "ShaderPositionColor"
#define kShader_PositionTexture "ShaderPositionTexture"
#define kShader_PositionTexture_uColor "ShaderPositionTexture_uColor"
#define kShader_PositionTextureA8Color "ShaderPositionTextureA8Color"
#define kShader_Position_uColor "ShaderPosition_uColor"
#define kShader_PositionLengthTexureColor "ShaderPositionLengthTextureColor"
// uniform names
#define kUniformPMatrix_s "CC_PMatrix"
#define kUniformMVMatrix_s "CC_MVMatrix"
#define kUniformMVPMatrix_s "CC_MVPMatrix"
#define kUniformTime_s "CC_Time"
#define kUniformSinTime_s "CC_SinTime"
#define kUniformCosTime_s "CC_CosTime"
#define kUniformRandom01_s "CC_Random01"
#define kUniformSampler_s "CC_Texture0"
#define kUniformAlphaTestValue "CC_alpha_value"
// Attribute names
#define kAttributeNameColor "a_color"
#define kAttributeNamePosition "a_position"
#define kAttributeNameTexCoord "a_texCoord"
struct _hashUniformEntry; struct _hashUniformEntry;
typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params);
@ -100,6 +54,54 @@ typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length,
class CC_DLL GLProgram : public Object class CC_DLL GLProgram : public Object
{ {
public: public:
enum
{
VERTEX_ATTRIB_POSITION,
VERTEX_ATTRIB_COLOR,
VERTEX_ATTRIB_TEX_COORDS,
VERTEX_ATTRIB_MAX,
};
enum
{
UNIFORM_P_MATRIX,
UNIFORM_MV_MATRIX,
UNIFORM_MVP_MATRIX,
UNIFORM_TIME,
UNIFORM_SIN_TIME,
UNIFORM_COS_TIME,
UNIFORM_RANDOM01,
UNIFORM_SAMPLER,
UNIFORM_MAX,
};
static const char* SHADER_NAME_POSITION_TEXTURE_COLOR;
static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST;
static const char* SHADER_NAME_POSITION_COLOR;
static const char* SHADER_NAME_POSITION_TEXTURE;
static const char* SHADER_NAME_POSITION_TEXTURE_U_COLOR;
static const char* SHADER_NAME_POSITION_TEXTURE_A8_COLOR;
static const char* SHADER_NAME_POSITION_U_COLOR;
static const char* SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR;
// uniform names
static const char* UNIFORM_NAME_P_MATRIX;
static const char* UNIFORM_NAME_MV_MATRIX;
static const char* UNIFORM_NAME_MVP_MATRIX;
static const char* UNIFORM_NAME_TIME;
static const char* UNIFORM_NAME_SIN_TIME;
static const char* UNIFORM_NAME_COS_TIME;
static const char* UNIFORM_NAME_RANDOM01;
static const char* UNIFORM_NAME_SAMPLER;
static const char* UNIFORM_NAME_ALPHA_TEST_VALUE;
// Attribute names
static const char* ATTRIBUTE_NAME_COLOR;
static const char* ATTRIBUTE_NAME_POSITION;
static const char* ATTRIBUTE_NAME_TEX_COORD;
GLProgram(); GLProgram();
virtual ~GLProgram(); virtual ~GLProgram();
/** Initializes the GLProgram with a vertex and fragment with bytes array */ /** Initializes the GLProgram with a vertex and fragment with bytes array */
@ -116,9 +118,9 @@ public:
- kUniformPMatrix - kUniformPMatrix
- kUniformMVMatrix - kUniformMVMatrix
- kUniformMVPMatrix - kUniformMVPMatrix
- kUniformSampler - GLProgram::UNIFORM_SAMPLER
And it will bind "kUniformSampler" to 0 And it will bind "GLProgram::UNIFORM_SAMPLER" to 0
*/ */
void updateUniforms(); void updateUniforms();
@ -198,7 +200,7 @@ private:
GLuint _program; GLuint _program;
GLuint _vertShader; GLuint _vertShader;
GLuint _fragShader; GLuint _fragShader;
GLint _uniforms[kUniform_MAX]; GLint _uniforms[UNIFORM_MAX];
struct _hashUniformEntry* _hashForUniforms; struct _hashUniformEntry* _hashForUniforms;
bool _usesTime; bool _usesTime;
}; };

View File

@ -100,14 +100,14 @@ void ShaderCache::loadDefaultShaders()
GLProgram *p = new GLProgram(); GLProgram *p = new GLProgram();
loadDefaultShader(p, kShaderType_PositionTextureColor); loadDefaultShader(p, kShaderType_PositionTextureColor);
_programs->setObject(p, kShader_PositionTextureColor); _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR);
p->release(); p->release();
// Position Texture Color alpha test // Position Texture Color alpha test
p = new GLProgram(); p = new GLProgram();
loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest);
_programs->setObject(p, kShader_PositionTextureColorAlphaTest); _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
p->release(); p->release();
// //
@ -116,7 +116,7 @@ void ShaderCache::loadDefaultShaders()
p = new GLProgram(); p = new GLProgram();
loadDefaultShader(p, kShaderType_PositionColor); loadDefaultShader(p, kShaderType_PositionColor);
_programs->setObject(p, kShader_PositionColor); _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_COLOR);
p->release(); p->release();
// //
@ -125,7 +125,7 @@ void ShaderCache::loadDefaultShaders()
p = new GLProgram(); p = new GLProgram();
loadDefaultShader(p, kShaderType_PositionTexture); loadDefaultShader(p, kShaderType_PositionTexture);
_programs->setObject(p, kShader_PositionTexture); _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE);
p->release(); p->release();
// //
@ -134,7 +134,7 @@ void ShaderCache::loadDefaultShaders()
p = new GLProgram(); p = new GLProgram();
loadDefaultShader(p, kShaderType_PositionTexture_uColor); loadDefaultShader(p, kShaderType_PositionTexture_uColor);
_programs->setObject(p ,kShader_PositionTexture_uColor); _programs->setObject(p ,GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR);
p->release(); p->release();
// //
@ -143,7 +143,7 @@ void ShaderCache::loadDefaultShaders()
p = new GLProgram(); p = new GLProgram();
loadDefaultShader(p, kShaderType_PositionTextureA8Color); loadDefaultShader(p, kShaderType_PositionTextureA8Color);
_programs->setObject(p, kShader_PositionTextureA8Color); _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR);
p->release(); p->release();
// //
@ -152,7 +152,7 @@ void ShaderCache::loadDefaultShaders()
p = new GLProgram(); p = new GLProgram();
loadDefaultShader(p, kShaderType_Position_uColor); loadDefaultShader(p, kShaderType_Position_uColor);
_programs->setObject(p, kShader_Position_uColor); _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_U_COLOR);
p->release(); p->release();
// //
@ -161,7 +161,7 @@ void ShaderCache::loadDefaultShaders()
p = new GLProgram(); p = new GLProgram();
loadDefaultShader(p, kShaderType_PositionLengthTexureColor); loadDefaultShader(p, kShaderType_PositionLengthTexureColor);
_programs->setObject(p, kShader_PositionLengthTexureColor); _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR);
p->release(); p->release();
} }
@ -170,54 +170,54 @@ void ShaderCache::reloadDefaultShaders()
// reset all programs and reload them // reset all programs and reload them
// Position Texture Color shader // Position Texture Color shader
GLProgram *p = programForKey(kShader_PositionTextureColor); GLProgram *p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_PositionTextureColor); loadDefaultShader(p, kShaderType_PositionTextureColor);
// Position Texture Color alpha test // Position Texture Color alpha test
p = programForKey(kShader_PositionTextureColorAlphaTest); p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest);
// //
// Position, Color shader // Position, Color shader
// //
p = programForKey(kShader_PositionColor); p = programForKey(GLProgram::SHADER_NAME_POSITION_COLOR);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_PositionColor); loadDefaultShader(p, kShaderType_PositionColor);
// //
// Position Texture shader // Position Texture shader
// //
p = programForKey(kShader_PositionTexture); p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_PositionTexture); loadDefaultShader(p, kShaderType_PositionTexture);
// //
// Position, Texture attribs, 1 Color as uniform shader // Position, Texture attribs, 1 Color as uniform shader
// //
p = programForKey(kShader_PositionTexture_uColor); p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_PositionTexture_uColor); loadDefaultShader(p, kShaderType_PositionTexture_uColor);
// //
// Position Texture A8 Color shader // Position Texture A8 Color shader
// //
p = programForKey(kShader_PositionTextureA8Color); p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_PositionTextureA8Color); loadDefaultShader(p, kShaderType_PositionTextureA8Color);
// //
// Position and 1 color passed as a uniform (to simulate glColor4ub ) // Position and 1 color passed as a uniform (to simulate glColor4ub )
// //
p = programForKey(kShader_Position_uColor); p = programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_Position_uColor); loadDefaultShader(p, kShaderType_Position_uColor);
// //
// Position, Legth(TexCoords, Color (used by Draw Node basically ) // Position, Legth(TexCoords, Color (used by Draw Node basically )
// //
p = programForKey(kShader_PositionLengthTexureColor); p = programForKey(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR);
p->reset(); p->reset();
loadDefaultShader(p, kShaderType_PositionLengthTexureColor); loadDefaultShader(p, kShaderType_PositionLengthTexureColor);
} }
@ -228,60 +228,60 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type)
case kShaderType_PositionTextureColor: case kShaderType_PositionTextureColor:
p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColor_frag); p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColor_frag);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
break; break;
case kShaderType_PositionTextureColorAlphaTest: case kShaderType_PositionTextureColorAlphaTest:
p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag); p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
break; break;
case kShaderType_PositionColor: case kShaderType_PositionColor:
p->initWithVertexShaderByteArray(ccPositionColor_vert ,ccPositionColor_frag); p->initWithVertexShaderByteArray(ccPositionColor_vert ,ccPositionColor_frag);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
break; break;
case kShaderType_PositionTexture: case kShaderType_PositionTexture:
p->initWithVertexShaderByteArray(ccPositionTexture_vert ,ccPositionTexture_frag); p->initWithVertexShaderByteArray(ccPositionTexture_vert ,ccPositionTexture_frag);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
break; break;
case kShaderType_PositionTexture_uColor: case kShaderType_PositionTexture_uColor:
p->initWithVertexShaderByteArray(ccPositionTexture_uColor_vert, ccPositionTexture_uColor_frag); p->initWithVertexShaderByteArray(ccPositionTexture_uColor_vert, ccPositionTexture_uColor_frag);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
break; break;
case kShaderType_PositionTextureA8Color: case kShaderType_PositionTextureA8Color:
p->initWithVertexShaderByteArray(ccPositionTextureA8Color_vert, ccPositionTextureA8Color_frag); p->initWithVertexShaderByteArray(ccPositionTextureA8Color_vert, ccPositionTextureA8Color_frag);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
break; break;
case kShaderType_Position_uColor: case kShaderType_Position_uColor:
p->initWithVertexShaderByteArray(ccPosition_uColor_vert, ccPosition_uColor_frag); p->initWithVertexShaderByteArray(ccPosition_uColor_vert, ccPosition_uColor_frag);
p->addAttribute("aVertex", kVertexAttrib_Position); p->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION);
break; break;
case kShaderType_PositionLengthTexureColor: case kShaderType_PositionLengthTexureColor:
p->initWithVertexShaderByteArray(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag); p->initWithVertexShaderByteArray(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
break; break;
default: default:

View File

@ -232,37 +232,37 @@ void ccGLEnableVertexAttribs( unsigned int flags )
ccGLBindVAO(0); ccGLBindVAO(0);
/* Position */ /* Position */
bool enablePosition = flags & kVertexAttribFlag_Position; bool enablePosition = flags & VERTEX_ATTRIB_FLAG_POSITION;
if( enablePosition != s_bVertexAttribPosition ) { if( enablePosition != s_bVertexAttribPosition ) {
if( enablePosition ) if( enablePosition )
glEnableVertexAttribArray( kVertexAttrib_Position ); glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION );
else else
glDisableVertexAttribArray( kVertexAttrib_Position ); glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION );
s_bVertexAttribPosition = enablePosition; s_bVertexAttribPosition = enablePosition;
} }
/* Color */ /* Color */
bool enableColor = (flags & kVertexAttribFlag_Color) != 0 ? true : false; bool enableColor = (flags & VERTEX_ATTRIB_FLAG_COLOR) != 0 ? true : false;
if( enableColor != s_bVertexAttribColor ) { if( enableColor != s_bVertexAttribColor ) {
if( enableColor ) if( enableColor )
glEnableVertexAttribArray( kVertexAttrib_Color ); glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR );
else else
glDisableVertexAttribArray( kVertexAttrib_Color ); glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR );
s_bVertexAttribColor = enableColor; s_bVertexAttribColor = enableColor;
} }
/* Tex Coords */ /* Tex Coords */
bool enableTexCoords = (flags & kVertexAttribFlag_TexCoords) != 0 ? true : false; bool enableTexCoords = (flags & VERTEX_ATTRIB_FLAG_TEX_COORDS) != 0 ? true : false;
if( enableTexCoords != s_bVertexAttribTexCoords ) { if( enableTexCoords != s_bVertexAttribTexCoords ) {
if( enableTexCoords ) if( enableTexCoords )
glEnableVertexAttribArray( kVertexAttrib_TexCoords ); glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS );
else else
glDisableVertexAttribArray( kVertexAttrib_TexCoords ); glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS );
s_bVertexAttribTexCoords = enableTexCoords; s_bVertexAttribTexCoords = enableTexCoords;
} }

View File

@ -41,13 +41,13 @@ class GLProgram;
/** vertex attrib flags */ /** vertex attrib flags */
enum { enum {
kVertexAttribFlag_None = 0, VERTEX_ATTRIB_FLAT_NONE = 0,
kVertexAttribFlag_Position = 1 << 0, VERTEX_ATTRIB_FLAG_POSITION = 1 << 0,
kVertexAttribFlag_Color = 1 << 1, VERTEX_ATTRIB_FLAG_COLOR = 1 << 1,
kVertexAttribFlag_TexCoords = 1 << 2, VERTEX_ATTRIB_FLAG_TEX_COORDS = 1 << 2,
kVertexAttribFlag_PosColorTex = ( kVertexAttribFlag_Position | kVertexAttribFlag_Color | kVertexAttribFlag_TexCoords ), VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = (VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_COLOR | VERTEX_ATTRIB_FLAG_TEX_COORDS),
}; };
/** GL server side states */ /** GL server side states */
@ -105,9 +105,9 @@ void CC_DLL ccSetProjectionMatrixDirty(void);
/** Will enable the vertex attribs that are passed as flags. /** Will enable the vertex attribs that are passed as flags.
Possible flags: Possible flags:
* kVertexAttribFlag_Position * VERTEX_ATTRIB_FLAG_POSITION
* kVertexAttribFlag_Color * VERTEX_ATTRIB_FLAG_COLOR
* kVertexAttribFlag_TexCoords * VERTEX_ATTRIB_FLAG_TEX_COORDS
These flags can be ORed. The flags that are not present, will be disabled. These flags can be ORed. The flags that are not present, will be disabled.

View File

@ -182,7 +182,7 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated
_quad.tr.colors = tmpColor; _quad.tr.colors = tmpColor;
// shader program // shader program
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
// update texture (calls updateBlendFunc) // update texture (calls updateBlendFunc)
setTexture(pTexture); setTexture(pTexture);
@ -554,7 +554,7 @@ void Sprite::draw(void)
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
ccGLBindTexture2D( _texture->getName() ); ccGLBindTexture2D( _texture->getName() );
ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
#define kQuadSize sizeof(_quad.bl) #define kQuadSize sizeof(_quad.bl)
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
@ -566,15 +566,15 @@ void Sprite::draw(void)
// vertex // vertex
int diff = offsetof( V3F_C4B_T2F, vertices); int diff = offsetof( V3F_C4B_T2F, vertices);
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
// texCoods // texCoods
diff = offsetof( V3F_C4B_T2F, texCoords); diff = offsetof( V3F_C4B_T2F, texCoords);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
// color // color
diff = offsetof( V3F_C4B_T2F, colors); diff = offsetof( V3F_C4B_T2F, colors);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -1102,7 +1102,7 @@ void Sprite::setTexture(Texture2D *texture)
if (NULL == texture) if (NULL == texture)
{ {
Image* image = new Image(); Image* image = new Image();
bool isOK = image->initWithImageData(cc_2x2_white_image, sizeof(cc_2x2_white_image), Image::kFmtRawData, 2, 2, 8); bool isOK = image->initWithImageData(cc_2x2_white_image, sizeof(cc_2x2_white_image), Image::FORMAT_RAW_DATA, 2, 2, 8);
CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully.");
texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY); texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY);

View File

@ -94,7 +94,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity)
_descendants = new Array(); _descendants = new Array();
_descendants->initWithCapacity(capacity); _descendants->initWithCapacity(capacity);
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
return true; return true;
} }

View File

@ -70,7 +70,7 @@ TextFieldTTF::~TextFieldTTF()
// static constructor // static constructor
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize) TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize)
{ {
TextFieldTTF *pRet = new TextFieldTTF(); TextFieldTTF *pRet = new TextFieldTTF();
if(pRet && pRet->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize)) if(pRet && pRet->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
@ -106,7 +106,7 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, c
// initialize // initialize
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize) bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize)
{ {
if (placeholder) if (placeholder)
{ {

View File

@ -103,11 +103,11 @@ public:
//char * description(); //char * description();
/** creates a TextFieldTTF from a fontname, alignment, dimension and font size */ /** creates a TextFieldTTF from a fontname, alignment, dimension and font size */
static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize); static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize);
/** creates a LabelTTF from a fontname and font size */ /** creates a LabelTTF from a fontname and font size */
static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize);
/** initializes the TextFieldTTF with a font name, alignment, dimension and font size */ /** initializes the TextFieldTTF with a font name, alignment, dimension and font size */
bool initWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize); bool initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize);
/** initializes the TextFieldTTF with a font name and font size */ /** initializes the TextFieldTTF with a font name and font size */
bool initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); bool initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize);

View File

@ -55,7 +55,7 @@ NS_CC_BEGIN
// If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit) // If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit)
// Default is: RGBA8888 (32-bit textures) // Default is: RGBA8888 (32-bit textures)
static Texture2DPixelFormat g_defaultAlphaPixelFormat = kTexture2DPixelFormat_Default; static Texture2D::PixelFormat g_defaultAlphaPixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
// By default PVR images are treated as if they don't have the alpha channel premultiplied // By default PVR images are treated as if they don't have the alpha channel premultiplied
static bool PVRHaveAlphaPremultiplied_ = false; static bool PVRHaveAlphaPremultiplied_ = false;
@ -64,7 +64,7 @@ Texture2D::Texture2D()
: _PVRHaveAlphaPremultiplied(true) : _PVRHaveAlphaPremultiplied(true)
, _pixelsWide(0) , _pixelsWide(0)
, _pixelsHigh(0) , _pixelsHigh(0)
, _pixelFormat(kTexture2DPixelFormat_Default) , _pixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT)
, _name(0) , _name(0)
, _maxS(0.0) , _maxS(0.0)
, _maxT(0.0) , _maxT(0.0)
@ -89,7 +89,7 @@ Texture2D::~Texture2D()
} }
} }
Texture2DPixelFormat Texture2D::getPixelFormat() const Texture2D::PixelFormat Texture2D::getPixelFormat() const
{ {
return _pixelFormat; return _pixelFormat;
} }
@ -172,11 +172,11 @@ bool Texture2D::hasPremultipliedAlpha() const
return _hasPremultipliedAlpha; return _hasPremultipliedAlpha;
} }
bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize) bool Texture2D::initWithData(const void *data, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize)
{ {
unsigned int bitsPerPixel; unsigned int bitsPerPixel;
//Hack: bitsPerPixelForFormat returns wrong number for RGB_888 textures. See function. //Hack: bitsPerPixelForFormat returns wrong number for RGB_888 textures. See function.
if(pixelFormat == kTexture2DPixelFormat_RGB888) if(pixelFormat == Texture2D::PIXEL_FORMAT_RGB888)
{ {
bitsPerPixel = 24; bitsPerPixel = 24;
} }
@ -217,28 +217,28 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat,
switch(pixelFormat) switch(pixelFormat)
{ {
case kTexture2DPixelFormat_RGBA8888: case Texture2D::PIXEL_FORMAT_RGBA8888:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
break; break;
case kTexture2DPixelFormat_RGB888: case Texture2D::PIXEL_FORMAT_RGB888:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
break; break;
case kTexture2DPixelFormat_RGBA4444: case Texture2D::PIXEL_FORMAT_RGBA4444:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);
break; break;
case kTexture2DPixelFormat_RGB5A1: case Texture2D::PIXEL_FORMAT_RGB5A1:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data);
break; break;
case kTexture2DPixelFormat_RGB565: case Texture2D::PIXEL_FORMAT_RGB565:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);
break; break;
case kTexture2DPixelFormat_AI88: case Texture2D::PIXEL_FORMAT_AI88:
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
break; break;
case kTexture2DPixelFormat_A8: case Texture2D::PIXEL_FORMAT_A8:
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
break; break;
case kTexture2DPixelFormat_I8: case Texture2D::PIXEL_FORMAT_I8:
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
break; break;
default: default:
@ -256,7 +256,7 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat,
_hasPremultipliedAlpha = false; _hasPremultipliedAlpha = false;
_hasMipmaps = false; _hasMipmaps = false;
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTexture)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE));
return true; return true;
} }
@ -301,7 +301,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
unsigned short* outPixel16 = NULL; unsigned short* outPixel16 = NULL;
bool hasAlpha = image->hasAlpha(); bool hasAlpha = image->hasAlpha();
Size imageSize = Size((float)(image->getWidth()), (float)(image->getHeight())); Size imageSize = Size((float)(image->getWidth()), (float)(image->getHeight()));
Texture2DPixelFormat pixelFormat; Texture2D::PixelFormat pixelFormat;
size_t bpp = image->getBitsPerComponent(); size_t bpp = image->getBitsPerComponent();
// compute pixel format // compute pixel format
@ -313,11 +313,11 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
{ {
if (bpp >= 8) if (bpp >= 8)
{ {
pixelFormat = kTexture2DPixelFormat_RGB888; pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
} }
else else
{ {
pixelFormat = kTexture2DPixelFormat_RGB565; pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
} }
} }
@ -325,7 +325,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
// Repack the pixel data into the right format // Repack the pixel data into the right format
unsigned int length = width * height; unsigned int length = width * height;
if (pixelFormat == kTexture2DPixelFormat_RGB565) if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB565)
{ {
if (hasAlpha) if (hasAlpha)
{ {
@ -360,7 +360,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
} }
} }
} }
else if (pixelFormat == kTexture2DPixelFormat_RGBA4444) else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444)
{ {
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
@ -377,7 +377,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
((((*inPixel32 >> 24) & 0xFF) >> 4) << 0); // A ((((*inPixel32 >> 24) & 0xFF) >> 4) << 0); // A
} }
} }
else if (pixelFormat == kTexture2DPixelFormat_RGB5A1) else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1)
{ {
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA" // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
inPixel32 = (unsigned int*)image->getData(); inPixel32 = (unsigned int*)image->getData();
@ -393,7 +393,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
((((*inPixel32 >> 24) & 0xFF) >> 7) << 0); // A ((((*inPixel32 >> 24) & 0xFF) >> 7) << 0); // A
} }
} }
else if (pixelFormat == kTexture2DPixelFormat_A8) else if (pixelFormat == Texture2D::PIXEL_FORMAT_A8)
{ {
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "AAAAAAAA" // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "AAAAAAAA"
inPixel32 = (unsigned int*)image->getData(); inPixel32 = (unsigned int*)image->getData();
@ -406,7 +406,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
} }
} }
if (hasAlpha && pixelFormat == kTexture2DPixelFormat_RGB888) if (hasAlpha && pixelFormat == Texture2D::PIXEL_FORMAT_RGB888)
{ {
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB" // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB"
inPixel32 = (unsigned int*)image->getData(); inPixel32 = (unsigned int*)image->getData();
@ -433,7 +433,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
} }
// implementation Texture2D (Text) // implementation Texture2D (Text)
bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, TextAlignment hAlignment/* = kTextAlignmentCenter */, VerticalTextAlignment vAlignment/* = kVerticalTextAlignmentTop */) bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, Label::TextAlignment hAlignment/* = Label::TEXT_ALIGNMENT_CENTER */, Label::VerticalTextAlignment vAlignment/* = Label::VERTICAL_TEXT_ALIGNMENT_TOP */)
{ {
FontDefinition tempDef; FontDefinition tempDef;
@ -461,20 +461,20 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
bool bRet = false; bool bRet = false;
Image::ETextAlign eAlign; Image::ETextAlign eAlign;
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment) if (Label::VERTICAL_TEXT_ALIGNMENT_TOP == textDefinition._vertAlignment)
{ {
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignTop
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
} }
else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment) else if (Label::VERTICAL_TEXT_ALIGNMENT_CENTER == textDefinition._vertAlignment)
{ {
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
} }
else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment) else if (Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM == textDefinition._vertAlignment)
{ {
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; : (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
} }
else else
{ {
@ -591,7 +591,7 @@ void Texture2D::drawAtPoint(const Point& point)
point.x, height + point.y, point.x, height + point.y,
width + point.x, height + point.y }; width + point.x, height + point.y };
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_TEX_COORDS );
_shaderProgram->use(); _shaderProgram->use();
_shaderProgram->setUniformsForBuiltins(); _shaderProgram->setUniformsForBuiltins();
@ -600,13 +600,13 @@ void Texture2D::drawAtPoint(const Point& point)
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); setGLBufferData(vertices, 8 * sizeof(GLfloat), 0);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -625,7 +625,7 @@ void Texture2D::drawInRect(const Rect& rect)
rect.origin.x, rect.origin.y + rect.size.height, /*0.0f,*/ rect.origin.x, rect.origin.y + rect.size.height, /*0.0f,*/
rect.origin.x + rect.size.width, rect.origin.y + rect.size.height, /*0.0f*/ }; rect.origin.x + rect.size.width, rect.origin.y + rect.size.height, /*0.0f*/ };
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_TEX_COORDS );
_shaderProgram->use(); _shaderProgram->use();
_shaderProgram->setUniformsForBuiltins(); _shaderProgram->setUniformsForBuiltins();
@ -633,13 +633,13 @@ void Texture2D::drawInRect(const Rect& rect)
#ifdef EMSCRIPTEN #ifdef EMSCRIPTEN
setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); setGLBufferData(vertices, 8 * sizeof(GLfloat), 0);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);
setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
#else #else
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates);
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
} }
@ -789,34 +789,34 @@ const char* Texture2D::getStringForFormat() const
{ {
switch (_pixelFormat) switch (_pixelFormat)
{ {
case kTexture2DPixelFormat_RGBA8888: case Texture2D::PIXEL_FORMAT_RGBA8888:
return "RGBA8888"; return "RGBA8888";
case kTexture2DPixelFormat_RGB888: case Texture2D::PIXEL_FORMAT_RGB888:
return "RGB888"; return "RGB888";
case kTexture2DPixelFormat_RGB565: case Texture2D::PIXEL_FORMAT_RGB565:
return "RGB565"; return "RGB565";
case kTexture2DPixelFormat_RGBA4444: case Texture2D::PIXEL_FORMAT_RGBA4444:
return "RGBA4444"; return "RGBA4444";
case kTexture2DPixelFormat_RGB5A1: case Texture2D::PIXEL_FORMAT_RGB5A1:
return "RGB5A1"; return "RGB5A1";
case kTexture2DPixelFormat_AI88: case Texture2D::PIXEL_FORMAT_AI88:
return "AI88"; return "AI88";
case kTexture2DPixelFormat_A8: case Texture2D::PIXEL_FORMAT_A8:
return "A8"; return "A8";
case kTexture2DPixelFormat_I8: case Texture2D::PIXEL_FORMAT_I8:
return "I8"; return "I8";
case kTexture2DPixelFormat_PVRTC4: case Texture2D::PIXEL_FORMAT_PRVTC4:
return "PVRTC4"; return "PVRTC4";
case kTexture2DPixelFormat_PVRTC2: case Texture2D::PIXEL_FORMAT_PRVTC2:
return "PVRTC2"; return "PVRTC2";
default: default:
@ -833,50 +833,50 @@ const char* Texture2D::getStringForFormat() const
// //
// implementation Texture2D (PixelFormat) // implementation Texture2D (PixelFormat)
void Texture2D::setDefaultAlphaPixelFormat(Texture2DPixelFormat format) void Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat format)
{ {
g_defaultAlphaPixelFormat = format; g_defaultAlphaPixelFormat = format;
} }
Texture2DPixelFormat Texture2D::getDefaultAlphaPixelFormat() Texture2D::PixelFormat Texture2D::getDefaultAlphaPixelFormat()
{ {
return g_defaultAlphaPixelFormat; return g_defaultAlphaPixelFormat;
} }
unsigned int Texture2D::getBitsPerPixelForFormat(Texture2DPixelFormat format) const unsigned int Texture2D::getBitsPerPixelForFormat(Texture2D::PixelFormat format) const
{ {
unsigned int ret=0; unsigned int ret=0;
switch (format) { switch (format) {
case kTexture2DPixelFormat_RGBA8888: case Texture2D::PIXEL_FORMAT_RGBA8888:
ret = 32; ret = 32;
break; break;
case kTexture2DPixelFormat_RGB888: case Texture2D::PIXEL_FORMAT_RGB888:
// It is 32 and not 24, since its internal representation uses 32 bits. // It is 32 and not 24, since its internal representation uses 32 bits.
ret = 32; ret = 32;
break; break;
case kTexture2DPixelFormat_RGB565: case Texture2D::PIXEL_FORMAT_RGB565:
ret = 16; ret = 16;
break; break;
case kTexture2DPixelFormat_RGBA4444: case Texture2D::PIXEL_FORMAT_RGBA4444:
ret = 16; ret = 16;
break; break;
case kTexture2DPixelFormat_RGB5A1: case Texture2D::PIXEL_FORMAT_RGB5A1:
ret = 16; ret = 16;
break; break;
case kTexture2DPixelFormat_AI88: case Texture2D::PIXEL_FORMAT_AI88:
ret = 16; ret = 16;
break; break;
case kTexture2DPixelFormat_A8: case Texture2D::PIXEL_FORMAT_A8:
ret = 8; ret = 8;
break; break;
case kTexture2DPixelFormat_I8: case Texture2D::PIXEL_FORMAT_I8:
ret = 8; ret = 8;
break; break;
case kTexture2DPixelFormat_PVRTC4: case Texture2D::PIXEL_FORMAT_PRVTC4:
ret = 4; ret = 4;
break; break;
case kTexture2DPixelFormat_PVRTC2: case Texture2D::PIXEL_FORMAT_PRVTC2:
ret = 2; ret = 2;
break; break;
default: default:

View File

@ -45,37 +45,6 @@ class Image;
//CONSTANTS: //CONSTANTS:
/** @typedef Texture2DPixelFormat
Possible texture pixel formats
*/
typedef enum {
//! 32-bit texture: RGBA8888
kTexture2DPixelFormat_RGBA8888,
//! 24-bit texture: RGBA888
kTexture2DPixelFormat_RGB888,
//! 16-bit texture without Alpha channel
kTexture2DPixelFormat_RGB565,
//! 8-bit textures used as masks
kTexture2DPixelFormat_A8,
//! 8-bit intensity texture
kTexture2DPixelFormat_I8,
//! 16-bit textures used as masks
kTexture2DPixelFormat_AI88,
//! 16-bit textures: RGBA4444
kTexture2DPixelFormat_RGBA4444,
//! 16-bit textures: RGB5A1
kTexture2DPixelFormat_RGB5A1,
//! 4-bit PVRTC-compressed texture: PVRTC4
kTexture2DPixelFormat_PVRTC4,
//! 2-bit PVRTC-compressed texture: PVRTC2
kTexture2DPixelFormat_PVRTC2,
//! Default texture format: RGBA8888
kTexture2DPixelFormat_Default = kTexture2DPixelFormat_RGBA8888
} Texture2DPixelFormat;
class GLProgram; class GLProgram;
/** /**
@ -102,14 +71,46 @@ class CC_DLL Texture2D : public Object
#endif // EMSCRIPTEN #endif // EMSCRIPTEN
{ {
public: public:
/** @typedef Texture2D::PixelFormat
Possible texture pixel formats
*/
enum PixelFormat
{
//! 32-bit texture: RGBA8888
PIXEL_FORMAT_RGBA8888,
//! 24-bit texture: RGBA888
PIXEL_FORMAT_RGB888,
//! 16-bit texture without Alpha channel
PIXEL_FORMAT_RGB565,
//! 8-bit textures used as masks
PIXEL_FORMAT_A8,
//! 8-bit intensity texture
PIXEL_FORMAT_I8,
//! 16-bit textures used as masks
PIXEL_FORMAT_AI88,
//! 16-bit textures: RGBA4444
PIXEL_FORMAT_RGBA4444,
//! 16-bit textures: RGB5A1
PIXEL_FORMAT_RGB5A1,
//! 4-bit PVRTC-compressed texture: PVRTC4
PIXEL_FORMAT_PRVTC4,
//! 2-bit PVRTC-compressed texture: PVRTC2
PIXEL_FORMAT_PRVTC2,
//! Default texture format: RGBA8888
PIXEL_FORMAT_DEFAULT = PIXEL_FORMAT_RGBA8888
} ;
/** sets the default pixel format for UIImagescontains alpha channel. /** sets the default pixel format for UIImagescontains alpha channel.
If the UIImage contains alpha channel, then the options are: If the UIImage contains alpha channel, then the options are:
- generate 32-bit textures: kTexture2DPixelFormat_RGBA8888 (default one) - generate 32-bit textures: Texture2D::PIXEL_FORMAT_RGBA8888 (default one)
- generate 24-bit textures: kTexture2DPixelFormat_RGB888 - generate 24-bit textures: Texture2D::PIXEL_FORMAT_RGB888
- generate 16-bit textures: kTexture2DPixelFormat_RGBA4444 - generate 16-bit textures: Texture2D::PIXEL_FORMAT_RGBA4444
- generate 16-bit textures: kTexture2DPixelFormat_RGB5A1 - generate 16-bit textures: Texture2D::PIXEL_FORMAT_RGB5A1
- generate 16-bit textures: kTexture2DPixelFormat_RGB565 - generate 16-bit textures: Texture2D::PIXEL_FORMAT_RGB565
- generate 8-bit textures: kTexture2DPixelFormat_A8 (only use it if you use just 1 color) - generate 8-bit textures: Texture2D::PIXEL_FORMAT_A8 (only use it if you use just 1 color)
How does it work ? How does it work ?
- If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture) - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture)
@ -119,13 +120,13 @@ public:
@since v0.8 @since v0.8
*/ */
static void setDefaultAlphaPixelFormat(Texture2DPixelFormat format); static void setDefaultAlphaPixelFormat(Texture2D::PixelFormat format);
/** returns the alpha pixel format /** returns the alpha pixel format
@since v0.8 @since v0.8
*/ */
static Texture2DPixelFormat getDefaultAlphaPixelFormat(); static Texture2D::PixelFormat getDefaultAlphaPixelFormat();
CC_DEPRECATED_ATTRIBUTE static Texture2DPixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); }; CC_DEPRECATED_ATTRIBUTE static Texture2D::PixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); };
/** treats (or not) PVR files as if they have alpha premultiplied. /** treats (or not) PVR files as if they have alpha premultiplied.
Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is
@ -148,7 +149,7 @@ public:
void* keepData(void *data, unsigned int length); void* keepData(void *data, unsigned int length);
/** Initializes with a texture2d with data */ /** Initializes with a texture2d with data */
bool initWithData(const void* data, Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize); bool initWithData(const void* data, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize);
/** /**
Drawing extensions to make it easy to draw basic quads using a Texture2D object. Drawing extensions to make it easy to draw basic quads using a Texture2D object.
@ -168,7 +169,7 @@ public:
bool initWithImage(Image * uiImage); bool initWithImage(Image * uiImage);
/** Initializes a texture from a string with dimensions, alignment, font name and font size */ /** Initializes a texture from a string with dimensions, alignment, font name and font size */
bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), TextAlignment hAlignment = kTextAlignmentCenter, VerticalTextAlignment vAlignment = kVerticalTextAlignmentTop); bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), Label::TextAlignment hAlignment = Label::TEXT_ALIGNMENT_CENTER, Label::VerticalTextAlignment vAlignment = Label::VERTICAL_TEXT_ALIGNMENT_TOP);
/** Initializes a texture from a string using a text definition*/ /** Initializes a texture from a string using a text definition*/
bool initWithString(const char *text, const FontDefinition& textDefinition); bool initWithString(const char *text, const FontDefinition& textDefinition);
@ -230,8 +231,8 @@ public:
/** Helper functions that returns bits per pixels for a given format. /** Helper functions that returns bits per pixels for a given format.
@since v2.0 @since v2.0
*/ */
unsigned int getBitsPerPixelForFormat(Texture2DPixelFormat format) const; unsigned int getBitsPerPixelForFormat(Texture2D::PixelFormat format) const;
CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2DPixelFormat format) const { return getBitsPerPixelForFormat(format); }; CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2D::PixelFormat format) const { return getBitsPerPixelForFormat(format); };
/** content size */ /** content size */
const Size& getContentSizeInPixels(); const Size& getContentSizeInPixels();
@ -240,7 +241,7 @@ public:
bool hasMipmaps() const; bool hasMipmaps() const;
/** Gets the pixel format of the texture */ /** Gets the pixel format of the texture */
Texture2DPixelFormat getPixelFormat() const; Texture2D::PixelFormat getPixelFormat() const;
/** Gets the width of the texture in pixels */ /** Gets the width of the texture in pixels */
unsigned int getPixelsWide() const; unsigned int getPixelsWide() const;
@ -274,7 +275,7 @@ private:
protected: protected:
/** pixel format of the texture */ /** pixel format of the texture */
Texture2DPixelFormat _pixelFormat; Texture2D::PixelFormat _pixelFormat;
/** width in pixels */ /** width in pixels */
unsigned int _pixelsWide; unsigned int _pixelsWide;

View File

@ -262,16 +262,16 @@ void TextureAtlas::setupVBOandVAO()
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW);
// vertices // vertices
glEnableVertexAttribArray(kVertexAttrib_Position); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
// colors // colors
glEnableVertexAttribArray(kVertexAttrib_Color); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
// tex coords // tex coords
glEnableVertexAttribArray(kVertexAttrib_TexCoords); glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW);
@ -664,16 +664,16 @@ void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start)
_dirty = false; _dirty = false;
} }
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
// vertices // vertices
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices));
// colors // colors
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors));
// tex coords // tex coords
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);

View File

@ -207,8 +207,8 @@ void TextureCache::loadImage()
const char *filename = pAsyncStruct->filename.c_str(); const char *filename = pAsyncStruct->filename.c_str();
// compute image type // compute image type
Image::EImageFormat imageType = computeImageFormatType(pAsyncStruct->filename); Image::Format imageType = computeImageFormatType(pAsyncStruct->filename);
if (imageType == Image::kFmtUnKnown) if (imageType == Image::FORMAT_UNKOWN)
{ {
CCLOG("unsupported format %s",filename); CCLOG("unsupported format %s",filename);
delete pAsyncStruct; delete pAsyncStruct;
@ -246,25 +246,25 @@ void TextureCache::loadImage()
} }
} }
Image::EImageFormat TextureCache::computeImageFormatType(string& filename) Image::Format TextureCache::computeImageFormatType(string& filename)
{ {
Image::EImageFormat ret = Image::kFmtUnKnown; Image::Format ret = Image::FORMAT_UNKOWN;
if ((std::string::npos != filename.find(".jpg")) || (std::string::npos != filename.find(".jpeg"))) if ((std::string::npos != filename.find(".jpg")) || (std::string::npos != filename.find(".jpeg")))
{ {
ret = Image::kFmtJpg; ret = Image::FORMAT_JPG;
} }
else if ((std::string::npos != filename.find(".png")) || (std::string::npos != filename.find(".PNG"))) else if ((std::string::npos != filename.find(".png")) || (std::string::npos != filename.find(".PNG")))
{ {
ret = Image::kFmtPng; ret = Image::FORMAT_PNG;
} }
else if ((std::string::npos != filename.find(".tiff")) || (std::string::npos != filename.find(".TIFF"))) else if ((std::string::npos != filename.find(".tiff")) || (std::string::npos != filename.find(".TIFF")))
{ {
ret = Image::kFmtTiff; ret = Image::FORMAT_TIFF;
} }
else if ((std::string::npos != filename.find(".webp")) || (std::string::npos != filename.find(".WEBP"))) else if ((std::string::npos != filename.find(".webp")) || (std::string::npos != filename.find(".WEBP")))
{ {
ret = Image::kFmtWebp; ret = Image::FORMAT_WEBP;
} }
return ret; return ret;
@ -365,22 +365,22 @@ Texture2D * TextureCache::addImage(const char * path)
} }
else else
{ {
Image::EImageFormat eImageFormat = Image::kFmtUnKnown; Image::Format eImageFormat = Image::FORMAT_UNKOWN;
if (std::string::npos != lowerCase.find(".png")) if (std::string::npos != lowerCase.find(".png"))
{ {
eImageFormat = Image::kFmtPng; eImageFormat = Image::FORMAT_PNG;
} }
else if (std::string::npos != lowerCase.find(".jpg") || std::string::npos != lowerCase.find(".jpeg")) else if (std::string::npos != lowerCase.find(".jpg") || std::string::npos != lowerCase.find(".jpeg"))
{ {
eImageFormat = Image::kFmtJpg; eImageFormat = Image::FORMAT_JPG;
} }
else if (std::string::npos != lowerCase.find(".tif") || std::string::npos != lowerCase.find(".tiff")) else if (std::string::npos != lowerCase.find(".tif") || std::string::npos != lowerCase.find(".tiff"))
{ {
eImageFormat = Image::kFmtTiff; eImageFormat = Image::FORMAT_TIFF;
} }
else if (std::string::npos != lowerCase.find(".webp")) else if (std::string::npos != lowerCase.find(".webp"))
{ {
eImageFormat = Image::kFmtWebp; eImageFormat = Image::FORMAT_WEBP;
} }
pImage = new Image(); pImage = new Image();
@ -433,7 +433,7 @@ Texture2D * TextureCache::addPVRImage(const char* path)
{ {
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture file name // cache the texture file name
VolatileTexture::addImageTexture(texture, fullpath.c_str(), Image::kFmtRawData); VolatileTexture::addImageTexture(texture, fullpath.c_str(), Image::FORMAT_RAW_DATA);
#endif #endif
_textures->setObject(texture, key.c_str()); _textures->setObject(texture, key.c_str());
texture->autorelease(); texture->autorelease();
@ -641,9 +641,9 @@ VolatileTexture::VolatileTexture(Texture2D *t)
: _texture(t) : _texture(t)
, _cashedImageType(kInvalid) , _cashedImageType(kInvalid)
, _textureData(NULL) , _textureData(NULL)
, _pixelFormat(kTexture2DPixelFormat_RGBA8888) , _pixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888)
, _fileName("") , _fileName("")
, _fmtImage(Image::kFmtPng) , _fmtImage(Image::FORMAT_PNG)
, _text("") , _text("")
, _uiImage(NULL) , _uiImage(NULL)
{ {
@ -660,7 +660,7 @@ VolatileTexture::~VolatileTexture()
CC_SAFE_RELEASE(_uiImage); CC_SAFE_RELEASE(_uiImage);
} }
void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format) void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName, Image::Format format)
{ {
if (_isReloading) if (_isReloading)
{ {
@ -705,7 +705,7 @@ VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt)
return vt; return vt;
} }
void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize) void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2D::PixelFormat pixelFormat, const Size& contentSize)
{ {
if (_isReloading) if (_isReloading)
{ {
@ -785,7 +785,7 @@ void VolatileTexture::reloadAllTextures()
if (std::string::npos != lowerCase.find(".pvr")) if (std::string::npos != lowerCase.find(".pvr"))
{ {
Texture2DPixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat); Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
vt->_texture->initWithPVRFile(vt->_fileName.c_str()); vt->_texture->initWithPVRFile(vt->_fileName.c_str());
@ -799,7 +799,7 @@ void VolatileTexture::reloadAllTextures()
if (pImage && pImage->initWithImageData((void*)pBuffer, nSize, vt->_fmtImage)) if (pImage && pImage->initWithImageData((void*)pBuffer, nSize, vt->_fmtImage))
{ {
Texture2DPixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat); Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
vt->_texture->initWithImage(pImage); vt->_texture->initWithImage(pImage);
Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat); Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat);

View File

@ -161,7 +161,7 @@ public:
private: private:
void addImageAsyncCallBack(float dt); void addImageAsyncCallBack(float dt);
void loadImage(); void loadImage();
Image::EImageFormat computeImageFormatType(std::string& filename); Image::Format computeImageFormatType(std::string& filename);
public: public:
struct AsyncStruct struct AsyncStruct
@ -179,7 +179,7 @@ protected:
{ {
AsyncStruct *asyncStruct; AsyncStruct *asyncStruct;
Image *image; Image *image;
Image::EImageFormat imageType; Image::Format imageType;
} ImageInfo; } ImageInfo;
std::thread* _loadingThread; std::thread* _loadingThread;
@ -218,9 +218,9 @@ public:
VolatileTexture(Texture2D *t); VolatileTexture(Texture2D *t);
~VolatileTexture(); ~VolatileTexture();
static void addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format); static void addImageTexture(Texture2D *tt, const char* imageFileName, Image::Format format);
static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition); static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition);
static void addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize); static void addDataTexture(Texture2D *tt, void* data, Texture2D::PixelFormat pixelFormat, const Size& contentSize);
static void addImage(Texture2D *tt, Image *image); static void addImage(Texture2D *tt, Image *image);
static void setTexParameters(Texture2D *t, const ccTexParams &texParams); static void setTexParameters(Texture2D *t, const ccTexParams &texParams);
@ -245,10 +245,10 @@ protected:
void *_textureData; void *_textureData;
Size _textureSize; Size _textureSize;
Texture2DPixelFormat _pixelFormat; Texture2D::PixelFormat _pixelFormat;
std::string _fileName; std::string _fileName;
Image::EImageFormat _fmtImage; Image::Format _fmtImage;
ccTexParams _texParams; ccTexParams _texParams;
std::string _text; std::string _text;

View File

@ -46,35 +46,35 @@ NS_CC_BEGIN
static const ccPVRTexturePixelFormatInfo PVRTableFormats[] = { static const ccPVRTexturePixelFormatInfo PVRTableFormats[] = {
// 0: BGRA_8888 // 0: BGRA_8888
{GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, true, kTexture2DPixelFormat_RGBA8888}, {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, true, Texture2D::PIXEL_FORMAT_RGBA8888},
// 1: RGBA_8888 // 1: RGBA_8888
{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true, kTexture2DPixelFormat_RGBA8888}, {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true, Texture2D::PIXEL_FORMAT_RGBA8888},
// 2: RGBA_4444 // 2: RGBA_4444
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true, kTexture2DPixelFormat_RGBA4444}, {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true, Texture2D::PIXEL_FORMAT_RGBA4444},
// 3: RGBA_5551 // 3: RGBA_5551
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true, kTexture2DPixelFormat_RGB5A1}, {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true, Texture2D::PIXEL_FORMAT_RGB5A1},
// 4: RGB_565 // 4: RGB_565
{GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false, kTexture2DPixelFormat_RGB565}, {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false, Texture2D::PIXEL_FORMAT_RGB565},
// 5: RGB_888 // 5: RGB_888
{GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false, kTexture2DPixelFormat_RGB888}, {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false, Texture2D::PIXEL_FORMAT_RGB888},
// 6: A_8 // 6: A_8
{GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false, kTexture2DPixelFormat_A8}, {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PIXEL_FORMAT_A8},
// 7: L_8 // 7: L_8
{GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false, kTexture2DPixelFormat_I8}, {GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PIXEL_FORMAT_I8},
// 8: LA_88 // 8: LA_88
{GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true, kTexture2DPixelFormat_AI88}, {GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true, Texture2D::PIXEL_FORMAT_AI88},
// Not all platforms include GLES/gl2ext.h so these PVRTC enums are not always // Not all platforms include GLES/gl2ext.h so these PVRTC enums are not always
// available. // available.
#ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG #ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
// 9: PVRTC 2BPP RGB // 9: PVRTC 2BPP RGB
{GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, false, kTexture2DPixelFormat_PVRTC2}, {GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, false, Texture2D::PIXEL_FORMAT_PRVTC2},
// 10: PVRTC 2BPP RGBA // 10: PVRTC 2BPP RGBA
{GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true, kTexture2DPixelFormat_PVRTC2}, {GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true, Texture2D::PIXEL_FORMAT_PRVTC2},
// 11: PVRTC 4BPP RGB // 11: PVRTC 4BPP RGB
{GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false, kTexture2DPixelFormat_PVRTC4}, {GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false, Texture2D::PIXEL_FORMAT_PRVTC4},
// 12: PVRTC 4BPP RGBA // 12: PVRTC 4BPP RGBA
{GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true, kTexture2DPixelFormat_PVRTC4}, {GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true, Texture2D::PIXEL_FORMAT_PRVTC4},
#endif #endif
}; };
@ -235,7 +235,7 @@ TexturePVR::TexturePVR()
, _hasPremultipliedAlpha(false) , _hasPremultipliedAlpha(false)
, _forcePremultipliedAlpha(false) , _forcePremultipliedAlpha(false)
, _retainName(false) , _retainName(false)
, _format(kTexture2DPixelFormat_Default) , _format(Texture2D::PIXEL_FORMAT_DEFAULT)
, _pixelFormatInfo(NULL) , _pixelFormatInfo(NULL)
{ {
} }

View File

@ -53,7 +53,7 @@ typedef struct _ccPVRTexturePixelFormatInfo {
uint32_t bpp; uint32_t bpp;
bool compressed; bool compressed;
bool alpha; bool alpha;
Texture2DPixelFormat ccPixelFormat; Texture2D::PixelFormat ccPixelFormat;
} ccPVRTexturePixelFormatInfo; } ccPVRTexturePixelFormatInfo;
/** /**
@ -115,7 +115,7 @@ public:
inline bool isForcePremultipliedAlpha() const { return _forcePremultipliedAlpha; } inline bool isForcePremultipliedAlpha() const { return _forcePremultipliedAlpha; }
/** how many mipmaps the texture has. 1 means one level (level 0 */ /** how many mipmaps the texture has. 1 means one level (level 0 */
inline unsigned int getNumberOfMipmaps() const { return _numberOfMipmaps; } inline unsigned int getNumberOfMipmaps() const { return _numberOfMipmaps; }
inline Texture2DPixelFormat getFormat() const { return _format; } inline Texture2D::PixelFormat getFormat() const { return _format; }
inline bool isRetainName() const { return _retainName; } inline bool isRetainName() const { return _retainName; }
inline void setRetainName(bool retainName) { _retainName = retainName; } inline void setRetainName(bool retainName) { _retainName = retainName; }
@ -136,7 +136,7 @@ protected:
// cocos2d integration // cocos2d integration
bool _retainName; bool _retainName;
Texture2DPixelFormat _format; Texture2D::PixelFormat _format;
const ccPVRTexturePixelFormatInfo *_pixelFormatInfo; const ccPVRTexturePixelFormatInfo *_pixelFormatInfo;
}; };

View File

@ -208,9 +208,9 @@ void TMXLayer::parseInternalProperties()
{ {
alphaFuncValue = alphaFuncVal->floatValue(); alphaFuncValue = alphaFuncVal->floatValue();
} }
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST));
GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), kUniformAlphaTestValue); GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
// NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison

View File

@ -191,7 +191,7 @@ bool Armature::init(const char *name)
} }
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
unscheduleUpdate(); unscheduleUpdate();
scheduleUpdate(); scheduleUpdate();

View File

@ -48,7 +48,7 @@ BatchNode::BatchNode()
bool BatchNode::init() bool BatchNode::init()
{ {
bool ret = Node::init(); bool ret = Node::init();
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
return ret; return ret;
} }

View File

@ -72,7 +72,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag)
GLProgram *shader = new GLProgram(); GLProgram *shader = new GLProgram();
shader->initWithVertexShaderFilename(vert, frag); shader->initWithVertexShaderFilename(vert, frag);
shader->addAttribute("aVertex", kVertexAttrib_Position); shader->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION);
shader->link(); shader->link();
shader->updateUniforms(); shader->updateUniforms();
@ -123,9 +123,9 @@ void ShaderNode::draw()
// time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version
glUniform1f(_uniformTime, _time); glUniform1f(_uniformTime, _time);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POSITION);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_TRIANGLES, 0, 6); glDrawArrays(GL_TRIANGLES, 0, 6);

View File

@ -40,7 +40,7 @@ void* Texture2DMutable::keepData(void* data, unsigned int lenght)
return newData; return newData;
} }
bool Texture2DMutable::initWithImageFile(const char *imageFile, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize) bool Texture2DMutable::initWithImageFile(const char *imageFile, cocos2d::Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize)
{ {
image_ = new cocos2d::Image(); image_ = new cocos2d::Image();
image_->initWithImageFile(imageFile); image_->initWithImageFile(imageFile);
@ -57,22 +57,22 @@ bool Texture2DMutable::initWithImageFile(const char *imageFile)
bool hasAlpha = image_->hasAlpha(); bool hasAlpha = image_->hasAlpha();
Size imageSize = Size((float)(image_->getWidth()), (float)(image_->getHeight())); Size imageSize = Size((float)(image_->getWidth()), (float)(image_->getHeight()));
size_t bpp = image_->getBitsPerComponent(); size_t bpp = image_->getBitsPerComponent();
cocos2d::Texture2DPixelFormat pixelFormat; cocos2d::Texture2D::PixelFormat pixelFormat;
// compute pixel format // compute pixel format
if(hasAlpha) if(hasAlpha)
{ {
pixelFormat = kTexture2DPixelFormat_Default; pixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
} }
else else
{ {
if (bpp >= 8) if (bpp >= 8)
{ {
pixelFormat = kTexture2DPixelFormat_RGB888; pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
} }
else else
{ {
pixelFormat = kTexture2DPixelFormat_RGB565; pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
} }
} }
@ -80,18 +80,18 @@ bool Texture2DMutable::initWithImageFile(const char *imageFile)
return initWithData(image_->getData(), pixelFormat, imageSize.width, imageSize.height, imageSize); return initWithData(image_->getData(), pixelFormat, imageSize.width, imageSize.height, imageSize);
} }
bool Texture2DMutable::initWithData(const void* data, Texture2DPixelFormat pixelFormat, unsigned int width, unsigned int height, const Size& size) bool Texture2DMutable::initWithData(const void* data, Texture2D::PixelFormat pixelFormat, unsigned int width, unsigned int height, const Size& size)
{ {
if(!Texture2D::initWithData(data, pixelFormat, width, height, size)) { if(!Texture2D::initWithData(data, pixelFormat, width, height, size)) {
return false; return false;
} }
switch (pixelFormat) { switch (pixelFormat) {
case kTexture2DPixelFormat_RGBA8888: bytesPerPixel_ = 4; break; case Texture2D::PIXEL_FORMAT_RGBA8888: bytesPerPixel_ = 4; break;
case kTexture2DPixelFormat_A8: bytesPerPixel_ = 1; break; case Texture2D::PIXEL_FORMAT_A8: bytesPerPixel_ = 1; break;
case kTexture2DPixelFormat_RGBA4444: case Texture2D::PIXEL_FORMAT_RGBA4444:
case kTexture2DPixelFormat_RGB565: case Texture2D::PIXEL_FORMAT_RGB565:
case kTexture2DPixelFormat_RGB5A1: case Texture2D::PIXEL_FORMAT_RGB5A1:
bytesPerPixel_ = 2; bytesPerPixel_ = 2;
break; break;
default:break; default:break;
@ -120,35 +120,35 @@ Color4B Texture2DMutable::pixelAt(const Point& pt)
//! unsigned int x = pt.x, y = pt.y //! unsigned int x = pt.x, y = pt.y
unsigned int x = pt.x, y = _pixelsHigh - pt.y; unsigned int x = pt.x, y = _pixelsHigh - pt.y;
if(_pixelFormat == kTexture2DPixelFormat_RGBA8888){ if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA8888){
unsigned int *pixel = (unsigned int *)data_; unsigned int *pixel = (unsigned int *)data_;
pixel = pixel + (y * _pixelsWide) + x; pixel = pixel + (y * _pixelsWide) + x;
c.r = *pixel & 0xff; c.r = *pixel & 0xff;
c.g = (*pixel >> 8) & 0xff; c.g = (*pixel >> 8) & 0xff;
c.b = (*pixel >> 16) & 0xff; c.b = (*pixel >> 16) & 0xff;
c.a = (*pixel >> 24) & 0xff; c.a = (*pixel >> 24) & 0xff;
} else if(_pixelFormat == kTexture2DPixelFormat_RGBA4444){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444){
GLushort *pixel = (GLushort *)data_; GLushort *pixel = (GLushort *)data_;
pixel = pixel + (y * _pixelsWide) + x; pixel = pixel + (y * _pixelsWide) + x;
c.a = ((*pixel & 0xf) << 4) | (*pixel & 0xf); c.a = ((*pixel & 0xf) << 4) | (*pixel & 0xf);
c.b = (((*pixel >> 4) & 0xf) << 4) | ((*pixel >> 4) & 0xf); c.b = (((*pixel >> 4) & 0xf) << 4) | ((*pixel >> 4) & 0xf);
c.g = (((*pixel >> 8) & 0xf) << 4) | ((*pixel >> 8) & 0xf); c.g = (((*pixel >> 8) & 0xf) << 4) | ((*pixel >> 8) & 0xf);
c.r = (((*pixel >> 12) & 0xf) << 4) | ((*pixel >> 12) & 0xf); c.r = (((*pixel >> 12) & 0xf) << 4) | ((*pixel >> 12) & 0xf);
} else if(_pixelFormat == kTexture2DPixelFormat_RGB5A1){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1){
GLushort *pixel = (GLushort *)data_; GLushort *pixel = (GLushort *)data_;
pixel = pixel + (y * _pixelsWide) + x; pixel = pixel + (y * _pixelsWide) + x;
c.r = ((*pixel >> 11) & 0x1f)<<3; c.r = ((*pixel >> 11) & 0x1f)<<3;
c.g = ((*pixel >> 6) & 0x1f)<<3; c.g = ((*pixel >> 6) & 0x1f)<<3;
c.b = ((*pixel >> 1) & 0x1f)<<3; c.b = ((*pixel >> 1) & 0x1f)<<3;
c.a = (*pixel & 0x1)*255; c.a = (*pixel & 0x1)*255;
} else if(_pixelFormat == kTexture2DPixelFormat_RGB565){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGB565){
GLushort *pixel = (GLushort *)data_; GLushort *pixel = (GLushort *)data_;
pixel = pixel + (y * _pixelsWide) + x; pixel = pixel + (y * _pixelsWide) + x;
c.b = (*pixel & 0x1f)<<3; c.b = (*pixel & 0x1f)<<3;
c.g = ((*pixel >> 5) & 0x3f)<<2; c.g = ((*pixel >> 5) & 0x3f)<<2;
c.r = ((*pixel >> 11) & 0x1f)<<3; c.r = ((*pixel >> 11) & 0x1f)<<3;
c.a = 255; c.a = 255;
} else if(_pixelFormat == kTexture2DPixelFormat_A8){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_A8){
GLubyte *pixel = (GLubyte *)data_; GLubyte *pixel = (GLubyte *)data_;
c.a = pixel[(y * _pixelsWide) + x]; c.a = pixel[(y * _pixelsWide) + x];
// Default white // Default white
@ -174,22 +174,22 @@ bool Texture2DMutable::setPixelAt(const Point& pt, Color4B c)
// Shifted bit placement based on little-endian, let's make this more // Shifted bit placement based on little-endian, let's make this more
// portable =/ // portable =/
if(_pixelFormat == kTexture2DPixelFormat_RGBA8888){ if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA8888){
unsigned int *pixel = (unsigned int *)data_; unsigned int *pixel = (unsigned int *)data_;
pixel[(y * _pixelsWide) + x] = (c.a << 24) | (c.b << 16) | (c.g << 8) | c.r; pixel[(y * _pixelsWide) + x] = (c.a << 24) | (c.b << 16) | (c.g << 8) | c.r;
} else if(_pixelFormat == kTexture2DPixelFormat_RGBA4444){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444){
GLushort *pixel = (GLushort *)data_; GLushort *pixel = (GLushort *)data_;
pixel = pixel + (y * _pixelsWide) + x; pixel = pixel + (y * _pixelsWide) + x;
*pixel = ((c.r >> 4) << 12) | ((c.g >> 4) << 8) | ((c.b >> 4) << 4) | (c.a >> 4); *pixel = ((c.r >> 4) << 12) | ((c.g >> 4) << 8) | ((c.b >> 4) << 4) | (c.a >> 4);
} else if(_pixelFormat == kTexture2DPixelFormat_RGB5A1){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1){
GLushort *pixel = (GLushort *)data_; GLushort *pixel = (GLushort *)data_;
pixel = pixel + (y * _pixelsWide) + x; pixel = pixel + (y * _pixelsWide) + x;
*pixel = ((c.r >> 3) << 11) | ((c.g >> 3) << 6) | ((c.b >> 3) << 1) | (c.a > 0); *pixel = ((c.r >> 3) << 11) | ((c.g >> 3) << 6) | ((c.b >> 3) << 1) | (c.a > 0);
} else if(_pixelFormat == kTexture2DPixelFormat_RGB565){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGB565){
GLushort *pixel = (GLushort *)data_; GLushort *pixel = (GLushort *)data_;
pixel = pixel + (y * _pixelsWide) + x; pixel = pixel + (y * _pixelsWide) + x;
*pixel = ((c.r >> 3) << 11) | ((c.g >> 2) << 5) | (c.b >> 3); *pixel = ((c.r >> 3) << 11) | ((c.g >> 2) << 5) | (c.b >> 3);
} else if(_pixelFormat == kTexture2DPixelFormat_A8){ } else if(_pixelFormat == Texture2D::PIXEL_FORMAT_A8){
GLubyte *pixel = (GLubyte *)data_; GLubyte *pixel = (GLubyte *)data_;
pixel[(y * _pixelsWide) + x] = c.a; pixel[(y * _pixelsWide) + x] = c.a;
} else { } else {
@ -264,19 +264,19 @@ void Texture2DMutable::apply()
switch(_pixelFormat) switch(_pixelFormat)
{ {
case kTexture2DPixelFormat_RGBA8888: case Texture2D::PIXEL_FORMAT_RGBA8888:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_);
break; break;
case kTexture2DPixelFormat_RGBA4444: case Texture2D::PIXEL_FORMAT_RGBA4444:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data_);
break; break;
case kTexture2DPixelFormat_RGB5A1: case Texture2D::PIXEL_FORMAT_RGB5A1:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data_);
break; break;
case kTexture2DPixelFormat_RGB565: case Texture2D::PIXEL_FORMAT_RGB565:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _pixelsWide, _pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _pixelsWide, _pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data_);
break; break;
case kTexture2DPixelFormat_A8: case Texture2D::PIXEL_FORMAT_A8:
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, _pixelsWide, _pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data_); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, _pixelsWide, _pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data_);
break; break;
default: default:

View File

@ -40,12 +40,12 @@ public:
void releaseData(void *data); void releaseData(void *data);
void* keepData(void *data, unsigned int length); void* keepData(void *data, unsigned int length);
bool initWithImageFile(const char *imageFile, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize); bool initWithImageFile(const char *imageFile, cocos2d::Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize);
bool initWithImageFile(const char *imageFilex); bool initWithImageFile(const char *imageFilex);
/** Intializes with a texture2d with data */ /** Intializes with a texture2d with data */
bool initWithData(const void* data, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize); bool initWithData(const void* data, cocos2d::Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize);
cocos2d::Color4B pixelAt(const cocos2d::Point& pt); cocos2d::Color4B pixelAt(const cocos2d::Point& pt);

View File

@ -42,7 +42,7 @@ GLESDebugDraw::GLESDebugDraw( float32 ratio )
void GLESDebugDraw::initShader( void ) void GLESDebugDraw::initShader( void )
{ {
mShaderProgram = ShaderCache::getInstance()->programForKey(kShader_Position_uColor); mShaderProgram = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR);
mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color"); mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color");
} }
@ -61,7 +61,7 @@ void GLESDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, con
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_LINE_LOOP, 0, vertexCount); glDrawArrays(GL_LINE_LOOP, 0, vertexCount);
CC_INCREMENT_GL_DRAWS(1); CC_INCREMENT_GL_DRAWS(1);
@ -84,7 +84,7 @@ void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount);
@ -118,7 +118,7 @@ void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Col
} }
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_LINE_LOOP, 0, vertexCount); glDrawArrays(GL_LINE_LOOP, 0, vertexCount);
@ -149,7 +149,7 @@ void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const
} }
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount);
@ -178,7 +178,7 @@ void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Colo
p1.x * mRatio, p1.y * mRatio, p1.x * mRatio, p1.y * mRatio,
p2.x * mRatio, p2.y * mRatio p2.x * mRatio, p2.y * mRatio
}; };
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_LINES, 0, 2); glDrawArrays(GL_LINES, 0, 2);
@ -211,7 +211,7 @@ void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& colo
p.x * mRatio, p.y * mRatio p.x * mRatio, p.y * mRatio
}; };
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_POINTS, 0, 1); glDrawArrays(GL_POINTS, 0, 1);
// glPointSize(1.0f); // glPointSize(1.0f);
@ -242,7 +242,7 @@ void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color)
aabb->lowerBound.x * mRatio, aabb->upperBound.y * mRatio aabb->lowerBound.x * mRatio, aabb->upperBound.y * mRatio
}; };
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_LINE_LOOP, 0, 8); glDrawArrays(GL_LINE_LOOP, 0, 8);
CC_INCREMENT_GL_DRAWS(1); CC_INCREMENT_GL_DRAWS(1);

View File

@ -64,9 +64,9 @@ void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, co
void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) {
if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) {
((LabelTTF *)pNode)->setHorizontalAlignment(TextAlignment(pIntegerLabeled)); ((LabelTTF *)pNode)->setHorizontalAlignment(Label::TextAlignment(pIntegerLabeled));
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) {
((LabelTTF *)pNode)->setVerticalAlignment(VerticalTextAlignment(pIntegerLabeled)); ((LabelTTF *)pNode)->setVerticalAlignment(Label::VerticalTextAlignment(pIntegerLabeled));
} else { } else {
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
} }

View File

@ -31,7 +31,7 @@ InputDelegate::InputDelegate(void)
, _accelerometerEnabled(false) , _accelerometerEnabled(false)
, _keypadEnabled(false) , _keypadEnabled(false)
, _touchPriority(0) , _touchPriority(0)
, _touchMode(kTouchesAllAtOnce) , _touchMode(Layer::TOUCHES_ALL_AT_ONCE)
{ {
} }
@ -106,7 +106,7 @@ void InputDelegate::setTouchEnabled(bool enabled)
_touchEnabled = enabled; _touchEnabled = enabled;
if (enabled) if (enabled)
{ {
if( _touchMode == kTouchesAllAtOnce ) if( _touchMode == Layer::TOUCHES_ALL_AT_ONCE )
{ {
Director::getInstance()->getTouchDispatcher()->addStandardDelegate(this, 0); Director::getInstance()->getTouchDispatcher()->addStandardDelegate(this, 0);
} }

View File

@ -59,7 +59,7 @@ ControlPotentiometer* ControlPotentiometer::create(const char* backgroundFile, c
// Prepare progress for potentiometer // Prepare progress for potentiometer
ProgressTimer *progressTimer = ProgressTimer::create(Sprite::create(progressFile)); ProgressTimer *progressTimer = ProgressTimer::create(Sprite::create(progressFile));
//progressTimer.type = kProgressTimerTypeRadialCW; //progressTimer.type = ProgressTimer::RADIALCW;
if (pRet->initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite)) if (pRet->initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite))
{ {
pRet->autorelease(); pRet->autorelease();

View File

@ -124,9 +124,9 @@ bool ControlSwitchSprite::initWithMaskSprite(
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
getShaderProgram()->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
getShaderProgram()->addAttribute(kAttributeNameColor, kVertexAttrib_Color); getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
getShaderProgram()->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
getShaderProgram()->link(); getShaderProgram()->link();
@ -157,7 +157,7 @@ void ControlSwitchSprite::draw()
{ {
CC_NODE_DRAW_SETUP(); CC_NODE_DRAW_SETUP();
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
getShaderProgram()->setUniformsForBuiltins(); getShaderProgram()->setUniformsForBuiltins();
@ -177,15 +177,15 @@ void ControlSwitchSprite::draw()
// vertex // vertex
int diff = offsetof( V3F_C4B_T2F, vertices); int diff = offsetof( V3F_C4B_T2F, vertices);
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
// texCoods // texCoods
diff = offsetof( V3F_C4B_T2F, texCoords); diff = offsetof( V3F_C4B_T2F, texCoords);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
// color // color
diff = offsetof( V3F_C4B_T2F, colors); diff = offsetof( V3F_C4B_T2F, colors);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

View File

@ -60,7 +60,7 @@ void CCSkeleton::initialize () {
blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
setOpacityModifyRGB(true); setOpacityModifyRGB(true);
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
scheduleUpdate(); scheduleUpdate();
} }

View File

@ -136,13 +136,13 @@ void SpriteProgressToRadial::onEnter()
ProgressTo *to2 = ProgressTo::create(2, 100); ProgressTo *to2 = ProgressTo::create(2, 100);
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
left->setType( kProgressTimerTypeRadial ); left->setType( ProgressTimer::RADIAL );
addChild(left); addChild(left);
left->setPosition(Point(100, s.height/2)); left->setPosition(Point(100, s.height/2));
left->runAction( RepeatForever::create(to1)); left->runAction( RepeatForever::create(to1));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
right->setType(kProgressTimerTypeRadial); right->setType(ProgressTimer::RADIAL);
// Makes the ridial CCW // Makes the ridial CCW
right->setReverseProgress(true); right->setReverseProgress(true);
addChild(right); addChild(right);
@ -171,7 +171,7 @@ void SpriteProgressToHorizontal::onEnter()
ProgressTo *to2 = ProgressTo::create(2, 100); ProgressTo *to2 = ProgressTo::create(2, 100);
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
left->setType(kProgressTimerTypeBar); left->setType(ProgressTimer::BAR);
// Setup for a bar starting from the left since the midpoint is 0 for the x // Setup for a bar starting from the left since the midpoint is 0 for the x
left->setMidpoint(Point(0,0)); left->setMidpoint(Point(0,0));
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
@ -181,7 +181,7 @@ void SpriteProgressToHorizontal::onEnter()
left->runAction( RepeatForever::create(to1)); left->runAction( RepeatForever::create(to1));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
right->setType(kProgressTimerTypeBar); right->setType(ProgressTimer::BAR);
// Setup for a bar starting from the left since the midpoint is 1 for the x // Setup for a bar starting from the left since the midpoint is 1 for the x
right->setMidpoint(Point(1, 0)); right->setMidpoint(Point(1, 0));
// Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
@ -211,7 +211,7 @@ void SpriteProgressToVertical::onEnter()
ProgressTo *to2 = ProgressTo::create(2, 100); ProgressTo *to2 = ProgressTo::create(2, 100);
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
left->setType(kProgressTimerTypeBar); left->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
left->setMidpoint(Point(0,0)); left->setMidpoint(Point(0,0));
@ -222,7 +222,7 @@ void SpriteProgressToVertical::onEnter()
left->runAction( RepeatForever::create(to1)); left->runAction( RepeatForever::create(to1));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
right->setType(kProgressTimerTypeBar); right->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Point(0, 1)); right->setMidpoint(Point(0, 1));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
@ -254,7 +254,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter()
* Our image on the left should be a radial progress indicator, clockwise * Our image on the left should be a radial progress indicator, clockwise
*/ */
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock)); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock));
left->setType(kProgressTimerTypeRadial); left->setType(ProgressTimer::RADIAL);
addChild(left); addChild(left);
left->setMidpoint(Point(0.25f, 0.75f)); left->setMidpoint(Point(0.25f, 0.75f));
left->setPosition(Point(100, s.height/2)); left->setPosition(Point(100, s.height/2));
@ -264,7 +264,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter()
* Our image on the left should be a radial progress indicator, counter clockwise * Our image on the left should be a radial progress indicator, counter clockwise
*/ */
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
right->setType(kProgressTimerTypeRadial); right->setType(ProgressTimer::RADIAL);
right->setMidpoint(Point(0.75f, 0.25f)); right->setMidpoint(Point(0.75f, 0.25f));
/** /**
@ -295,7 +295,7 @@ void SpriteProgressBarVarious::onEnter()
ProgressTo *to = ProgressTo::create(2, 100); ProgressTo *to = ProgressTo::create(2, 100);
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
left->setType(kProgressTimerTypeBar); left->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
left->setMidpoint(Point(0.5f, 0.5f)); left->setMidpoint(Point(0.5f, 0.5f));
@ -306,7 +306,7 @@ void SpriteProgressBarVarious::onEnter()
left->runAction(RepeatForever::create(to->clone())); left->runAction(RepeatForever::create(to->clone()));
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
middle->setType(kProgressTimerTypeBar); middle->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
middle->setMidpoint(Point(0.5f, 0.5f)); middle->setMidpoint(Point(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
@ -316,7 +316,7 @@ void SpriteProgressBarVarious::onEnter()
middle->runAction(RepeatForever::create(to->clone())); middle->runAction(RepeatForever::create(to->clone()));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
right->setType(kProgressTimerTypeBar); right->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Point(0.5f, 0.5f)); right->setMidpoint(Point(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
@ -352,7 +352,7 @@ void SpriteProgressBarTintAndFade::onEnter()
NULL); NULL);
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
left->setType(kProgressTimerTypeBar); left->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
left->setMidpoint(Point(0.5f, 0.5f)); left->setMidpoint(Point(0.5f, 0.5f));
@ -366,7 +366,7 @@ void SpriteProgressBarTintAndFade::onEnter()
left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f)); left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f));
ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2));
middle->setType(kProgressTimerTypeBar); middle->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
middle->setMidpoint(Point(0.5f, 0.5f)); middle->setMidpoint(Point(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
@ -379,7 +379,7 @@ void SpriteProgressBarTintAndFade::onEnter()
middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f)); middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f));
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2));
right->setType(kProgressTimerTypeBar); right->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Point(0.5f, 0.5f)); right->setMidpoint(Point(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
@ -414,7 +414,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist"); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
ProgressTimer *left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png")); ProgressTimer *left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png"));
left->setType(kProgressTimerTypeBar); left->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
left->setMidpoint(Point(0.5f, 0.5f)); left->setMidpoint(Point(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
@ -424,7 +424,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
left->runAction(RepeatForever::create(to->clone())); left->runAction(RepeatForever::create(to->clone()));
ProgressTimer *middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png")); ProgressTimer *middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png"));
middle->setType(kProgressTimerTypeBar); middle->setType(ProgressTimer::BAR);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
middle->setMidpoint(Point(0.5f, 0.5f)); middle->setMidpoint(Point(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
@ -434,7 +434,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
middle->runAction(RepeatForever::create(to->clone())); middle->runAction(RepeatForever::create(to->clone()));
ProgressTimer *right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png")); ProgressTimer *right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png"));
right->setType(kProgressTimerTypeRadial); right->setType(ProgressTimer::RADIAL);
// Setup for a bar starting from the bottom since the midpoint is 0 for the y // Setup for a bar starting from the bottom since the midpoint is 0 for the y
right->setMidpoint(Point(0.5f, 0.5f)); right->setMidpoint(Point(0.5f, 0.5f));
// Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change

View File

@ -141,7 +141,7 @@ void Box2DTestLayer::draw()
Layer::draw(); Layer::draw();
#if CC_ENABLE_BOX2D_INTEGRATION #if CC_ENABLE_BOX2D_INTEGRATION
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
kmGLPushMatrix(); kmGLPushMatrix();

View File

@ -191,7 +191,7 @@ void Box2DView::draw()
{ {
Layer::draw(); Layer::draw();
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
kmGLPushMatrix(); kmGLPushMatrix();

View File

@ -40,7 +40,7 @@ GLESDebugDraw::GLESDebugDraw( float32 ratio )
void GLESDebugDraw::initShader( void ) void GLESDebugDraw::initShader( void )
{ {
mShaderProgram = ShaderCache::getInstance()->programForKey(kShader_Position_uColor); mShaderProgram = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR);
mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color"); mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color");
} }
@ -59,7 +59,7 @@ void GLESDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, con
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_LINE_LOOP, 0, vertexCount); glDrawArrays(GL_LINE_LOOP, 0, vertexCount);
CC_INCREMENT_GL_DRAWS(1); CC_INCREMENT_GL_DRAWS(1);
@ -82,7 +82,7 @@ void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount);
@ -116,7 +116,7 @@ void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Col
} }
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_LINE_LOOP, 0, vertexCount); glDrawArrays(GL_LINE_LOOP, 0, vertexCount);
@ -147,7 +147,7 @@ void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const
} }
mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f);
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount);
@ -176,7 +176,7 @@ void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Colo
p1.x * mRatio, p1.y * mRatio, p1.x * mRatio, p1.y * mRatio,
p2.x * mRatio, p2.y * mRatio p2.x * mRatio, p2.y * mRatio
}; };
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_LINES, 0, 2); glDrawArrays(GL_LINES, 0, 2);
@ -209,7 +209,7 @@ void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& colo
p.x * mRatio, p.y * mRatio p.x * mRatio, p.y * mRatio
}; };
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_POINTS, 0, 1); glDrawArrays(GL_POINTS, 0, 1);
// glPointSize(1.0f); // glPointSize(1.0f);
@ -240,7 +240,7 @@ void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color)
aabb->lowerBound.x * mRatio, aabb->upperBound.y * mRatio aabb->lowerBound.x * mRatio, aabb->upperBound.y * mRatio
}; };
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices);
glDrawArrays(GL_LINE_LOOP, 0, 8); glDrawArrays(GL_LINE_LOOP, 0, 8);
CC_INCREMENT_GL_DRAWS(1); CC_INCREMENT_GL_DRAWS(1);

View File

@ -723,8 +723,8 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane)
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, _alphaThreshold); glAlphaFunc(GL_GREATER, _alphaThreshold);
#else #else
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
_sprite->setShaderProgram(program ); _sprite->setShaderProgram(program );
#endif #endif
@ -756,8 +756,8 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane)
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, _alphaThreshold); glAlphaFunc(GL_GREATER, _alphaThreshold);
#else #else
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
_sprite->setShaderProgram( program ); _sprite->setShaderProgram( program );
#endif #endif
@ -821,8 +821,8 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane)
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, _alphaThreshold); glAlphaFunc(GL_GREATER, _alphaThreshold);
#else #else
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
_sprite->setShaderProgram(program); _sprite->setShaderProgram(program);
#endif #endif

View File

@ -215,7 +215,7 @@ void Effect5::onExit()
{ {
EffectAdvanceTextLayer::onExit(); EffectAdvanceTextLayer::onExit();
Director::getInstance()->setProjection(kDirectorProjection3D); Director::getInstance()->setProjection(Director::PROJECTION_3D);
} }
//------------------------------------------------------------------ //------------------------------------------------------------------

View File

@ -154,7 +154,7 @@ void ArmatureTestLayer::onEnter()
addChild(menu, 100); addChild(menu, 100);
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
} }
void ArmatureTestLayer::onExit() void ArmatureTestLayer::onExit()
@ -539,7 +539,7 @@ std::string TestBox2DDetector::title()
} }
void TestBox2DDetector::draw() void TestBox2DDetector::draw()
{ {
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
kmGLPushMatrix(); kmGLPushMatrix();

View File

@ -81,7 +81,7 @@ SocketIOTestLayer::SocketIOTestLayer(void)
menuRequest->addChild(itemTestEndpointDisconnect); menuRequest->addChild(itemTestEndpointDisconnect);
// Sahred Status Label // Sahred Status Label
_sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), kTextAlignmentLeft); _sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), Label::TEXT_ALIGNMENT_LEFT);
_sioClientStatus->setAnchorPoint(Point(0, 0)); _sioClientStatus->setAnchorPoint(Point(0, 0));
_sioClientStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y)); _sioClientStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y));
this->addChild(_sioClientStatus); this->addChild(_sioClientStatus);

View File

@ -49,19 +49,19 @@ WebSocketTestLayer::WebSocketTestLayer()
// Send Text Status Label // Send Text Status Label
_sendTextStatus = LabelTTF::create("Send Text WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); _sendTextStatus = LabelTTF::create("Send Text WS is waiting...", "Arial", 14, Size(160, 100), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
_sendTextStatus->setAnchorPoint(Point(0, 0)); _sendTextStatus->setAnchorPoint(Point(0, 0));
_sendTextStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y + 25)); _sendTextStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y + 25));
this->addChild(_sendTextStatus); this->addChild(_sendTextStatus);
// Send Binary Status Label // Send Binary Status Label
_sendBinaryStatus = LabelTTF::create("Send Binary WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); _sendBinaryStatus = LabelTTF::create("Send Binary WS is waiting...", "Arial", 14, Size(160, 100), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
_sendBinaryStatus->setAnchorPoint(Point(0, 0)); _sendBinaryStatus->setAnchorPoint(Point(0, 0));
_sendBinaryStatus->setPosition(Point(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25)); _sendBinaryStatus->setPosition(Point(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25));
this->addChild(_sendBinaryStatus); this->addChild(_sendBinaryStatus);
// Error Label // Error Label
_errorStatus = LabelTTF::create("Error WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); _errorStatus = LabelTTF::create("Error WS is waiting...", "Arial", 14, Size(160, 100), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
_errorStatus->setAnchorPoint(Point(0, 0)); _errorStatus->setAnchorPoint(Point(0, 0));
_errorStatus->setPosition(Point(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25)); _errorStatus->setPosition(Point(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25));
this->addChild(_errorStatus); this->addChild(_errorStatus);

View File

@ -39,11 +39,11 @@ static std::string fontList[] =
static int fontCount = sizeof(fontList) / sizeof(*fontList); static int fontCount = sizeof(fontList) / sizeof(*fontList);
static int vAlignIdx = 0; static int vAlignIdx = 0;
static VerticalTextAlignment verticalAlignment[] = static Label::VerticalTextAlignment verticalAlignment[] =
{ {
kVerticalTextAlignmentTop, Label::VERTICAL_TEXT_ALIGNMENT_TOP,
kVerticalTextAlignmentCenter, Label::VERTICAL_TEXT_ALIGNMENT_CENTER,
kVerticalTextAlignmentBottom, Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM,
}; };
static int vAlignCount = sizeof(verticalAlignment) / sizeof(*verticalAlignment); static int vAlignCount = sizeof(verticalAlignment) / sizeof(*verticalAlignment);
@ -99,11 +99,11 @@ void FontTest::showFont(const char *pFont)
LabelTTF *top = LabelTTF::create(pFont, pFont, 24); LabelTTF *top = LabelTTF::create(pFont, pFont, 24);
LabelTTF *left = LabelTTF::create("alignment left", pFont, fontSize, LabelTTF *left = LabelTTF::create("alignment left", pFont, fontSize,
blockSize, kTextAlignmentLeft, verticalAlignment[vAlignIdx]); blockSize, Label::TEXT_ALIGNMENT_LEFT, verticalAlignment[vAlignIdx]);
LabelTTF *center = LabelTTF::create("alignment center", pFont, fontSize, LabelTTF *center = LabelTTF::create("alignment center", pFont, fontSize,
blockSize, kTextAlignmentCenter, verticalAlignment[vAlignIdx]); blockSize, Label::TEXT_ALIGNMENT_CENTER, verticalAlignment[vAlignIdx]);
LabelTTF *right = LabelTTF::create("alignment right", pFont, fontSize, LabelTTF *right = LabelTTF::create("alignment right", pFont, fontSize,
blockSize, kTextAlignmentRight, verticalAlignment[vAlignIdx]); blockSize, Label::TEXT_ALIGNMENT_RIGHT, verticalAlignment[vAlignIdx]);
LayerColor *leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); LayerColor *leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
LayerColor *centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height); LayerColor *centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);

View File

@ -348,19 +348,19 @@ LabelTTFAlignment::LabelTTFAlignment()
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
LabelTTF* ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12, LabelTTF* ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12,
Size(256, 32), kTextAlignmentLeft); Size(256, 32), Label::TEXT_ALIGNMENT_LEFT);
ttf0->setPosition(Point(s.width/2,(s.height/6)*2)); ttf0->setPosition(Point(s.width/2,(s.height/6)*2));
ttf0->setAnchorPoint(Point(0.5f,0.5f)); ttf0->setAnchorPoint(Point(0.5f,0.5f));
this->addChild(ttf0); this->addChild(ttf0);
LabelTTF* ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, LabelTTF* ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12,
Size(245, 32), kTextAlignmentCenter); Size(245, 32), Label::TEXT_ALIGNMENT_CENTER);
ttf1->setPosition(Point(s.width/2,(s.height/6)*3)); ttf1->setPosition(Point(s.width/2,(s.height/6)*3));
ttf1->setAnchorPoint(Point(0.5f,0.5f)); ttf1->setAnchorPoint(Point(0.5f,0.5f));
this->addChild(ttf1); this->addChild(ttf1);
LabelTTF* ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, LabelTTF* ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12,
Size(245, 32), kTextAlignmentRight); Size(245, 32), Label::TEXT_ALIGNMENT_RIGHT);
ttf2->setPosition(Point(s.width/2,(s.height/6)*4)); ttf2->setPosition(Point(s.width/2,(s.height/6)*4));
ttf2->setAnchorPoint(Point(0.5f,0.5f)); ttf2->setAnchorPoint(Point(0.5f,0.5f));
this->addChild(ttf2); this->addChild(ttf2);
@ -953,8 +953,8 @@ LabelTTFTest::LabelTTFTest()
this->addChild(menu); this->addChild(menu);
_plabel = NULL; _plabel = NULL;
_horizAlign = kTextAlignmentLeft; _horizAlign = Label::TEXT_ALIGNMENT_LEFT;
_vertAlign = kVerticalTextAlignmentTop; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
this->updateAlignment(); this->updateAlignment();
} }
@ -988,37 +988,37 @@ void LabelTTFTest::updateAlignment()
void LabelTTFTest::setAlignmentLeft(Object* pSender) void LabelTTFTest::setAlignmentLeft(Object* pSender)
{ {
_horizAlign = kTextAlignmentLeft; _horizAlign = Label::TEXT_ALIGNMENT_LEFT;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentCenter(Object* pSender) void LabelTTFTest::setAlignmentCenter(Object* pSender)
{ {
_horizAlign = kTextAlignmentCenter; _horizAlign = Label::TEXT_ALIGNMENT_CENTER;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentRight(Object* pSender) void LabelTTFTest::setAlignmentRight(Object* pSender)
{ {
_horizAlign = kTextAlignmentRight; _horizAlign = Label::TEXT_ALIGNMENT_RIGHT;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentTop(Object* pSender) void LabelTTFTest::setAlignmentTop(Object* pSender)
{ {
_vertAlign = kVerticalTextAlignmentTop; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentMiddle(Object* pSender) void LabelTTFTest::setAlignmentMiddle(Object* pSender)
{ {
_vertAlign = kVerticalTextAlignmentCenter; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_CENTER;
this->updateAlignment(); this->updateAlignment();
} }
void LabelTTFTest::setAlignmentBottom(Object* pSender) void LabelTTFTest::setAlignmentBottom(Object* pSender)
{ {
_vertAlign = kVerticalTextAlignmentBottom; _vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM;
this->updateAlignment(); this->updateAlignment();
} }
@ -1027,24 +1027,24 @@ const char* LabelTTFTest::getCurrentAlignment()
const char* vertical = NULL; const char* vertical = NULL;
const char* horizontal = NULL; const char* horizontal = NULL;
switch (_vertAlign) { switch (_vertAlign) {
case kVerticalTextAlignmentTop: case Label::VERTICAL_TEXT_ALIGNMENT_TOP:
vertical = "Top"; vertical = "Top";
break; break;
case kVerticalTextAlignmentCenter: case Label::VERTICAL_TEXT_ALIGNMENT_CENTER:
vertical = "Middle"; vertical = "Middle";
break; break;
case kVerticalTextAlignmentBottom: case Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM:
vertical = "Bottom"; vertical = "Bottom";
break; break;
} }
switch (_horizAlign) { switch (_horizAlign) {
case kTextAlignmentLeft: case Label::TEXT_ALIGNMENT_LEFT:
horizontal = "Left"; horizontal = "Left";
break; break;
case kTextAlignmentCenter: case Label::TEXT_ALIGNMENT_CENTER:
horizontal = "Center"; horizontal = "Center";
break; break;
case kTextAlignmentRight: case Label::TEXT_ALIGNMENT_RIGHT:
horizontal = "Right"; horizontal = "Right";
break; break;
} }
@ -1070,8 +1070,8 @@ LabelTTFMultiline::LabelTTFMultiline()
"Paint Boy", "Paint Boy",
32, 32,
Size(s.width/2,200), Size(s.width/2,200),
kTextAlignmentCenter, Label::TEXT_ALIGNMENT_CENTER,
kVerticalTextAlignmentTop); Label::VERTICAL_TEXT_ALIGNMENT_TOP);
center->setPosition(Point(s.width / 2, 150)); center->setPosition(Point(s.width / 2, 150));
@ -1141,7 +1141,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
Size size = Director::getInstance()->getWinSize(); Size size = Director::getInstance()->getWinSize();
// create and initialize a Label // create and initialize a Label
this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kTextAlignmentCenter); this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, Label::TEXT_ALIGNMENT_CENTER);
this->_labelShouldRetain->retain(); this->_labelShouldRetain->retain();
this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png"); this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png");
@ -1250,13 +1250,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender)
switch(item->getTag()) switch(item->getTag())
{ {
case LeftAlign: case LeftAlign:
this->_labelShouldRetain->setAlignment(kTextAlignmentLeft); this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_LEFT);
break; break;
case CenterAlign: case CenterAlign:
this->_labelShouldRetain->setAlignment(kTextAlignmentCenter); this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_CENTER);
break; break;
case RightAlign: case RightAlign:
this->_labelShouldRetain->setAlignment(kTextAlignmentRight); this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_RIGHT);
break; break;
default: default:
@ -1348,11 +1348,11 @@ BMFontOneAtlas::BMFontOneAtlas()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
addChild(label1); addChild(label1);
label1->setPosition(Point(s.width/2, s.height/3*2)); label1->setPosition(Point(s.width/2, s.height/3*2));
auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point(0, 128)); auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point(0, 128));
addChild(label2); addChild(label2);
label2->setPosition(Point(s.width/2, s.height/3*1)); label2->setPosition(Point(s.width/2, s.height/3*1));
} }
@ -1379,7 +1379,7 @@ BMFontUnicode::BMFontUnicode()
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, kTextAlignmentLeft); auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, Label::TEXT_ALIGNMENT_LEFT);
addChild(label1); addChild(label1);
label1->setPosition(Point(s.width/2, s.height/5*4)); label1->setPosition(Point(s.width/2, s.height/5*4));

View File

@ -191,8 +191,8 @@ private:
const char* getCurrentAlignment(); const char* getCurrentAlignment();
private: private:
LabelTTF* _plabel; LabelTTF* _plabel;
TextAlignment _horizAlign; Label::TextAlignment _horizAlign;
VerticalTextAlignment _vertAlign; Label::VerticalTextAlignment _vertAlign;
}; };
class LabelTTFMultiline : public AtlasDemo class LabelTTFMultiline : public AtlasDemo

View File

@ -26,8 +26,8 @@ enum {
MenuLayerMainMenu::MenuLayerMainMenu() MenuLayerMainMenu::MenuLayerMainMenu()
{ {
setTouchEnabled(true); setTouchEnabled(true);
setTouchPriority(kMenuHandlerPriority + 1); setTouchPriority(Menu::HANDLER_PRIORITY + 1);
setTouchMode(kTouchesOneByOne); setTouchMode(Layer::TOUCHES_ONE_BY_ONE);
// Font Item // Font Item
Sprite* spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23)); Sprite* spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23));
@ -149,7 +149,7 @@ void MenuLayerMainMenu::menuCallbackConfig(Object* sender)
void MenuLayerMainMenu::allowTouches(float dt) void MenuLayerMainMenu::allowTouches(float dt)
{ {
Director* director = Director::getInstance(); Director* director = Director::getInstance();
director->getTouchDispatcher()->setPriority(kMenuHandlerPriority+1, this); director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY+1, this);
unscheduleAllSelectors(); unscheduleAllSelectors();
log("TOUCHES ALLOWED AGAIN"); log("TOUCHES ALLOWED AGAIN");
} }
@ -158,7 +158,7 @@ void MenuLayerMainMenu::menuCallbackDisabled(Object* sender)
{ {
// hijack all touch events for 5 seconds // hijack all touch events for 5 seconds
Director* director = Director::getInstance(); Director* director = Director::getInstance();
director->getTouchDispatcher()->setPriority(kMenuHandlerPriority-1, this); director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY-1, this);
schedule(schedule_selector(MenuLayerMainMenu::allowTouches), 5.0f); schedule(schedule_selector(MenuLayerMainMenu::allowTouches), 5.0f);
log("TOUCHES DISABLED FOR 5 SECONDS"); log("TOUCHES DISABLED FOR 5 SECONDS");
} }
@ -491,10 +491,10 @@ MenuLayerPriorityTest::MenuLayerPriorityTest()
MenuItemFont::setFontSize(48); MenuItemFont::setFontSize(48);
item1 = MenuItemFont::create("Toggle priority", [&](Object *sender) { item1 = MenuItemFont::create("Toggle priority", [&](Object *sender) {
if( _priority) { if( _priority) {
_menu2->setHandlerPriority(kMenuHandlerPriority + 20); _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY + 20);
_priority = false; _priority = false;
} else { } else {
_menu2->setHandlerPriority(kMenuHandlerPriority - 20); _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY - 20);
_priority = true; _priority = true;
} }
}); });

View File

@ -14,7 +14,7 @@ class TouchPoint : public Node
public: public:
TouchPoint() TouchPoint()
{ {
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
} }
virtual void draw() virtual void draw()

View File

@ -512,12 +512,12 @@ std::string NodeToWorld::title()
void CameraOrbitTest::onEnter() void CameraOrbitTest::onEnter()
{ {
TestCocosNodeDemo::onEnter(); TestCocosNodeDemo::onEnter();
Director::getInstance()->setProjection(kDirectorProjection3D); Director::getInstance()->setProjection(Director::PROJECTION_3D);
} }
void CameraOrbitTest::onExit() void CameraOrbitTest::onExit()
{ {
Director::getInstance()->setProjection(kDirectorProjection2D); Director::getInstance()->setProjection(Director::PROJECTION_2D);
TestCocosNodeDemo::onExit(); TestCocosNodeDemo::onExit();
} }
@ -584,12 +584,12 @@ void CameraZoomTest::onEnter()
{ {
TestCocosNodeDemo::onEnter(); TestCocosNodeDemo::onEnter();
Director::getInstance()->setProjection(kDirectorProjection3D); Director::getInstance()->setProjection(Director::PROJECTION_3D);
} }
void CameraZoomTest::onExit() void CameraZoomTest::onExit()
{ {
Director::getInstance()->setProjection(kDirectorProjection2D); Director::getInstance()->setProjection(Director::PROJECTION_2D);
TestCocosNodeDemo::onExit(); TestCocosNodeDemo::onExit();
} }

View File

@ -1,11 +1,5 @@
#include "ParticleTest.h" #include "ParticleTest.h"
// #include "CCActionInterval.h"
// #include "CCMenu.h"
// #include "CCLabelTTF.h"
// #include "CCLabelAtlas.h"
// #include "touch_dispatcher/CCTouchDispatcher.h"
#include "../testResource.h" #include "../testResource.h"
/*#include "support/CCPointExtension.h"*/
enum { enum {
kTagParticleCount = 1, kTagParticleCount = 1,
@ -200,7 +194,7 @@ void DemoBigFlower::onEnter()
// size, in pixels // size, in pixels
_emitter->setStartSize(80.0f); _emitter->setStartSize(80.0f);
_emitter->setStartSizeVar(40.0f); _emitter->setStartSizeVar(40.0f);
_emitter->setEndSize(kParticleStartSizeEqualToEndSize); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per second // emits per second
_emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());
@ -285,7 +279,7 @@ void DemoRotFlower::onEnter()
// size, in pixels // size, in pixels
_emitter->setStartSize(30.0f); _emitter->setStartSize(30.0f);
_emitter->setStartSizeVar(00.0f); _emitter->setStartSizeVar(00.0f);
_emitter->setEndSize(kParticleStartSizeEqualToEndSize); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per second // emits per second
_emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());
@ -650,10 +644,10 @@ void RadiusMode1::onEnter()
_emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png")); _emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png"));
// duration // duration
_emitter->setDuration(kParticleDurationInfinity); _emitter->setDuration(ParticleSystem::DURATION_INFINITY);
// radius mode // radius mode
_emitter->setEmitterMode(kParticleModeRadius); _emitter->setEmitterMode(ParticleSystem::MODE_RADIUS);
// radius mode: start and end radius in pixels // radius mode: start and end radius in pixels
_emitter->setStartRadius(0); _emitter->setStartRadius(0);
@ -701,7 +695,7 @@ void RadiusMode1::onEnter()
// size, in pixels // size, in pixels
_emitter->setStartSize(32); _emitter->setStartSize(32);
_emitter->setStartSizeVar(0); _emitter->setStartSizeVar(0);
_emitter->setEndSize(kParticleStartSizeEqualToEndSize); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per second // emits per second
_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife()); _emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());
@ -734,15 +728,15 @@ void RadiusMode2::onEnter()
_emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png")); _emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png"));
// duration // duration
_emitter->setDuration(kParticleDurationInfinity); _emitter->setDuration(ParticleSystem::DURATION_INFINITY);
// radius mode // radius mode
_emitter->setEmitterMode(kParticleModeRadius); _emitter->setEmitterMode(ParticleSystem::MODE_RADIUS);
// radius mode: start and end radius in pixels // radius mode: start and end radius in pixels
_emitter->setStartRadius(100); _emitter->setStartRadius(100);
_emitter->setStartRadiusVar(0); _emitter->setStartRadiusVar(0);
_emitter->setEndRadius(kParticleStartRadiusEqualToEndRadius); _emitter->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
_emitter->setEndRadiusVar(0); _emitter->setEndRadiusVar(0);
// radius mode: degrees per second // radius mode: degrees per second
@ -785,7 +779,7 @@ void RadiusMode2::onEnter()
// size, in pixels // size, in pixels
_emitter->setStartSize(32); _emitter->setStartSize(32);
_emitter->setStartSizeVar(0); _emitter->setStartSizeVar(0);
_emitter->setEndSize(kParticleStartSizeEqualToEndSize); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per second // emits per second
_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife()); _emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());
@ -818,15 +812,15 @@ void Issue704::onEnter()
_emitter->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); _emitter->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
// duration // duration
_emitter->setDuration(kParticleDurationInfinity); _emitter->setDuration(ParticleSystem::DURATION_INFINITY);
// radius mode // radius mode
_emitter->setEmitterMode(kParticleModeRadius); _emitter->setEmitterMode(ParticleSystem::MODE_RADIUS);
// radius mode: start and end radius in pixels // radius mode: start and end radius in pixels
_emitter->setStartRadius(50); _emitter->setStartRadius(50);
_emitter->setStartRadiusVar(0); _emitter->setStartRadiusVar(0);
_emitter->setEndRadius(kParticleStartRadiusEqualToEndRadius); _emitter->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
_emitter->setEndRadiusVar(0); _emitter->setEndRadiusVar(0);
// radius mode: degrees per second // radius mode: degrees per second
@ -869,7 +863,7 @@ void Issue704::onEnter()
// size, in pixels // size, in pixels
_emitter->setStartSize(16); _emitter->setStartSize(16);
_emitter->setStartSizeVar(0); _emitter->setStartSizeVar(0);
_emitter->setEndSize(kParticleStartSizeEqualToEndSize); _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per second // emits per second
_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife()); _emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());
@ -1163,12 +1157,12 @@ void ParticleDemo::toggleCallback(Object* pSender)
{ {
if (_emitter != NULL) if (_emitter != NULL)
{ {
if( _emitter->getPositionType() == kPositionTypeGrouped ) if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_GROUPED)
_emitter->setPositionType( kPositionTypeFree ); _emitter->setPositionType(ParticleSystem::POSITION_TYPE_FREE);
else if (_emitter->getPositionType() == kPositionTypeFree) else if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_FREE)
_emitter->setPositionType(kPositionTypeRelative); _emitter->setPositionType(ParticleSystem::POSITION_TYPE_RELATIVE);
else if (_emitter->getPositionType() == kPositionTypeRelative) else if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_RELATIVE)
_emitter->setPositionType( kPositionTypeGrouped ); _emitter->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED );
} }
} }
@ -1403,10 +1397,10 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles)
setBlendAdditive(false); setBlendAdditive(false);
// duration // duration
setDuration(kParticleDurationInfinity); setDuration(ParticleSystem::DURATION_INFINITY);
// Gravity Mode // Gravity Mode
setEmitterMode(kParticleModeGravity); setEmitterMode(ParticleSystem::MODE_GRAVITY);
// Gravity Mode: gravity // Gravity Mode: gravity
setGravity(Point(0,0)); setGravity(Point(0,0));
@ -1436,7 +1430,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles)
// size, in pixels // size, in pixels
setStartSize(25.0f); setStartSize(25.0f);
setStartSizeVar(0); setStartSizeVar(0);
setEndSize(kParticleStartSizeEqualToEndSize); setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per seconds // emits per seconds
setEmissionRate(getTotalParticles()/getLife()); setEmissionRate(getTotalParticles()/getLife());
@ -1513,7 +1507,7 @@ void MultipleParticleSystems::onEnter()
particleSystem->setPosition(Point(i*50 ,i*50)); particleSystem->setPosition(Point(i*50 ,i*50));
particleSystem->setPositionType(kPositionTypeGrouped); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
addChild(particleSystem); addChild(particleSystem);
} }
@ -1570,7 +1564,7 @@ void MultipleParticleSystemsBatched::onEnter()
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist");
particleSystem->setPositionType(kPositionTypeGrouped); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
particleSystem->setPosition(Point(i*50 ,i*50)); particleSystem->setPosition(Point(i*50 ,i*50));
batchNode->setTexture(particleSystem->getTexture()); batchNode->setTexture(particleSystem->getTexture());
@ -1633,7 +1627,7 @@ void AddAndDeleteParticleSystems::onEnter()
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist");
_batchNode->setTexture(particleSystem->getTexture()); _batchNode->setTexture(particleSystem->getTexture());
particleSystem->setPositionType(kPositionTypeGrouped); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
particleSystem->setTotalParticles(200); particleSystem->setTotalParticles(200);
particleSystem->setPosition(Point(i*15 +100,i*15+100)); particleSystem->setPosition(Point(i*15 +100,i*15+100));
@ -1660,7 +1654,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt)
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist");
//add new //add new
particleSystem->setPositionType(kPositionTypeGrouped); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
particleSystem->setTotalParticles(200); particleSystem->setTotalParticles(200);
particleSystem->setPosition(Point(rand() % 300 ,rand() % 400)); particleSystem->setPosition(Point(rand() % 300 ,rand() % 400));
@ -1724,15 +1718,15 @@ void ReorderParticleSystems::onEnter()
particleSystem->setTexture(_batchNode->getTexture()); particleSystem->setTexture(_batchNode->getTexture());
// duration // duration
particleSystem->setDuration(kParticleDurationInfinity); particleSystem->setDuration(ParticleSystem::DURATION_INFINITY);
// radius mode // radius mode
particleSystem->setEmitterMode(kParticleModeRadius); particleSystem->setEmitterMode(ParticleSystem::MODE_RADIUS);
// radius mode: 100 pixels from center // radius mode: 100 pixels from center
particleSystem->setStartRadius(100); particleSystem->setStartRadius(100);
particleSystem->setStartRadiusVar(0); particleSystem->setStartRadiusVar(0);
particleSystem->setEndRadius(kParticleStartRadiusEqualToEndRadius); particleSystem->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
particleSystem->setEndRadiusVar(0); // not used when start == end particleSystem->setEndRadiusVar(0); // not used when start == end
// radius mode: degrees per second // radius mode: degrees per second
@ -1776,7 +1770,7 @@ void ReorderParticleSystems::onEnter()
// size, in pixels // size, in pixels
particleSystem->setStartSize(32); particleSystem->setStartSize(32);
particleSystem->setStartSizeVar(0); particleSystem->setStartSizeVar(0);
particleSystem->setEndSize(kParticleStartSizeEqualToEndSize); particleSystem->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
// emits per second // emits per second
particleSystem->setEmissionRate(particleSystem->getTotalParticles()/particleSystem->getLife()); particleSystem->setEmissionRate(particleSystem->getTotalParticles()/particleSystem->getLife());
@ -1787,7 +1781,7 @@ void ReorderParticleSystems::onEnter()
_batchNode->addChild(particleSystem); _batchNode->addChild(particleSystem);
particleSystem->setPositionType(kPositionTypeFree); particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_FREE);
particleSystem->release(); particleSystem->release();

View File

@ -202,17 +202,17 @@ void ParticleMainScene::createParticleSystem()
switch( subtestNumber) switch( subtestNumber)
{ {
case 1: case 1:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
particleSystem->initWithTotalParticles(quantityParticles); particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
break; break;
case 2: case 2:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
particleSystem->initWithTotalParticles(quantityParticles); particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
break; break;
case 3: case 3:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
particleSystem->initWithTotalParticles(quantityParticles); particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
break; break;
@ -222,17 +222,17 @@ void ParticleMainScene::createParticleSystem()
// particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); // particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
// break; // break;
case 4: case 4:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
particleSystem->initWithTotalParticles(quantityParticles); particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
break; break;
case 5: case 5:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
particleSystem->initWithTotalParticles(quantityParticles); particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
break; break;
case 6: case 6:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
particleSystem->initWithTotalParticles(quantityParticles); particleSystem->initWithTotalParticles(quantityParticles);
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
break; break;
@ -252,7 +252,7 @@ void ParticleMainScene::createParticleSystem()
doTest(); doTest();
// restore the default pixel format // restore the default pixel format
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
} }
void ParticleMainScene::testNCallback(Object* pSender) void ParticleMainScene::testNCallback(Object* pSender)

View File

@ -67,36 +67,36 @@ void SubTest::initWithSubTest(int nSubTest, Node* p)
break; break;
/// ///
case 2: case 2:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100); batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100);
p->addChild(batchNode, 0); p->addChild(batchNode, 0);
break; break;
case 3: case 3:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100); batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100);
p->addChild(batchNode, 0); p->addChild(batchNode, 0);
break; break;
/// ///
case 5: case 5:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100);
p->addChild(batchNode, 0); p->addChild(batchNode, 0);
break; break;
case 6: case 6:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100);
p->addChild(batchNode, 0); p->addChild(batchNode, 0);
break; break;
/// ///
case 8: case 8:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100); batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100);
p->addChild(batchNode, 0); p->addChild(batchNode, 0);
break; break;
case 9: case 9:
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100); batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100);
p->addChild(batchNode, 0); p->addChild(batchNode, 0);
break; break;
@ -110,13 +110,13 @@ void SubTest::initWithSubTest(int nSubTest, Node* p)
batchNode->retain(); batchNode->retain();
} }
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT);
} }
Sprite* SubTest::createSpriteWithTag(int tag) Sprite* SubTest::createSpriteWithTag(int tag)
{ {
// create // create
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
Sprite* sprite = NULL; Sprite* sprite = NULL;
switch (subtestNumber) switch (subtestNumber)
@ -194,7 +194,7 @@ Sprite* SubTest::createSpriteWithTag(int tag)
break; break;
} }
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT);
return sprite; return sprite;
} }

View File

@ -87,7 +87,7 @@ void TextureTest::performTestsPNG(const char* filename)
TextureCache *cache = TextureCache::getInstance(); TextureCache *cache = TextureCache::getInstance();
log("RGBA 8888"); log("RGBA 8888");
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
texture = cache->addImage(filename); texture = cache->addImage(filename);
if( texture ) if( texture )
@ -97,7 +97,7 @@ void TextureTest::performTestsPNG(const char* filename)
cache->removeTexture(texture); cache->removeTexture(texture);
log("RGBA 4444"); log("RGBA 4444");
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
texture = cache->addImage(filename); texture = cache->addImage(filename);
if( texture ) if( texture )
@ -107,7 +107,7 @@ void TextureTest::performTestsPNG(const char* filename)
cache->removeTexture(texture); cache->removeTexture(texture);
log("RGBA 5551"); log("RGBA 5551");
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB5A1);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
texture = cache->addImage(filename); texture = cache->addImage(filename);
if( texture ) if( texture )
@ -117,7 +117,7 @@ void TextureTest::performTestsPNG(const char* filename)
cache->removeTexture(texture); cache->removeTexture(texture);
log("RGB 565"); log("RGB 565");
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB565);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
texture = cache->addImage(filename); texture = cache->addImage(filename);
if( texture ) if( texture )

View File

@ -98,7 +98,7 @@ RenderTextureSave::RenderTextureSave()
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
// create a render texture, this is what we are going to draw into // create a render texture, this is what we are going to draw into
_target = RenderTexture::create(s.width, s.height, kTexture2DPixelFormat_RGBA8888); _target = RenderTexture::create(s.width, s.height, Texture2D::PIXEL_FORMAT_RGBA8888);
_target->retain(); _target->retain();
_target->setPosition(Point(s.width / 2, s.height / 2)); _target->setPosition(Point(s.width / 2, s.height / 2));
@ -147,8 +147,8 @@ void RenderTextureSave::saveImage(cocos2d::Object *pSender)
char jpg[20]; char jpg[20];
sprintf(jpg, "image-%d.jpg", counter); sprintf(jpg, "image-%d.jpg", counter);
_target->saveToFile(png, kImageFormatPNG); _target->saveToFile(png, Image::FORMAT_PNG);
_target->saveToFile(jpg, kImageFormatJPEG); _target->saveToFile(jpg, Image::FORMAT_JPG);
Image *pImage = _target->newImage(); Image *pImage = _target->newImage();
@ -243,7 +243,7 @@ RenderTextureIssue937::RenderTextureIssue937()
/* A2 & B2 setup */ /* A2 & B2 setup */
RenderTexture *rend = RenderTexture::create(32, 64, kTexture2DPixelFormat_RGBA8888); RenderTexture *rend = RenderTexture::create(32, 64, Texture2D::PIXEL_FORMAT_RGBA8888);
if (NULL == rend) if (NULL == rend)
{ {
@ -441,7 +441,7 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil()
Sprite *sprite = Sprite::create("Images/fire.png"); Sprite *sprite = Sprite::create("Images/fire.png");
sprite->setPosition(Point(s.width * 0.25f, 0)); sprite->setPosition(Point(s.width * 0.25f, 0));
sprite->setScale(10); sprite->setScale(10);
RenderTexture *rend = RenderTexture::create(s.width, s.height, kTexture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8); RenderTexture *rend = RenderTexture::create(s.width, s.height, Texture2D::PIXEL_FORMAT_RGBA4444, GL_DEPTH24_STENCIL8);
glStencilMask(0xFF); glStencilMask(0xFF);
rend->beginWithClear(0, 0, 0, 0, 0, 0); rend->beginWithClear(0, 0, 0, 0, 0, 0);
@ -505,7 +505,7 @@ RenderTextureTargetNode::RenderTextureTargetNode()
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
/* Create the render texture */ /* Create the render texture */
RenderTexture *renderTexture = RenderTexture::create(s.width, s.height, kTexture2DPixelFormat_RGBA4444); RenderTexture *renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PIXEL_FORMAT_RGBA4444);
this->renderTexture = renderTexture; this->renderTexture = renderTexture;
renderTexture->setPosition(Point(s.width/2, s.height/2)); renderTexture->setPosition(Point(s.width/2, s.height/2));
@ -591,7 +591,7 @@ void SpriteRenderTextureBug::SimpleSprite::draw()
{ {
Size s = Director::getInstance()->getWinSize(); Size s = Director::getInstance()->getWinSize();
rt = new RenderTexture(); rt = new RenderTexture();
rt->initWithWidthAndHeight(s.width, s.height, kTexture2DPixelFormat_RGBA8888); rt->initWithWidthAndHeight(s.width, s.height, Texture2D::PIXEL_FORMAT_RGBA8888);
} }
rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f); rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f);
rt->end(); rt->end();
@ -607,22 +607,22 @@ void SpriteRenderTextureBug::SimpleSprite::draw()
// Attributes // Attributes
// //
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
#define kQuadSize sizeof(_quad.bl) #define kQuadSize sizeof(_quad.bl)
long offset = (long)&_quad; long offset = (long)&_quad;
// vertex // vertex
int diff = offsetof( V3F_C4B_T2F, vertices); int diff = offsetof( V3F_C4B_T2F, vertices);
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
// texCoods // texCoods
diff = offsetof( V3F_C4B_T2F, texCoords); diff = offsetof( V3F_C4B_T2F, texCoords);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
// color // color
diff = offsetof( V3F_C4B_T2F, colors); diff = offsetof( V3F_C4B_T2F, colors);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
} }

View File

@ -359,7 +359,7 @@ void SchedulerPauseResumeAllUser::pause(float dt)
{ {
log("Pausing"); log("Pausing");
Director* director = Director::getInstance(); Director* director = Director::getInstance();
_pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(kPriorityNonSystemMin); _pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN);
CC_SAFE_RETAIN(_pausedTargets); CC_SAFE_RETAIN(_pausedTargets);
} }
@ -463,7 +463,7 @@ void SchedulerUnscheduleAllHard::onExit()
if(!_actionManagerActive) { if(!_actionManagerActive) {
// Restore the director's action manager. // Restore the director's action manager.
Director* director = Director::getInstance(); Director* director = Director::getInstance();
director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), kPrioritySystem, false); director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false);
} }
} }
@ -548,7 +548,7 @@ void SchedulerUnscheduleAllUserLevel::tick4(float dt)
void SchedulerUnscheduleAllUserLevel::unscheduleAll(float dt) void SchedulerUnscheduleAllUserLevel::unscheduleAll(float dt)
{ {
Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(kPriorityNonSystemMin); Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN);
} }
std::string SchedulerUnscheduleAllUserLevel::title() std::string SchedulerUnscheduleAllUserLevel::title()

View File

@ -166,7 +166,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag)
GLProgram *shader = new GLProgram(); GLProgram *shader = new GLProgram();
shader->initWithVertexShaderFilename(vert, frag); shader->initWithVertexShaderFilename(vert, frag);
shader->addAttribute("aVertex", kVertexAttrib_Position); shader->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION);
shader->link(); shader->link();
shader->updateUniforms(); shader->updateUniforms();
@ -208,9 +208,9 @@ void ShaderNode::draw()
// time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version
glUniform1f(_uniformTime, _time); glUniform1f(_uniformTime, _time);
ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glDrawArrays(GL_TRIANGLES, 0, 6); glDrawArrays(GL_TRIANGLES, 0, 6);
@ -499,9 +499,9 @@ void SpriteBlur::initProgram()
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
getShaderProgram()->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
getShaderProgram()->addAttribute(kAttributeNameColor, kVertexAttrib_Color); getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
getShaderProgram()->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
@ -521,7 +521,7 @@ void SpriteBlur::initProgram()
void SpriteBlur::draw() void SpriteBlur::draw()
{ {
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex ); ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
BlendFunc blend = getBlendFunc(); BlendFunc blend = getBlendFunc();
ccGLBlendFunc(blend.src, blend.dst); ccGLBlendFunc(blend.src, blend.dst);
@ -540,15 +540,15 @@ void SpriteBlur::draw()
// vertex // vertex
int diff = offsetof( V3F_C4B_T2F, vertices); int diff = offsetof( V3F_C4B_T2F, vertices);
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
// texCoods // texCoods
diff = offsetof( V3F_C4B_T2F, texCoords); diff = offsetof( V3F_C4B_T2F, texCoords);
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
// color // color
diff = offsetof( V3F_C4B_T2F, colors); diff = offsetof( V3F_C4B_T2F, colors);
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@ -646,8 +646,8 @@ bool ShaderRetroEffect::init()
GLProgram *p = new GLProgram(); GLProgram *p = new GLProgram();
p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
p->link(); p->link();
p->updateUniforms(); p->updateUniforms();
@ -740,8 +740,8 @@ ShaderFail::ShaderFail()
GLProgram *p = new GLProgram(); GLProgram *p = new GLProgram();
p->initWithVertexShaderByteArray(ccPositionTexture_vert, shader_frag_fail); p->initWithVertexShaderByteArray(ccPositionTexture_vert, shader_frag_fail);
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
p->link(); p->link();
p->updateUniforms(); p->updateUniforms();

View File

@ -1 +1 @@
715f77e7fdc777c303783dad8b6ce3e1b19526d7 4b0a077e077119ecd733b35f41231c3b6668d2f7

View File

@ -1313,7 +1313,7 @@ void TexturePixelFormat::onEnter()
addChild(background, -1); addChild(background, -1);
// RGBA 8888 image (32-bit) // RGBA 8888 image (32-bit)
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
Sprite *sprite1 = Sprite::create("Images/test-rgba1.png"); Sprite *sprite1 = Sprite::create("Images/test-rgba1.png");
sprite1->setPosition(Point(1*s.width/7, s.height/2+32)); sprite1->setPosition(Point(1*s.width/7, s.height/2+32));
addChild(sprite1, 0); addChild(sprite1, 0);
@ -1322,7 +1322,7 @@ void TexturePixelFormat::onEnter()
TextureCache::getInstance()->removeTexture(sprite1->getTexture()); TextureCache::getInstance()->removeTexture(sprite1->getTexture());
// RGBA 4444 image (16-bit) // RGBA 4444 image (16-bit)
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
Sprite *sprite2 = Sprite::create("Images/test-rgba1.png"); Sprite *sprite2 = Sprite::create("Images/test-rgba1.png");
sprite2->setPosition(Point(2*s.width/7, s.height/2-32)); sprite2->setPosition(Point(2*s.width/7, s.height/2-32));
addChild(sprite2, 0); addChild(sprite2, 0);
@ -1331,7 +1331,7 @@ void TexturePixelFormat::onEnter()
TextureCache::getInstance()->removeTexture(sprite2->getTexture()); TextureCache::getInstance()->removeTexture(sprite2->getTexture());
// RGB5A1 image (16-bit) // RGB5A1 image (16-bit)
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB5A1);
Sprite *sprite3 = Sprite::create("Images/test-rgba1.png"); Sprite *sprite3 = Sprite::create("Images/test-rgba1.png");
sprite3->setPosition(Point(3*s.width/7, s.height/2+32)); sprite3->setPosition(Point(3*s.width/7, s.height/2+32));
addChild(sprite3, 0); addChild(sprite3, 0);
@ -1340,7 +1340,7 @@ void TexturePixelFormat::onEnter()
TextureCache::getInstance()->removeTexture(sprite3->getTexture()); TextureCache::getInstance()->removeTexture(sprite3->getTexture());
// RGB888 image // RGB888 image
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB888);
Sprite *sprite4 = Sprite::create("Images/test-rgba1.png"); Sprite *sprite4 = Sprite::create("Images/test-rgba1.png");
sprite4->setPosition(Point(4*s.width/7, s.height/2-32)); sprite4->setPosition(Point(4*s.width/7, s.height/2-32));
addChild(sprite4, 0); addChild(sprite4, 0);
@ -1349,7 +1349,7 @@ void TexturePixelFormat::onEnter()
TextureCache::getInstance()->removeTexture(sprite4->getTexture()); TextureCache::getInstance()->removeTexture(sprite4->getTexture());
// RGB565 image (16-bit) // RGB565 image (16-bit)
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB565);
Sprite *sprite5 = Sprite::create("Images/test-rgba1.png"); Sprite *sprite5 = Sprite::create("Images/test-rgba1.png");
sprite5->setPosition(Point(5*s.width/7, s.height/2+32)); sprite5->setPosition(Point(5*s.width/7, s.height/2+32));
addChild(sprite5, 0); addChild(sprite5, 0);
@ -1358,7 +1358,7 @@ void TexturePixelFormat::onEnter()
TextureCache::getInstance()->removeTexture(sprite5->getTexture()); TextureCache::getInstance()->removeTexture(sprite5->getTexture());
// A8 image (8-bit) // A8 image (8-bit)
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
Sprite *sprite6 = Sprite::create("Images/test-rgba1.png"); Sprite *sprite6 = Sprite::create("Images/test-rgba1.png");
sprite6->setPosition(Point(6*s.width/7, s.height/2-32)); sprite6->setPosition(Point(6*s.width/7, s.height/2-32));
addChild(sprite6, 0); addChild(sprite6, 0);
@ -1382,7 +1382,7 @@ void TexturePixelFormat::onEnter()
sprite5->runAction(seq_4ever5); sprite5->runAction(seq_4ever5);
// restore default // restore default
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT);
TextureCache::getInstance()->dumpCachedTextureInfo(); TextureCache::getInstance()->dumpCachedTextureInfo();
} }
@ -1937,7 +1937,7 @@ TexturePVRv3Premult::TexturePVRv3Premult()
transformSprite(pvr2); transformSprite(pvr2);
// PNG // PNG
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
TextureCache::getInstance()->removeTextureForKey("Images/grossinis_sister1-testalpha.png"); TextureCache::getInstance()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
Sprite *png = Sprite::create("Images/grossinis_sister1-testalpha.png"); Sprite *png = Sprite::create("Images/grossinis_sister1-testalpha.png");
addChild(png, 0); addChild(png, 0);

View File

@ -150,12 +150,12 @@ void TMXOrthoTest::onEnter()
{ {
TileDemo::onEnter(); TileDemo::onEnter();
Director::getInstance()->setProjection(kDirectorProjection3D); Director::getInstance()->setProjection(Director::PROJECTION_3D);
} }
void TMXOrthoTest::onExit() void TMXOrthoTest::onExit()
{ {
Director::getInstance()->setProjection(kDirectorProjection2D); Director::getInstance()->setProjection(Director::PROJECTION_2D);
TileDemo::onExit(); TileDemo::onExit();
} }
@ -973,13 +973,13 @@ void TMXIsoVertexZ::onEnter()
TileDemo::onEnter(); TileDemo::onEnter();
// TIP: 2d projection should be used // TIP: 2d projection should be used
Director::getInstance()->setProjection(kDirectorProjection2D); Director::getInstance()->setProjection(Director::PROJECTION_2D);
} }
void TMXIsoVertexZ::onExit() void TMXIsoVertexZ::onExit()
{ {
// At exit use any other projection. // At exit use any other projection.
// Director::getInstance()->setProjection:kDirectorProjection3D); // Director::getInstance()->setProjection:Director::PROJECTION_3D);
TileDemo::onExit(); TileDemo::onExit();
} }
@ -1042,13 +1042,13 @@ void TMXOrthoVertexZ::onEnter()
TileDemo::onEnter(); TileDemo::onEnter();
// TIP: 2d projection should be used // TIP: 2d projection should be used
Director::getInstance()->setProjection(kDirectorProjection2D); Director::getInstance()->setProjection(Director::PROJECTION_2D);
} }
void TMXOrthoVertexZ::onExit() void TMXOrthoVertexZ::onExit()
{ {
// At exit use any other projection. // At exit use any other projection.
// Director::getInstance()->setProjection:kDirectorProjection3D); // Director::getInstance()->setProjection:Director::PROJECTION_3D);
TileDemo::onExit(); TileDemo::onExit();
} }

View File

@ -18,7 +18,7 @@ class FlipXLeftOver : public TransitionFlipX
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionFlipX::create(t, s, kTransitionOrientationLeftOver); return TransitionFlipX::create(t, s, TransitionScene::ORIENTATION_LEFT_OVER);
} }
}; };
@ -27,7 +27,7 @@ class FlipXRightOver : public TransitionFlipX
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionFlipX::create(t, s, kTransitionOrientationRightOver); return TransitionFlipX::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
}; };
@ -36,7 +36,7 @@ class FlipYUpOver : public TransitionFlipY
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionFlipY::create(t, s, kTransitionOrientationUpOver); return TransitionFlipY::create(t, s, TransitionScene::ORIENTATION_UP_OVER);
} }
}; };
@ -45,7 +45,7 @@ class FlipYDownOver : public TransitionFlipY
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionFlipY::create(t, s, kTransitionOrientationDownOver); return TransitionFlipY::create(t, s, TransitionScene::ORIENTATION_DOWN_OVER);
} }
}; };
@ -54,7 +54,7 @@ class FlipAngularLeftOver : public TransitionFlipAngular
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionFlipAngular::create(t, s, kTransitionOrientationLeftOver); return TransitionFlipAngular::create(t, s, TransitionScene::ORIENTATION_LEFT_OVER);
} }
}; };
@ -63,7 +63,7 @@ class FlipAngularRightOver : public TransitionFlipAngular
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionFlipAngular::create(t, s, kTransitionOrientationRightOver); return TransitionFlipAngular::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
}; };
@ -72,7 +72,7 @@ class ZoomFlipXLeftOver : public TransitionZoomFlipX
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionZoomFlipX::create(t, s, kTransitionOrientationLeftOver); return TransitionZoomFlipX::create(t, s, TransitionScene::ORIENTATION_LEFT_OVER);
} }
}; };
@ -81,7 +81,7 @@ class ZoomFlipXRightOver : public TransitionZoomFlipX
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionZoomFlipX::create(t, s, kTransitionOrientationRightOver); return TransitionZoomFlipX::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
}; };
@ -90,7 +90,7 @@ class ZoomFlipYUpOver : public TransitionZoomFlipY
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionZoomFlipY::create(t, s, kTransitionOrientationUpOver); return TransitionZoomFlipY::create(t, s, TransitionScene::ORIENTATION_UP_OVER);
} }
}; };
@ -100,7 +100,7 @@ class ZoomFlipYDownOver : public TransitionZoomFlipY
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionZoomFlipY::create(t, s, kTransitionOrientationDownOver); return TransitionZoomFlipY::create(t, s, TransitionScene::ORIENTATION_DOWN_OVER);
} }
}; };
@ -109,7 +109,7 @@ class ZoomFlipAngularLeftOver : public TransitionZoomFlipAngular
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationLeftOver); return TransitionZoomFlipAngular::create(t, s, TransitionScene::ORIENTATION_LEFT_OVER);
} }
}; };
@ -118,7 +118,7 @@ class ZoomFlipAngularRightOver : public TransitionZoomFlipAngular
public: public:
static TransitionScene* create(float t, Scene* s) static TransitionScene* create(float t, Scene* s)
{ {
return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationRightOver); return TransitionZoomFlipAngular::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
} }
}; };

View File

@ -33,7 +33,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// initialize director // initialize director
Director *pDirector = Director::getInstance(); Director *pDirector = Director::getInstance();
pDirector->setOpenGLView(EGLView::getInstance()); pDirector->setOpenGLView(EGLView::getInstance());
pDirector->setProjection(kDirectorProjection2D); pDirector->setProjection(Director::PROJECTION_2D);
Size screenSize = EGLView::getInstance()->getFrameSize(); Size screenSize = EGLView::getInstance()->getFrameSize();

View File

@ -29,7 +29,7 @@ bool AppDelegate::applicationDidFinishLaunching()
// initialize director // initialize director
Director *pDirector = Director::getInstance(); Director *pDirector = Director::getInstance();
pDirector->setOpenGLView(EGLView::getInstance()); pDirector->setOpenGLView(EGLView::getInstance());
pDirector->setProjection(kDirectorProjection2D); pDirector->setProjection(Director::PROJECTION_2D);
Size screenSize = EGLView::getInstance()->getFrameSize(); Size screenSize = EGLView::getInstance()->getFrameSize();

Some files were not shown because too many files have changed in this diff Show More