mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3257 from minggo/iss2430-modify_enum
move enum into class
This commit is contained in:
commit
7dc710a77f
|
@ -1 +1 @@
|
|||
61930829c286fd6ec795bccee6e841a60e8ba34f
|
||||
a30cd2dad1df734bd988309d3b344ff946601cb4
|
|
@ -8,6 +8,7 @@ LOCAL_MODULE_FILENAME := libcocos2d
|
|||
|
||||
LOCAL_SRC_FILES := \
|
||||
CCConfiguration.cpp \
|
||||
CCDeprecated.cpp \
|
||||
CCScheduler.cpp \
|
||||
CCCamera.cpp \
|
||||
ccFPSImages.c \
|
||||
|
|
|
@ -35,15 +35,6 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
typedef enum _ccConfigurationType {
|
||||
ConfigurationError,
|
||||
ConfigurationString,
|
||||
ConfigurationInt,
|
||||
ConfigurationDouble,
|
||||
ConfigurationBoolean
|
||||
} ccConfigurationType;
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup global
|
||||
* @{
|
||||
|
@ -55,6 +46,15 @@ typedef enum _ccConfigurationType {
|
|||
class CC_DLL Configuration : public Object
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
ERROR,
|
||||
STRING,
|
||||
INT,
|
||||
DOUBLE,
|
||||
BOOLEAN,
|
||||
};
|
||||
|
||||
/** returns a shared instance of Configuration */
|
||||
static Configuration *getInstance();
|
||||
|
||||
|
|
|
@ -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
|
|
@ -146,7 +146,7 @@ bool Director::init(void)
|
|||
_scheduler = new Scheduler();
|
||||
// action manager
|
||||
_actionManager = new ActionManager();
|
||||
_scheduler->scheduleUpdateForTarget(_actionManager, kPrioritySystem, false);
|
||||
_scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false);
|
||||
// touchDispatcher
|
||||
_touchDispatcher = new TouchDispatcher();
|
||||
_touchDispatcher->init();
|
||||
|
@ -210,22 +210,22 @@ void Director::setDefaultValues(void)
|
|||
// GL projection
|
||||
const char *projection = conf->getCString("cocos2d.x.gl.projection", "3d");
|
||||
if( strcmp(projection, "3d") == 0 )
|
||||
_projection = kDirectorProjection3D;
|
||||
_projection = PROJECTION_3D;
|
||||
else if (strcmp(projection, "2d") == 0)
|
||||
_projection = kDirectorProjection2D;
|
||||
_projection = PROJECTION_2D;
|
||||
else if (strcmp(projection, "custom") == 0)
|
||||
_projection = kDirectorProjectionCustom;
|
||||
_projection = PROJECTION_CUSTOM;
|
||||
else
|
||||
CCASSERT(false, "Invalid projection value");
|
||||
|
||||
// Default pixel format for PNG images with alpha
|
||||
const char *pixel_format = conf->getCString("cocos2d.x.texture.pixel_format_for_png", "rgba8888");
|
||||
if( strcmp(pixel_format, "rgba8888") == 0 )
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
else if( strcmp(pixel_format, "rgba4444") == 0 )
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
else if( strcmp(pixel_format, "rgba5551") == 0 )
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB5A1);
|
||||
|
||||
// PVR v2 has alpha premultiplied ?
|
||||
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;
|
||||
}
|
||||
|
||||
void Director::setProjection(ccDirectorProjection kProjection)
|
||||
void Director::setProjection(Projection kProjection)
|
||||
{
|
||||
Size size = _winSizeInPoints;
|
||||
|
||||
|
@ -393,7 +393,7 @@ void Director::setProjection(ccDirectorProjection kProjection)
|
|||
|
||||
switch (kProjection)
|
||||
{
|
||||
case kDirectorProjection2D:
|
||||
case PROJECTION_2D:
|
||||
{
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadIdentity();
|
||||
|
@ -405,7 +405,7 @@ void Director::setProjection(ccDirectorProjection kProjection)
|
|||
}
|
||||
break;
|
||||
|
||||
case kDirectorProjection3D:
|
||||
case PROJECTION_3D:
|
||||
{
|
||||
float zeye = this->getZEye();
|
||||
|
||||
|
@ -431,7 +431,7 @@ void Director::setProjection(ccDirectorProjection kProjection)
|
|||
}
|
||||
break;
|
||||
|
||||
case kDirectorProjectionCustom:
|
||||
case PROJECTION_CUSTOM:
|
||||
if (_projectionDelegate)
|
||||
{
|
||||
_projectionDelegate->updateProjection();
|
||||
|
@ -864,8 +864,8 @@ void Director::createStatsLabel()
|
|||
FileUtils::getInstance()->purgeCachedEntries();
|
||||
}
|
||||
|
||||
Texture2DPixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
unsigned char *data = NULL;
|
||||
unsigned int data_len = 0;
|
||||
getFPSImageData(&data, &data_len);
|
||||
|
|
|
@ -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. */
|
||||
class LabelAtlas;
|
||||
class Scene;
|
||||
|
@ -99,6 +82,24 @@ and when to execute the Scenes.
|
|||
class CC_DLL Director : public Object, public TypeInfo
|
||||
{
|
||||
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 */
|
||||
static Director* getInstance();
|
||||
|
||||
|
@ -147,8 +148,8 @@ public:
|
|||
/** Sets an OpenGL projection
|
||||
@since v0.8.2
|
||||
*/
|
||||
inline ccDirectorProjection getProjection(void) { return _projection; }
|
||||
void setProjection(ccDirectorProjection kProjection);
|
||||
inline Projection getProjection(void) { return _projection; }
|
||||
void setProjection(Projection kProjection);
|
||||
|
||||
/** Sets the glViewport*/
|
||||
void setViewport();
|
||||
|
@ -477,7 +478,7 @@ protected:
|
|||
bool _nextDeltaTimeZero;
|
||||
|
||||
/* projection used */
|
||||
ccDirectorProjection _projection;
|
||||
Projection _projection;
|
||||
|
||||
/* window size in points */
|
||||
Size _winSizeInPoints;
|
||||
|
|
|
@ -240,6 +240,12 @@ SEL_SCHEDULE Timer::getSelector() const
|
|||
|
||||
// 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)
|
||||
: _timeScale(1.0f)
|
||||
, _updatesNegList(NULL)
|
||||
|
@ -577,7 +583,7 @@ void Scheduler::unscheduleUpdateForTarget(const Object *target)
|
|||
|
||||
void Scheduler::unscheduleAll(void)
|
||||
{
|
||||
unscheduleAllWithMinPriority(kPrioritySystem);
|
||||
unscheduleAllWithMinPriority(PRIORITY_SYSTEM);
|
||||
}
|
||||
|
||||
void Scheduler::unscheduleAllWithMinPriority(int nMinPriority)
|
||||
|
@ -759,7 +765,7 @@ bool Scheduler::isTargetPaused(Object *target)
|
|||
|
||||
Set* Scheduler::pauseAllTargets()
|
||||
{
|
||||
return pauseAllTargetsWithMinPriority(kPrioritySystem);
|
||||
return pauseAllTargetsWithMinPriority(PRIORITY_SYSTEM);
|
||||
}
|
||||
|
||||
Set* Scheduler::pauseAllTargetsWithMinPriority(int nMinPriority)
|
||||
|
|
|
@ -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;
|
||||
//
|
||||
// Timer
|
||||
|
@ -121,6 +115,12 @@ The 'custom selectors' should be avoided when possible. It is faster, and consum
|
|||
class CC_DLL Scheduler : public Object
|
||||
{
|
||||
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(void);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, unsigned int tileWidth, unsi
|
|||
_quadsToDraw = itemsToRender;
|
||||
|
||||
// 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");
|
||||
|
||||
return true;
|
||||
|
|
|
@ -823,7 +823,7 @@ public:
|
|||
* Since v2.0, each rendering node must set its shader program.
|
||||
* It should be set in initialize phase.
|
||||
* @code
|
||||
* node->setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
* node->setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
* @endcode
|
||||
*
|
||||
* @param The shader program which fetchs from ShaderCache.
|
||||
|
|
|
@ -157,7 +157,7 @@ bool DrawNode::init()
|
|||
_blendFunc.src = CC_BLEND_SRC;
|
||||
_blendFunc.dst = CC_BLEND_DST;
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionLengthTexureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR));
|
||||
|
||||
ensureCapacity(512);
|
||||
|
||||
|
@ -170,14 +170,14 @@ bool DrawNode::init()
|
|||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(kVertexAttrib_Position);
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
|
||||
|
||||
glEnableVertexAttribArray(kVertexAttrib_Color);
|
||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
|
||||
|
||||
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
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);
|
||||
|
||||
|
@ -211,17 +211,17 @@ void DrawNode::render()
|
|||
#if CC_TEXTURE_ATLAS_USE_VAO
|
||||
ccGLBindVAO(_vao);
|
||||
#else
|
||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
||||
ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
// 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
|
||||
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
|
||||
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
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, _bufferCount);
|
||||
|
|
|
@ -93,7 +93,7 @@ static void lazy_init( void )
|
|||
//
|
||||
// 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_nColorLocation = glGetUniformLocation( s_pShader->getProgram(), "u_color");
|
||||
|
@ -125,7 +125,7 @@ void ccDrawPoint( const Point& point )
|
|||
p.x = point.x;
|
||||
p.y = point.y;
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
s_pShader->use();
|
||||
s_pShader->setUniformsForBuiltins();
|
||||
|
||||
|
@ -134,9 +134,9 @@ void ccDrawPoint( const Point& point )
|
|||
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, &p);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, &p);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
glDrawArrays(GL_POINTS, 0, 1);
|
||||
|
@ -148,7 +148,7 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
|
|||
{
|
||||
lazy_init();
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
s_pShader->use();
|
||||
s_pShader->setUniformsForBuiltins();
|
||||
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
|
||||
|
@ -162,9 +162,9 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
|
|||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, points);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points);
|
||||
#endif // EMSCRIPTEN
|
||||
}
|
||||
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,
|
||||
// but want to make sure this continues to work even if they do.
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
|
||||
#endif // EMSCRIPTEN
|
||||
}
|
||||
|
||||
|
@ -205,12 +205,12 @@ void ccDrawLine( const Point& origin, const Point& destination )
|
|||
s_pShader->setUniformsForBuiltins();
|
||||
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
#endif // EMSCRIPTEN
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
|
||||
|
@ -245,16 +245,16 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg
|
|||
s_pShader->setUniformsForBuiltins();
|
||||
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
// iPhone and 32-bit machines optimization
|
||||
if( sizeof(Point) == sizeof(Vertex2F) )
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
if( closePolygon )
|
||||
|
@ -273,9 +273,9 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg
|
|||
}
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
if( closePolygon )
|
||||
|
@ -297,7 +297,7 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co
|
|||
s_pShader->setUniformsForBuiltins();
|
||||
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
|
||||
Vertex2F* newPoli = new Vertex2F[numberOfPoints];
|
||||
|
@ -307,9 +307,9 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co
|
|||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli);
|
||||
#endif // EMSCRIPTEN
|
||||
}
|
||||
else
|
||||
|
@ -321,9 +321,9 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co
|
|||
}
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||
#endif // EMSCRIPTEN
|
||||
}
|
||||
|
||||
|
@ -362,13 +362,13 @@ void ccDrawCircle( const Point& center, float radius, float angle, unsigned int
|
|||
s_pShader->setUniformsForBuiltins();
|
||||
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
#endif // EMSCRIPTEN
|
||||
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->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
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->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
#endif // EMSCRIPTEN
|
||||
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);
|
||||
CC_SAFE_DELETE_ARRAY(vertices);
|
||||
|
@ -505,13 +505,13 @@ void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segm
|
|||
s_pShader->setUniformsForBuiltins();
|
||||
s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*)&s_tColor.r, 1);
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
#endif // EMSCRIPTEN
|
||||
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->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1);
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
#endif // EMSCRIPTEN
|
||||
glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1);
|
||||
CC_SAFE_DELETE_ARRAY(vertices);
|
||||
|
|
|
@ -102,7 +102,7 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFli
|
|||
bRet = false;
|
||||
}
|
||||
|
||||
_shaderProgram = ShaderCache::getInstance()->programForKey(kShader_PositionTexture);
|
||||
_shaderProgram = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE);
|
||||
calculateVertexPoints();
|
||||
|
||||
return bRet;
|
||||
|
@ -117,7 +117,7 @@ bool GridBase::initWithSize(const Size& gridSize)
|
|||
unsigned long POTHigh = ccNextPOT((unsigned int)s.height);
|
||||
|
||||
// we only use rgba8888
|
||||
Texture2DPixelFormat format = kTexture2DPixelFormat_RGBA8888;
|
||||
Texture2D::PixelFormat format = Texture2D::PIXEL_FORMAT_RGBA8888;
|
||||
|
||||
void *data = calloc((int)(POTWide * POTHigh * 4), 1);
|
||||
if (! data)
|
||||
|
@ -161,7 +161,7 @@ void GridBase::setActive(bool bActive)
|
|||
if (! bActive)
|
||||
{
|
||||
Director *pDirector = Director::getInstance();
|
||||
ccDirectorProjection proj = pDirector->getProjection();
|
||||
Director::Projection proj = pDirector->getProjection();
|
||||
pDirector->setProjection(proj);
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ void GridBase::beforeDraw(void)
|
|||
_directorProjection = director->getProjection();
|
||||
|
||||
// 2d projection
|
||||
// [director setProjection:kDirectorProjection2D];
|
||||
// [director setProjection:Director::PROJECTION_2D];
|
||||
set2DProjection();
|
||||
_grabber->beforeRender(_texture);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ void Grid3D::blit(void)
|
|||
{
|
||||
int n = _gridSize.width * _gridSize.height;
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_TEX_COORDS );
|
||||
_shaderProgram->use();
|
||||
_shaderProgram->setUniformsForBuiltins();;
|
||||
|
||||
|
@ -328,20 +328,20 @@ void Grid3D::blit(void)
|
|||
|
||||
// position
|
||||
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
|
||||
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);
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0);
|
||||
#else
|
||||
// position
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, _vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices);
|
||||
|
||||
// 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);
|
||||
#endif // EMSCRIPTEN
|
||||
|
@ -537,26 +537,26 @@ void TiledGrid3D::blit(void)
|
|||
//
|
||||
// Attributes
|
||||
//
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_TEX_COORDS );
|
||||
#ifdef EMSCRIPTEN
|
||||
int numQuads = _gridSize.width * _gridSize.height;
|
||||
|
||||
// position
|
||||
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
|
||||
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);
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0);
|
||||
#else
|
||||
// position
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, _vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices);
|
||||
|
||||
// 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);
|
||||
#endif // EMSCRIPTEN
|
||||
|
|
|
@ -99,7 +99,7 @@ protected:
|
|||
Grabber *_grabber;
|
||||
bool _isTextureFlipped;
|
||||
GLProgram* _shaderProgram;
|
||||
ccDirectorProjection _directorProjection;
|
||||
Director::Projection _directorProjection;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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). */
|
||||
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). */
|
||||
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 const Color3B ccYELLOW = Color3B::YELLOW;
|
||||
CC_DEPRECATED_ATTRIBUTE const Color3B ccGREEN = Color3B::GREEN;
|
||||
CC_DEPRECATED_ATTRIBUTE const Color3B ccBLUE = Color3B::BLUE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Color3B ccRED = Color3B::RED;
|
||||
CC_DEPRECATED_ATTRIBUTE const Color3B ccMAGENTA = Color3B::MAGENTA;
|
||||
CC_DEPRECATED_ATTRIBUTE const Color3B ccBLACK = Color3B::BLACK;
|
||||
CC_DEPRECATED_ATTRIBUTE const Color3B ccORANGE = Color3B::ORANGE;
|
||||
CC_DEPRECATED_ATTRIBUTE const Color3B ccGRAY = Color3B::GRAY;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccWHITE;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccYELLOW;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGREEN;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLUE;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccRED;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccMAGENTA;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLACK;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Color3B ccORANGE;
|
||||
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)
|
||||
{
|
||||
|
@ -471,9 +471,20 @@ CC_DEPRECATED_ATTRIBUTE static inline Tex2F tex2(const float u, const float v)
|
|||
return t;
|
||||
}
|
||||
|
||||
#define CCAffineTransformMake AffineTransformMake
|
||||
#define CCPointApplyAffineTransform PointApplyAffineTransform
|
||||
#define CCSizeApplyAffineTransform SizeApplyAffineTransform
|
||||
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty)
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
@ -515,8 +526,10 @@ CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformInvert(co
|
|||
return AffineTransformInvert(t);
|
||||
}
|
||||
|
||||
#define CCAffineTransformIdentity AffineTransformIdentity
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformIdentity()
|
||||
{
|
||||
return AffineTransformMakeIdentity();
|
||||
}
|
||||
|
||||
// CC prefix compatibility
|
||||
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 FontDefinition ccFontDefinition;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef VerticalTextAlignment CCVerticalTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TextAlignment CCTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimerType CCProgressTimerType;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Label::VerticalTextAlignment CCVerticalTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Label::TextAlignment CCTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
|
||||
|
||||
#define kCCVertexAttrib_Position kVertexAttrib_Position
|
||||
#define kCCVertexAttrib_Color kVertexAttrib_Color
|
||||
#define kCCVertexAttrib_TexCoords kVertexAttrib_TexCoords
|
||||
#define kCCVertexAttrib_MAX kVertexAttrib_MAX
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Position;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Color;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_TexCoords;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_MAX;
|
||||
|
||||
#define kCCUniformPMatrix kUniformPMatrix
|
||||
#define kCCUniformMVMatrix kUniformMVMatrix
|
||||
#define kCCUniformMVPMatrix kUniformMVPMatrix
|
||||
#define kCCUniformTime kUniformTime
|
||||
#define kCCUniformSinTime kUniformSinTime
|
||||
#define kCCUniformCosTime kUniformCosTime
|
||||
#define kCCUniformRandom01 kUniformRandom01
|
||||
#define kCCUniformSampler kUniformSampler
|
||||
#define kCCUniform_MAX kUniform_MAX
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformPMatrix;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVMatrix;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVPMatrix;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformTime;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSinTime;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformCosTime;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformRandom01;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSampler;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCUniform_MAX;
|
||||
|
||||
|
||||
#define kCCShader_PositionTextureColor kShader_PositionTextureColor
|
||||
#define kCCShader_PositionTextureColorAlphaTest kShader_PositionTextureColorAlphaTest
|
||||
#define kCCShader_PositionColor kShader_PositionColor
|
||||
#define kCCShader_PositionTexture kShader_PositionTexture
|
||||
#define kCCShader_PositionTexture_uColor kShader_PositionTexture_uColor
|
||||
#define kCCShader_PositionTextureA8Color kShader_PositionTextureA8Color
|
||||
#define kCCShader_Position_uColor kShader_Position_uColor
|
||||
#define kCCShader_PositionLengthTexureColor kShader_PositionLengthTexureColor
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColor;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColorAlphaTest;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionColor;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture_uColor;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureA8Color;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_Position_uColor;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionLengthTexureColor;
|
||||
|
||||
// uniform names
|
||||
#define kCCUniformPMatrix_s kUniformPMatrix_s
|
||||
#define kCCUniformMVMatrix_s kUniformMVMatrix_s
|
||||
#define kCCUniformMVPMatrix_s kUniformMVPMatrix_s
|
||||
#define kCCUniformTime_s kUniformTime_s
|
||||
#define kCCUniformSinTime_s kUniformSinTime_s
|
||||
#define kCCUniformCosTime_s kUniformCosTime_s
|
||||
#define kCCUniformRandom01_s kUniformRandom01_s
|
||||
#define kCCUniformSampler_s kUniformSampler_s
|
||||
#define kCCUniformAlphaTestValue kUniformAlphaTestValue
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformPMatrix_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVMatrix_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVPMatrix_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformTime_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSinTime_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformCosTime_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformRandom01_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSampler_s;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformAlphaTestValue;
|
||||
|
||||
// Attribute names
|
||||
#define kCCAttributeNameColor kAttributeNameColor
|
||||
#define kCCAttributeNamePosition kAttributeNamePosition
|
||||
#define kCCAttributeNameTexCoord kAttributeNameTexCoord
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameColor;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNamePosition;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameTexCoord;
|
||||
|
||||
#define kCCVertexAttribFlag_None kVertexAttribFlag_None
|
||||
#define kCCVertexAttribFlag_Position kVertexAttribFlag_Position
|
||||
#define kCCVertexAttribFlag_Color kVertexAttribFlag_Color
|
||||
#define kCCVertexAttribFlag_TexCoords kVertexAttribFlag_TexCoords
|
||||
#define kCCVertexAttribFlag_PosColorTex kVertexAttribFlag_PosColorTex
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_None;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Position;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Color;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_TexCoords;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_PosColorTex;
|
||||
|
||||
#define kCCProgressTimerTypeRadial kProgressTimerTypeRadial
|
||||
#define kCCProgressTimerTypeBar kProgressTimerTypeBar
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeRadial;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeBar;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum ProgressTimer::Type ProgressTimerType;
|
||||
|
||||
#define kCCDirectorProjection2D kDirectorProjection2D
|
||||
#define kCCDirectorProjection3D kDirectorProjection3D
|
||||
#define kCCDirectorProjectionCustom kDirectorProjectionCustom
|
||||
#define kCCDirectorProjectionDefault kDirectorProjectionDefault
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjection2D;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjection3D;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjectionCustom;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCDirectorProjectionDefault;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Director::Projection ccDirectorProjection;
|
||||
|
||||
#define kCCVerticalTextAlignmentTop kVerticalTextAlignmentTop
|
||||
#define kCCVerticalTextAlignmentCenter kVerticalTextAlignmentCenter
|
||||
#define kCCVerticalTextAlignmentBottom kVerticalTextAlignmentBottom
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationError;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationString;
|
||||
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
|
||||
#define kCCTextAlignmentCenter kTextAlignmentCenter
|
||||
#define kCCTextAlignmentRight kTextAlignmentRight
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentTop;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCVerticalTextAlignmentCenter;
|
||||
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
|
||||
#define kCCTexture2DPixelFormat_RGB888 kTexture2DPixelFormat_RGB888
|
||||
#define kCCTexture2DPixelFormat_RGB565 kTexture2DPixelFormat_RGB565
|
||||
#define kCCTexture2DPixelFormat_A8 kTexture2DPixelFormat_A8
|
||||
#define kCCTexture2DPixelFormat_I8 kTexture2DPixelFormat_I8
|
||||
#define kCCTexture2DPixelFormat_AI88 kTexture2DPixelFormat_AI88
|
||||
#define kCCTexture2DPixelFormat_RGBA4444 kTexture2DPixelFormat_RGBA4444
|
||||
#define kCCTexture2DPixelFormat_RGB5A1 kTexture2DPixelFormat_RGB5A1
|
||||
#define kCCTexture2DPixelFormat_PVRTC4 kTexture2DPixelFormat_PVRTC4
|
||||
#define kCCTexture2DPixelFormat_PVRTC2 kTexture2DPixelFormat_PVRTC2
|
||||
#define kCCTexture2DPixelFormat_Default kTexture2DPixelFormat_Default
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGBA8888;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGB888;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGB565;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_A8;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_I8;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_AI88;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGBA4444;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_RGB5A1;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_PVRTC4;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_PVRTC2;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTexture2DPixelFormat_Default;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Texture2D::PixelFormat CCTexture2DPixelFormat;
|
||||
|
||||
#define kCCLabelAutomaticWidth kLabelAutomaticWidth
|
||||
|
||||
#define kCCParticleDurationInfinity kParticleDurationInfinity
|
||||
#define kCCParticleStartSizeEqualToEndSize kParticleStartSizeEqualToEndSize
|
||||
#define kCCParticleStartRadiusEqualToEndRadius kParticleStartRadiusEqualToEndRadius
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleDurationInfinity;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartSizeEqualToEndSize;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartRadiusEqualToEndRadius;
|
||||
|
||||
#define kCCParticleModeGravity kParticleModeGravity
|
||||
#define kCCParticleModeRadius kParticleModeRadius
|
||||
#define kCCPositionTypeFree kPositionTypeFree
|
||||
#define kCCPositionTypeRelative kPositionTypeRelative
|
||||
#define kCCPositionTypeGrouped kPositionTypeGrouped
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleModeGravity;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleModeRadius;
|
||||
|
||||
#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
|
||||
#define kCCMenuStateWaiting kMenuStateWaiting
|
||||
#define kCCMenuStateTrackingTouch kMenuStateTrackingTouch
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuHandlerPriority;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuStateWaiting;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuStateTrackingTouch;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Menu::State tMenuState;
|
||||
|
||||
#define kCCTouchesOneByOne kTouchesOneByOne
|
||||
#define kCCTouchesAllAtOnce kTouchesAllAtOnce
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTouchesOneByOne;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTouchesAllAtOnce;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Layer::TouchesMode ccTouchesMode;
|
||||
|
||||
#define kCCImageFormatPNG kImageFormatPNG
|
||||
#define kCCImageFormatJPEG kImageFormatJPEG
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCImageFormatPNG;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCImageFormatJPEG;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Image::Format tImageFormat;
|
||||
|
||||
#define kCCTransitionOrientationLeftOver kTransitionOrientationLeftOver
|
||||
#define kCCTransitionOrientationRightOver kTransitionOrientationRightOver
|
||||
#define kCCTransitionOrientationUpOver kTransitionOrientationUpOver
|
||||
#define kCCTransitionOrientationDownOver kTransitionOrientationDownOver
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationLeftOver;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationRightOver;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationUpOver;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTransitionOrientationDownOver;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum TransitionScene::Orientation tOrientation;
|
||||
|
||||
#define kCCPrioritySystem kPrioritySystem
|
||||
#define kCCPriorityNonSystemMin kPriorityNonSystemMin
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCPrioritySystem;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCPriorityNonSystemMin;
|
||||
|
||||
#define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag
|
||||
#define kCCTMXTileVerticalFlag kTMXTileVerticalFlag
|
||||
|
|
|
@ -304,23 +304,27 @@ struct BlendFunc
|
|||
const static BlendFunc BLEND_FUNC_DISABLE;
|
||||
};
|
||||
|
||||
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m
|
||||
//! Vertical text alignment type
|
||||
typedef enum
|
||||
class Label : public Object
|
||||
{
|
||||
kVerticalTextAlignmentTop,
|
||||
kVerticalTextAlignmentCenter,
|
||||
kVerticalTextAlignmentBottom,
|
||||
} VerticalTextAlignment;
|
||||
|
||||
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m
|
||||
//! Horizontal text alignment type
|
||||
typedef enum
|
||||
{
|
||||
kTextAlignmentLeft,
|
||||
kTextAlignmentCenter,
|
||||
kTextAlignmentRight,
|
||||
} TextAlignment;
|
||||
public:
|
||||
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m
|
||||
//! Vertical text alignment type
|
||||
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
|
||||
//! Horizontal text alignment type
|
||||
enum TextAlignment
|
||||
{
|
||||
TEXT_ALIGNMENT_LEFT,
|
||||
TEXT_ALIGNMENT_CENTER,
|
||||
TEXT_ALIGNMENT_RIGHT,
|
||||
};
|
||||
};
|
||||
|
||||
// types for animation in particle systems
|
||||
|
||||
|
@ -345,8 +349,6 @@ struct AnimationFrameData
|
|||
Size size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
types used for defining fonts properties (i.e. font name, size, stroke or shadow)
|
||||
*/
|
||||
|
@ -398,8 +400,8 @@ struct FontDefinition
|
|||
public:
|
||||
|
||||
FontDefinition():_fontSize(0),
|
||||
_alignment(kTextAlignmentCenter),
|
||||
_vertAlignment(kVerticalTextAlignmentTop),
|
||||
_alignment(Label::TEXT_ALIGNMENT_CENTER),
|
||||
_vertAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP),
|
||||
_fontFillColor(Color3B::WHITE)
|
||||
{ _dimensions = Size(0,0); }
|
||||
|
||||
|
@ -408,9 +410,9 @@ public:
|
|||
// font size
|
||||
int _fontSize;
|
||||
// horizontal alignment
|
||||
TextAlignment _alignment;
|
||||
Label::Label::Label::TextAlignment _alignment;
|
||||
// vertical alignment
|
||||
VerticalTextAlignment _vertAlignment;
|
||||
Label::Label::Label::VerticalTextAlignment _vertAlignment;
|
||||
// renering box
|
||||
Size _dimensions;
|
||||
// font color
|
||||
|
|
|
@ -430,23 +430,23 @@ LabelBMFont * LabelBMFont::create()
|
|||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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 *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();
|
||||
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()
|
||||
{
|
||||
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( (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()
|
||||
: _string(NULL)
|
||||
, _initialString(NULL)
|
||||
, _alignment(kTextAlignmentCenter)
|
||||
, _alignment(Label::TEXT_ALIGNMENT_CENTER)
|
||||
, _width(-1.0f)
|
||||
, _configuration(NULL)
|
||||
, _lineBreakWithoutSpaces(false)
|
||||
|
@ -1094,7 +1094,7 @@ void LabelBMFont::updateLabel()
|
|||
}
|
||||
|
||||
// Step 2: Make alignment
|
||||
if (_alignment != kTextAlignmentLeft)
|
||||
if (_alignment != Label::TEXT_ALIGNMENT_LEFT)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
@ -1125,10 +1125,10 @@ void LabelBMFont::updateLabel()
|
|||
float shift = 0;
|
||||
switch (_alignment)
|
||||
{
|
||||
case kTextAlignmentCenter:
|
||||
case Label::TEXT_ALIGNMENT_CENTER:
|
||||
shift = getContentSize().width/2.0f - lineWidth/2.0f;
|
||||
break;
|
||||
case kTextAlignmentRight:
|
||||
case Label::TEXT_ALIGNMENT_RIGHT:
|
||||
shift = getContentSize().width - lineWidth;
|
||||
break;
|
||||
default:
|
||||
|
@ -1160,7 +1160,7 @@ void LabelBMFont::updateLabel()
|
|||
}
|
||||
|
||||
// LabelBMFont - Alignment
|
||||
void LabelBMFont::setAlignment(TextAlignment alignment)
|
||||
void LabelBMFont::setAlignment(Label::TextAlignment alignment)
|
||||
{
|
||||
this->_alignment = alignment;
|
||||
updateLabel();
|
||||
|
|
|
@ -192,9 +192,9 @@ public:
|
|||
static void purgeCachedData();
|
||||
|
||||
/** 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);
|
||||
|
||||
|
@ -206,7 +206,7 @@ public:
|
|||
|
||||
bool init();
|
||||
/** 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 */
|
||||
void createFontChars();
|
||||
|
@ -218,7 +218,7 @@ public:
|
|||
virtual void setCString(const char *label);
|
||||
virtual void setAnchorPoint(const Point& var);
|
||||
virtual void updateLabel();
|
||||
virtual void setAlignment(TextAlignment alignment);
|
||||
virtual void setAlignment(Label::TextAlignment alignment);
|
||||
virtual void setWidth(float width);
|
||||
virtual void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
||||
virtual void setScale(float scale);
|
||||
|
@ -265,7 +265,7 @@ protected:
|
|||
std::string _initialStringUTF8;
|
||||
|
||||
// alignment of all lines
|
||||
TextAlignment _alignment;
|
||||
Label::TextAlignment _alignment;
|
||||
// max width until a line break is added
|
||||
float _width;
|
||||
|
||||
|
|
|
@ -31,17 +31,17 @@ THE SOFTWARE.
|
|||
NS_CC_BEGIN
|
||||
|
||||
#if CC_USE_LA88_LABELS
|
||||
#define SHADER_PROGRAM kShader_PositionTextureColor
|
||||
#define SHADER_PROGRAM GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR
|
||||
#else
|
||||
#define SHADER_PROGRAM kShader_PositionTextureA8Color
|
||||
#define SHADER_PROGRAM GLProgram::SHADER_NAME_POSITION_TEXTUREA8Color
|
||||
#endif
|
||||
|
||||
//
|
||||
//CCLabelTTF
|
||||
//
|
||||
LabelTTF::LabelTTF()
|
||||
: _alignment(kTextAlignmentCenter)
|
||||
, _vAlignment(kVerticalTextAlignmentTop)
|
||||
: _alignment(Label::TEXT_ALIGNMENT_CENTER)
|
||||
, _vAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP)
|
||||
, _fontName(NULL)
|
||||
, _fontSize(0.0)
|
||||
, _string("")
|
||||
|
@ -73,18 +73,18 @@ LabelTTF * LabelTTF::create()
|
|||
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float 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,
|
||||
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,
|
||||
const Size &dimensions, TextAlignment hAlignment,
|
||||
VerticalTextAlignment vAlignment)
|
||||
const Size &dimensions, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment)
|
||||
{
|
||||
LabelTTF *pRet = new LabelTTF();
|
||||
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,
|
||||
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)
|
||||
{
|
||||
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,
|
||||
const cocos2d::Size &dimensions, TextAlignment hAlignment,
|
||||
VerticalTextAlignment vAlignment)
|
||||
const cocos2d::Size &dimensions, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
TextAlignment LabelTTF::getHorizontalAlignment() const
|
||||
Label::TextAlignment LabelTTF::getHorizontalAlignment() const
|
||||
{
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
void LabelTTF::setHorizontalAlignment(TextAlignment alignment)
|
||||
void LabelTTF::setHorizontalAlignment(Label::TextAlignment alignment)
|
||||
{
|
||||
if (alignment != _alignment)
|
||||
{
|
||||
|
@ -212,12 +212,12 @@ void LabelTTF::setHorizontalAlignment(TextAlignment alignment)
|
|||
}
|
||||
}
|
||||
|
||||
VerticalTextAlignment LabelTTF::getVerticalAlignment() const
|
||||
Label::VerticalTextAlignment LabelTTF::getVerticalAlignment() const
|
||||
{
|
||||
return _vAlignment;
|
||||
}
|
||||
|
||||
void LabelTTF::setVerticalAlignment(VerticalTextAlignment verticalAlignment)
|
||||
void LabelTTF::setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment)
|
||||
{
|
||||
if (verticalAlignment != _vAlignment)
|
||||
{
|
||||
|
|
|
@ -48,9 +48,9 @@ NS_CC_BEGIN
|
|||
* Custom ttf file can be put in assets/ or external storage that the Application can access.
|
||||
* @code
|
||||
* 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,
|
||||
* kTextAlignmentLeft, kVerticalTextAlignmentCenter);
|
||||
* Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_CENTER);
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
|
@ -70,14 +70,14 @@ public:
|
|||
@since v2.0.1
|
||||
*/
|
||||
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
|
||||
@since v2.0.1
|
||||
*/
|
||||
static LabelTTF * create(const char *string, const char *fontName, float fontSize,
|
||||
const Size& dimensions, TextAlignment hAlignment,
|
||||
VerticalTextAlignment vAlignment);
|
||||
const Size& dimensions, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment);
|
||||
|
||||
|
||||
/** 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 */
|
||||
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 */
|
||||
bool initWithString(const char *string, const char *fontName, float fontSize,
|
||||
const Size& dimensions, TextAlignment hAlignment,
|
||||
VerticalTextAlignment vAlignment);
|
||||
const Size& dimensions, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment);
|
||||
|
||||
/** initializes the LabelTTF with a font name, alignment, dimension and font size */
|
||||
bool initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition);
|
||||
|
@ -136,11 +136,11 @@ public:
|
|||
virtual void setString(const char *label);
|
||||
virtual const char* getString(void) const;
|
||||
|
||||
TextAlignment getHorizontalAlignment() const;
|
||||
void setHorizontalAlignment(TextAlignment alignment);
|
||||
Label::TextAlignment getHorizontalAlignment() const;
|
||||
void setHorizontalAlignment(Label::TextAlignment alignment);
|
||||
|
||||
VerticalTextAlignment getVerticalAlignment() const;
|
||||
void setVerticalAlignment(VerticalTextAlignment verticalAlignment);
|
||||
Label::VerticalTextAlignment getVerticalAlignment() const;
|
||||
void setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment);
|
||||
|
||||
const Size& getDimensions() const;
|
||||
void setDimensions(const Size &dim);
|
||||
|
@ -162,9 +162,9 @@ protected:
|
|||
/** Dimensions of the label in Points */
|
||||
Size _dimensions;
|
||||
/** The alignment of the label */
|
||||
TextAlignment _alignment;
|
||||
Label::TextAlignment _alignment;
|
||||
/** The vertical alignment of the label */
|
||||
VerticalTextAlignment _vAlignment;
|
||||
Label::VerticalTextAlignment _vAlignment;
|
||||
/** Font name used in the label */
|
||||
std::string * _fontName;
|
||||
/** Font size of the label */
|
||||
|
|
|
@ -48,7 +48,7 @@ Layer::Layer()
|
|||
, _keyboardEnabled(false)
|
||||
, _keypadEnabled(false)
|
||||
, _touchPriority(0)
|
||||
, _touchMode(kTouchesAllAtOnce)
|
||||
, _touchMode(Layer::TOUCHES_ALL_AT_ONCE)
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
@ -96,7 +96,7 @@ void Layer::registerWithTouchDispatcher()
|
|||
{
|
||||
TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher();
|
||||
|
||||
if( _touchMode == kTouchesAllAtOnce ) {
|
||||
if( _touchMode == Layer::TOUCHES_ALL_AT_ONCE ) {
|
||||
pDispatcher->addStandardDelegate(this, 0);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
|
@ -708,7 +708,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h)
|
|||
updateColor();
|
||||
setContentSize(Size(w, h));
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_COLOR));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -762,20 +762,20 @@ void LayerColor::draw()
|
|||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_Color );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_COLOR );
|
||||
|
||||
//
|
||||
// Attributes
|
||||
//
|
||||
#ifdef EMSCRIPTEN
|
||||
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);
|
||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices);
|
||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
|
||||
|
|
|
@ -39,11 +39,6 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
typedef enum {
|
||||
kTouchesAllAtOnce,
|
||||
kTouchesOneByOne,
|
||||
} ccTouchesMode;
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
public:
|
||||
enum TouchesMode
|
||||
{
|
||||
TOUCHES_ALL_AT_ONCE,
|
||||
TOUCHES_ONE_BY_ONE,
|
||||
};
|
||||
|
||||
/** creates a fullscreen black layer */
|
||||
static Layer *create(void);
|
||||
Layer();
|
||||
|
@ -103,7 +104,7 @@ public:
|
|||
virtual bool isTouchEnabled() const;
|
||||
virtual void setTouchEnabled(bool value);
|
||||
|
||||
virtual void setTouchMode(ccTouchesMode mode);
|
||||
virtual void setTouchMode(TouchesMode mode);
|
||||
virtual int getTouchMode() const;
|
||||
|
||||
/** priority of the touch events. Default is 0 */
|
||||
|
@ -148,7 +149,7 @@ protected:
|
|||
|
||||
private:
|
||||
int _touchPriority;
|
||||
ccTouchesMode _touchMode;
|
||||
TouchesMode _touchMode;
|
||||
|
||||
int executeScriptTouchHandler(int eventType, Touch* touch);
|
||||
int executeScriptTouchesHandler(int eventType, Set* touches);
|
||||
|
|
|
@ -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();
|
||||
pScene->initWithDuration(t,scene,orientation);
|
||||
|
@ -214,7 +214,7 @@ TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene,
|
|||
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) )
|
||||
{
|
||||
|
@ -740,7 +740,7 @@ void TransitionFlipX::onEnter()
|
|||
float inDeltaZ, inAngleZ;
|
||||
float outDeltaZ, outAngleZ;
|
||||
|
||||
if( _orientation == kTransitionOrientationRightOver )
|
||||
if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER )
|
||||
{
|
||||
inDeltaZ = 90;
|
||||
inAngleZ = 270;
|
||||
|
@ -776,7 +776,7 @@ void TransitionFlipX::onEnter()
|
|||
_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();
|
||||
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)
|
||||
{
|
||||
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 outDeltaZ, outAngleZ;
|
||||
|
||||
if( _orientation == kTransitionOrientationUpOver )
|
||||
if( _orientation == TransitionScene::ORIENTATION_UP_OVER )
|
||||
{
|
||||
inDeltaZ = 90;
|
||||
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();
|
||||
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)
|
||||
{
|
||||
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 outDeltaZ, outAngleZ;
|
||||
|
||||
if( _orientation == kTransitionOrientationRightOver )
|
||||
if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER )
|
||||
{
|
||||
inDeltaZ = 90;
|
||||
inAngleZ = 270;
|
||||
|
@ -916,7 +916,7 @@ void TransitionFlipAngular::onEnter()
|
|||
_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();
|
||||
pScene->initWithDuration(t, s, o);
|
||||
|
@ -927,7 +927,7 @@ TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, tOrienta
|
|||
|
||||
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 outDeltaZ, outAngleZ;
|
||||
|
||||
if( _orientation == kTransitionOrientationRightOver ) {
|
||||
if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER ) {
|
||||
inDeltaZ = 90;
|
||||
inAngleZ = 270;
|
||||
outDeltaZ = 90;
|
||||
|
@ -994,7 +994,7 @@ void TransitionZoomFlipX::onEnter()
|
|||
_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();
|
||||
pScene->initWithDuration(t, s, o);
|
||||
|
@ -1005,7 +1005,7 @@ TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, tOrientation
|
|||
|
||||
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 outDeltaZ, outAngleZ;
|
||||
|
||||
if( _orientation== kTransitionOrientationUpOver ) {
|
||||
if( _orientation== TransitionScene::ORIENTATION_UP_OVER ) {
|
||||
inDeltaZ = 90;
|
||||
inAngleZ = 270;
|
||||
outDeltaZ = 90;
|
||||
|
@ -1073,7 +1073,7 @@ void TransitionZoomFlipY::onEnter()
|
|||
_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();
|
||||
pScene->initWithDuration(t, s, o);
|
||||
|
@ -1084,7 +1084,7 @@ TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, tOrientation
|
|||
|
||||
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 outDeltaZ, outAngleZ;
|
||||
|
||||
if( _orientation == kTransitionOrientationRightOver ) {
|
||||
if( _orientation == TransitionScene::ORIENTATION_RIGHT_OVER ) {
|
||||
inDeltaZ = 90;
|
||||
inAngleZ = 270;
|
||||
outDeltaZ = 90;
|
||||
|
@ -1154,7 +1154,7 @@ void TransitionZoomFlipAngular::onEnter()
|
|||
_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();
|
||||
pScene->initWithDuration(t, s, o);
|
||||
|
@ -1165,7 +1165,7 @@ 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);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -56,31 +56,25 @@ public:
|
|||
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
|
||||
*/
|
||||
class CC_DLL TransitionScene : public Scene
|
||||
{
|
||||
|
||||
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 */
|
||||
static TransitionScene * create(float t, Scene *scene);
|
||||
|
||||
|
@ -125,16 +119,16 @@ class CC_DLL TransitionSceneOriented : public TransitionScene
|
|||
{
|
||||
public:
|
||||
/** 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();
|
||||
virtual ~TransitionSceneOriented();
|
||||
|
||||
/** 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:
|
||||
tOrientation _orientation;
|
||||
Orientation _orientation;
|
||||
};
|
||||
|
||||
/** @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
|
||||
{
|
||||
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);
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
|
||||
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
|
||||
{
|
||||
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);
|
||||
|
||||
TransitionZoomFlipAngular();
|
||||
|
|
|
@ -140,7 +140,7 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType(kProgressTimerTypeRadial);
|
||||
pNode->setType(ProgressTimer::RADIAL);
|
||||
|
||||
// Return the radial type that we want to use
|
||||
pNode->setReverseDirection(false);
|
||||
|
@ -184,7 +184,7 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( kProgressTimerTypeRadial );
|
||||
pNode->setType( ProgressTimer::RADIAL );
|
||||
|
||||
// Return the radial type that we want to use
|
||||
pNode->setReverseDirection(true);
|
||||
|
@ -216,7 +216,7 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture(
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( kProgressTimerTypeBar);
|
||||
pNode->setType( ProgressTimer::BAR);
|
||||
|
||||
pNode->setMidpoint(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
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType(kProgressTimerTypeBar);
|
||||
pNode->setType(ProgressTimer::BAR);
|
||||
|
||||
pNode->setMidpoint(Point(0, 0));
|
||||
pNode->setBarChangeRate(Point(0,1));
|
||||
|
@ -295,7 +295,7 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( kProgressTimerTypeBar);
|
||||
pNode->setType( ProgressTimer::BAR);
|
||||
|
||||
pNode->setMidpoint(Point(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(Point(1, 1));
|
||||
|
@ -329,7 +329,7 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende
|
|||
|
||||
// but it is flipped upside down so we flip the sprite
|
||||
pNode->getSprite()->setFlipY(true);
|
||||
pNode->setType( kProgressTimerTypeBar );
|
||||
pNode->setType( ProgressTimer::BAR );
|
||||
|
||||
pNode->setMidpoint(Point(0.5f, 0.5f));
|
||||
pNode->setBarChangeRate(Point(1, 1));
|
||||
|
|
|
@ -121,8 +121,8 @@ bool Menu::initWithArray(Array* pArrayOfItems)
|
|||
{
|
||||
if (Layer::init())
|
||||
{
|
||||
setTouchPriority(kMenuHandlerPriority);
|
||||
setTouchMode(kTouchesOneByOne);
|
||||
setTouchPriority(Menu::HANDLER_PRIORITY);
|
||||
setTouchMode(Layer::TOUCHES_ONE_BY_ONE);
|
||||
setTouchEnabled(true);
|
||||
|
||||
_enabled = true;
|
||||
|
@ -149,7 +149,7 @@ bool Menu::initWithArray(Array* pArrayOfItems)
|
|||
|
||||
// [self alignItemsVertically];
|
||||
_selectedItem = NULL;
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
|
||||
// enable cascade color and opacity on menus
|
||||
setCascadeColorEnabled(true);
|
||||
|
@ -181,7 +181,7 @@ void Menu::addChild(Node * child, int zOrder, int tag)
|
|||
|
||||
void Menu::onExit()
|
||||
{
|
||||
if (_state == kMenuStateTrackingTouch)
|
||||
if (_state == Menu::STATE_TRACKING_TOUCH)
|
||||
{
|
||||
if (_selectedItem)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ void Menu::onExit()
|
|||
_selectedItem = NULL;
|
||||
}
|
||||
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
}
|
||||
|
||||
Layer::onExit();
|
||||
|
@ -225,7 +225,7 @@ void Menu::registerWithTouchDispatcher()
|
|||
bool Menu::ccTouchBegan(Touch* touch, Event* event)
|
||||
{
|
||||
CC_UNUSED_PARAM(event);
|
||||
if (_state != kMenuStateWaiting || ! _visible || !_enabled)
|
||||
if (_state != Menu::STATE_WAITING || ! _visible || !_enabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ bool Menu::ccTouchBegan(Touch* touch, Event* event)
|
|||
_selectedItem = this->itemForTouch(touch);
|
||||
if (_selectedItem)
|
||||
{
|
||||
_state = kMenuStateTrackingTouch;
|
||||
_state = Menu::STATE_TRACKING_TOUCH;
|
||||
_selectedItem->selected();
|
||||
return true;
|
||||
}
|
||||
|
@ -252,31 +252,31 @@ void Menu::ccTouchEnded(Touch *touch, Event* event)
|
|||
{
|
||||
CC_UNUSED_PARAM(touch);
|
||||
CC_UNUSED_PARAM(event);
|
||||
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state");
|
||||
CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchEnded] -- invalid state");
|
||||
if (_selectedItem)
|
||||
{
|
||||
_selectedItem->unselected();
|
||||
_selectedItem->activate();
|
||||
}
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
}
|
||||
|
||||
void Menu::ccTouchCancelled(Touch *touch, Event* event)
|
||||
{
|
||||
CC_UNUSED_PARAM(touch);
|
||||
CC_UNUSED_PARAM(event);
|
||||
CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state");
|
||||
CCASSERT(_state == Menu::STATE_TRACKING_TOUCH, "[Menu ccTouchCancelled] -- invalid state");
|
||||
if (_selectedItem)
|
||||
{
|
||||
_selectedItem->unselected();
|
||||
}
|
||||
_state = kMenuStateWaiting;
|
||||
_state = Menu::STATE_WAITING;
|
||||
}
|
||||
|
||||
void Menu::ccTouchMoved(Touch* touch, Event* 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);
|
||||
if (currentItem != _selectedItem)
|
||||
{
|
||||
|
|
|
@ -36,16 +36,8 @@ NS_CC_BEGIN
|
|||
* @addtogroup menu
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
kMenuStateWaiting,
|
||||
kMenuStateTrackingTouch
|
||||
} tMenuState;
|
||||
|
||||
enum {
|
||||
//* priority used by the menu for the event handler
|
||||
kMenuHandlerPriority = -128,
|
||||
};
|
||||
|
||||
|
||||
/** @brief A Menu
|
||||
*
|
||||
|
@ -56,6 +48,17 @@ enum {
|
|||
class CC_DLL Menu : public LayerRGBA
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
HANDLER_PRIORITY = -128,
|
||||
};
|
||||
|
||||
enum State
|
||||
{
|
||||
STATE_WAITING,
|
||||
STATE_TRACKING_TOUCH,
|
||||
};
|
||||
|
||||
/** creates an empty Menu */
|
||||
static Menu* create();
|
||||
|
||||
|
@ -133,7 +136,7 @@ protected:
|
|||
bool _enabled;
|
||||
|
||||
MenuItem* itemForTouch(Touch * touch);
|
||||
tMenuState _state;
|
||||
State _state;
|
||||
MenuItem *_selectedItem;
|
||||
};
|
||||
|
||||
|
|
|
@ -308,8 +308,8 @@ void ClippingNode::visit()
|
|||
#else
|
||||
// since glAlphaTest do not exists in OES, use a shader that writes
|
||||
// pixel only if greater than an alpha threshold
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue);
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||
// set our alphaThreshold
|
||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
||||
// we need to recursively apply this shader to all the nodes in the stencil node
|
||||
|
|
|
@ -127,7 +127,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
|
|||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
|
||||
// shader program
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
||||
setTexture(texture);
|
||||
setColor(color);
|
||||
|
@ -331,7 +331,7 @@ void MotionStreak::draw()
|
|||
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex );
|
||||
ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
|
||||
|
||||
ccGLBindTexture2D( _texture->getName() );
|
||||
|
@ -339,17 +339,17 @@ void MotionStreak::draw()
|
|||
#ifdef EMSCRIPTEN
|
||||
// Size calculations from ::initWithFade
|
||||
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);
|
||||
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);
|
||||
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
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoords);
|
||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoords);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2);
|
||||
|
|
|
@ -45,7 +45,7 @@ const char kProgressTextureCoords = 0x4b;
|
|||
|
||||
|
||||
ProgressTimer::ProgressTimer()
|
||||
:_type(kProgressTimerTypeRadial)
|
||||
:_type(RADIAL)
|
||||
,_percentage(0.0f)
|
||||
,_sprite(NULL)
|
||||
,_vertexDataCount(0)
|
||||
|
@ -78,13 +78,13 @@ bool ProgressTimer::initWithSprite(Sprite* sp)
|
|||
_vertexDataCount = 0;
|
||||
|
||||
setAnchorPoint(Point(0.5f,0.5f));
|
||||
_type = kProgressTimerTypeRadial;
|
||||
_type = RADIAL;
|
||||
_reverseDirection = false;
|
||||
setMidpoint(Point(0.5f, 0.5f));
|
||||
setBarChangeRate(Point(1,1));
|
||||
setSprite(sp);
|
||||
// shader program
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ void ProgressTimer::setSprite(Sprite *pSprite)
|
|||
}
|
||||
}
|
||||
|
||||
void ProgressTimer::setType(ProgressTimerType type)
|
||||
void ProgressTimer::setType(Type type)
|
||||
{
|
||||
if (type != _type)
|
||||
{
|
||||
|
@ -225,10 +225,10 @@ void ProgressTimer::updateProgress(void)
|
|||
{
|
||||
switch (_type)
|
||||
{
|
||||
case kProgressTimerTypeRadial:
|
||||
case RADIAL:
|
||||
updateRadial();
|
||||
break;
|
||||
case kProgressTimerTypeBar:
|
||||
case BAR:
|
||||
updateBar();
|
||||
break;
|
||||
default:
|
||||
|
@ -506,7 +506,7 @@ void ProgressTimer::draw(void)
|
|||
|
||||
ccGLBlendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst );
|
||||
|
||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex );
|
||||
ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
|
||||
ccGLBindTexture2D( _sprite->getTexture()->getName() );
|
||||
|
||||
|
@ -514,24 +514,24 @@ void ProgressTimer::draw(void)
|
|||
setGLBufferData((void*) _vertexData, (_vertexDataCount * sizeof(V2F_C4B_T2F)), 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);
|
||||
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);
|
||||
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
|
||||
glVertexAttribPointer( kVertexAttrib_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( kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors);
|
||||
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices);
|
||||
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords);
|
||||
glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
if(_type == kProgressTimerTypeRadial)
|
||||
if(_type == RADIAL)
|
||||
{
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount);
|
||||
}
|
||||
else if (_type == kProgressTimerTypeBar)
|
||||
else if (_type == BAR)
|
||||
{
|
||||
if (!_reverseDirection)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
It renders the inner sprite according to the percentage.
|
||||
|
@ -59,6 +49,17 @@ class CC_DLL ProgressTimer : public NodeRGBA
|
|||
#endif // EMSCRIPTEN
|
||||
{
|
||||
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 */
|
||||
static ProgressTimer* create(Sprite* sp);
|
||||
|
||||
|
@ -69,7 +70,7 @@ public:
|
|||
bool initWithSprite(Sprite* sp);
|
||||
|
||||
/** Change the percentage to change progress. */
|
||||
inline ProgressTimerType getType() const { return _type; }
|
||||
inline Type getType() const { return _type; }
|
||||
|
||||
/** Percentages are from 0 to 100 */
|
||||
inline float getPercentage() const {return _percentage; }
|
||||
|
@ -79,7 +80,7 @@ public:
|
|||
|
||||
void setPercentage(float fPercentage);
|
||||
void setSprite(Sprite *pSprite);
|
||||
void setType(ProgressTimerType type);
|
||||
void setType(Type type);
|
||||
void setReverseProgress(bool reverse);
|
||||
|
||||
inline bool isReverseDirection() { return _reverseDirection; };
|
||||
|
@ -126,7 +127,7 @@ protected:
|
|||
void updateColor(void);
|
||||
Point boundaryTexCoord(char index);
|
||||
|
||||
ProgressTimerType _type;
|
||||
Type _type;
|
||||
Point _midpoint;
|
||||
Point _barChangeRate;
|
||||
float _percentage;
|
||||
|
|
|
@ -51,7 +51,7 @@ RenderTexture::RenderTexture()
|
|||
, _texture(0)
|
||||
, _textureCopy(0)
|
||||
, _UITextureImage(NULL)
|
||||
, _pixelFormat(kTexture2DPixelFormat_RGBA8888)
|
||||
, _pixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888)
|
||||
, _clearFlags(0)
|
||||
, _clearColor(Color4F(0,0,0,0))
|
||||
, _clearDepth(0.0f)
|
||||
|
@ -102,11 +102,11 @@ void RenderTexture::listenToBackground(cocos2d::Object *obj)
|
|||
if (_UITextureImage)
|
||||
{
|
||||
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 )
|
||||
{
|
||||
VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s);
|
||||
VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), Texture2D::PIXEL_FORMAT_RGBA8888, s);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -140,7 +140,7 @@ void RenderTexture::listenToForeground(cocos2d::Object *obj)
|
|||
#endif
|
||||
}
|
||||
|
||||
RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat)
|
||||
RenderTexture * RenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat)
|
||||
{
|
||||
RenderTexture *pRet = new RenderTexture();
|
||||
|
||||
|
@ -153,7 +153,7 @@ RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat
|
|||
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();
|
||||
|
||||
|
@ -170,7 +170,7 @@ RenderTexture * RenderTexture::create(int w, int h)
|
|||
{
|
||||
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();
|
||||
return pRet;
|
||||
|
@ -179,14 +179,14 @@ RenderTexture * RenderTexture::create(int w, int h)
|
|||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
void *data = NULL;
|
||||
|
@ -221,7 +221,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
|
|||
_texture = new Texture2D();
|
||||
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
|
||||
{
|
||||
|
@ -235,7 +235,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
|
|||
_textureCopy = new Texture2D();
|
||||
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
|
||||
{
|
||||
|
@ -550,16 +550,16 @@ bool RenderTexture::saveToFile(const char *szFilePath)
|
|||
Image *pImage = newImage(true);
|
||||
if (pImage)
|
||||
{
|
||||
bRet = pImage->saveToFile(szFilePath, kImageFormatJPEG);
|
||||
bRet = pImage->saveToFile(szFilePath, Image::FORMAT_JPG);
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(pImage);
|
||||
return bRet;
|
||||
}
|
||||
bool RenderTexture::saveToFile(const char *fileName, tImageFormat format)
|
||||
bool RenderTexture::saveToFile(const char *fileName, Image::Format format)
|
||||
{
|
||||
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");
|
||||
|
||||
Image *pImage = newImage(true);
|
||||
|
@ -578,7 +578,7 @@ bool RenderTexture::saveToFile(const char *fileName, tImageFormat format)
|
|||
/* get buffer as Image */
|
||||
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)
|
||||
{
|
||||
|
@ -624,11 +624,11 @@ Image* RenderTexture::newImage(bool flipImage)
|
|||
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
|
||||
{
|
||||
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);
|
||||
|
|
|
@ -28,6 +28,7 @@ THE SOFTWARE.
|
|||
#include "base_nodes/CCNode.h"
|
||||
#include "sprite_nodes/CCSprite.h"
|
||||
#include "kazmath/mat4.h"
|
||||
#include "platform/CCImage.h"
|
||||
|
||||
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,
|
||||
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:
|
||||
/** 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 */
|
||||
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 */
|
||||
static RenderTexture * create(int w, int h);
|
||||
|
@ -67,10 +63,10 @@ public:
|
|||
virtual ~RenderTexture();
|
||||
|
||||
/** 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*/
|
||||
bool initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat);
|
||||
bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat);
|
||||
|
||||
/** starts grabbing */
|
||||
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.
|
||||
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.
|
||||
It only has effect on Android.
|
||||
|
|
|
@ -102,7 +102,7 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, unsigned int capacity)
|
|||
_blendFunc.src = CC_BLEND_SRC;
|
||||
_blendFunc.dst = CC_BLEND_DST;
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ static Texture2D* getDefaultTexture()
|
|||
|
||||
pImage = new Image();
|
||||
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);
|
||||
|
||||
pTexture = TextureCache::getInstance()->addUIImage(pImage, key);
|
||||
|
@ -91,10 +91,10 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// Gravity Mode
|
||||
this->_emitterMode = kParticleModeGravity;
|
||||
this->_emitterMode = MODE_GRAVITY;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = Point(0,0);
|
||||
|
@ -124,7 +124,7 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 54.0f;
|
||||
_startSizeVar = 10.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per frame
|
||||
_emissionRate = _totalParticles/_life;
|
||||
|
@ -196,10 +196,10 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration= kParticleDurationInfinity;
|
||||
_duration= DURATION_INFINITY;
|
||||
|
||||
// Gravity Mode
|
||||
this->_emitterMode = kParticleModeGravity;
|
||||
this->_emitterMode = MODE_GRAVITY;
|
||||
|
||||
// Gravity Mode: gravity
|
||||
this->modeA.gravity = Point(0,-90);
|
||||
|
@ -248,7 +248,7 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 8.0f;
|
||||
_startSizeVar = 2.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
Texture2D* pTexture = getDefaultTexture();
|
||||
if (pTexture != NULL)
|
||||
|
@ -300,10 +300,10 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
this->setBlendAdditive(true);
|
||||
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// Gravity Mode
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
|
@ -333,7 +333,7 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 30.0f;
|
||||
_startSizeVar = 10.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per seconds
|
||||
_emissionRate = _totalParticles/_life;
|
||||
|
@ -404,10 +404,10 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// Gravity Mode
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
|
@ -440,7 +440,7 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 37.0f;
|
||||
_startSizeVar = 10.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per second
|
||||
_emissionRate = _totalParticles/_life;
|
||||
|
@ -513,10 +513,10 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// Gravity Mode
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
|
@ -549,7 +549,7 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 30.0f;
|
||||
_startSizeVar = 10.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per second
|
||||
_emissionRate = _totalParticles/_life;
|
||||
|
@ -621,10 +621,10 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// Gravity Mode
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(-200,200));
|
||||
|
@ -657,7 +657,7 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 60.0f;
|
||||
_startSizeVar = 10.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per second
|
||||
_emissionRate = _totalParticles/_life;
|
||||
|
@ -730,10 +730,10 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// Gravity Mode
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
|
@ -766,7 +766,7 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 20.0f;
|
||||
_startSizeVar = 0.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per second
|
||||
_emissionRate = _totalParticles/_life;
|
||||
|
@ -841,7 +841,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// duration
|
||||
_duration = 0.1f;
|
||||
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
|
@ -874,7 +874,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 15.0f;
|
||||
_startSizeVar = 10.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per second
|
||||
_emissionRate = _totalParticles/_duration;
|
||||
|
@ -947,10 +947,10 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// Emitter mode: Gravity Mode
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
|
@ -979,7 +979,7 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 60.0f;
|
||||
_startSizeVar = 10.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per frame
|
||||
_emissionRate = _totalParticles/_life;
|
||||
|
@ -1052,10 +1052,10 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
// set gravity mode.
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,-1));
|
||||
|
@ -1088,7 +1088,7 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 10.0f;
|
||||
_startSizeVar = 5.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per second
|
||||
_emissionRate = 10;
|
||||
|
@ -1160,9 +1160,9 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) )
|
||||
{
|
||||
// duration
|
||||
_duration = kParticleDurationInfinity;
|
||||
_duration = DURATION_INFINITY;
|
||||
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(10,-10));
|
||||
|
@ -1196,7 +1196,7 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
_startSize = 4.0f;
|
||||
_startSizeVar = 2.0f;
|
||||
_endSize = kParticleStartSizeEqualToEndSize;
|
||||
_endSize = START_SIZE_EQUAL_TO_END_SIZE;
|
||||
|
||||
// emits per second
|
||||
_emissionRate = 20;
|
||||
|
|
|
@ -42,6 +42,9 @@ THE SOFTWARE.
|
|||
//
|
||||
|
||||
#include "CCParticleSystem.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "CCParticleBatchNode.h"
|
||||
#include "ccTypes.h"
|
||||
#include "textures/CCTextureCache.h"
|
||||
|
@ -55,8 +58,6 @@ THE SOFTWARE.
|
|||
// opengl
|
||||
#include "CCGL.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
@ -111,9 +112,9 @@ ParticleSystem::ParticleSystem()
|
|||
, _texture(NULL)
|
||||
, _opacityModifyRGB(false)
|
||||
, _isBlendAdditive(false)
|
||||
, _positionType(kPositionTypeFree)
|
||||
, _positionType(POSITION_TYPE_FREE)
|
||||
, _isAutoRemoveOnFinish(false)
|
||||
, _emitterMode(kParticleModeGravity)
|
||||
, _emitterMode(MODE_GRAVITY)
|
||||
{
|
||||
modeA.gravity = Point::ZERO;
|
||||
modeA.speed = 0;
|
||||
|
@ -259,7 +260,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
|||
_emitterMode = dictionary->valueForKey("emitterType")->intValue();
|
||||
|
||||
// Mode A: Gravity + tangential accel + radial accel
|
||||
if( _emitterMode == kParticleModeGravity )
|
||||
if (_emitterMode == MODE_GRAVITY)
|
||||
{
|
||||
// gravity
|
||||
modeA.gravity.x = dictionary->valueForKey("gravityx")->floatValue();
|
||||
|
@ -282,7 +283,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn
|
|||
}
|
||||
|
||||
// or Mode B: radius movement
|
||||
else if( _emitterMode == kParticleModeRadius )
|
||||
else if (_emitterMode == MODE_RADIUS)
|
||||
{
|
||||
modeB.startRadius = dictionary->valueForKey("maxRadius")->floatValue();
|
||||
modeB.startRadiusVar = dictionary->valueForKey("maxRadiusVariance")->floatValue();
|
||||
|
@ -418,10 +419,10 @@ bool ParticleSystem::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
_blendFunc.dst = CC_BLEND_DST;
|
||||
|
||||
// default movement type;
|
||||
_positionType = kPositionTypeFree;
|
||||
_positionType = POSITION_TYPE_FREE;
|
||||
|
||||
// by default be in mode A:
|
||||
_emitterMode = kParticleModeGravity;
|
||||
_emitterMode = MODE_GRAVITY;
|
||||
|
||||
// default: modulate
|
||||
// XXX: not used
|
||||
|
@ -501,7 +502,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
|
||||
particle->size = startS;
|
||||
|
||||
if( _endSize == kParticleStartSizeEqualToEndSize )
|
||||
if (_endSize == START_SIZE_EQUAL_TO_END_SIZE)
|
||||
{
|
||||
particle->deltaSize = 0;
|
||||
}
|
||||
|
@ -519,11 +520,11 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
particle->deltaRotation = (endA - startA) / particle->timeToLive;
|
||||
|
||||
// position
|
||||
if( _positionType == kPositionTypeFree )
|
||||
if (_positionType == POSITION_TYPE_FREE)
|
||||
{
|
||||
particle->startPos = this->convertToWorldSpace(Point::ZERO);
|
||||
}
|
||||
else if ( _positionType == kPositionTypeRelative )
|
||||
else if (_positionType == POSITION_TYPE_RELATIVE)
|
||||
{
|
||||
particle->startPos = _position;
|
||||
}
|
||||
|
@ -532,7 +533,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
float a = CC_DEGREES_TO_RADIANS( _angle + _angleVar * CCRANDOM_MINUS1_1() );
|
||||
|
||||
// Mode Gravity: A
|
||||
if (_emitterMode == kParticleModeGravity)
|
||||
if (_emitterMode == MODE_GRAVITY)
|
||||
{
|
||||
Point v(cosf( a ), sinf( a ));
|
||||
float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1();
|
||||
|
@ -561,7 +562,7 @@ void ParticleSystem::initParticle(tParticle* particle)
|
|||
|
||||
particle->modeB.radius = startRadius;
|
||||
|
||||
if(modeB.endRadius == kParticleStartRadiusEqualToEndRadius)
|
||||
if (modeB.endRadius == START_RADIUS_EQUAL_TO_END_RADIUS)
|
||||
{
|
||||
particle->modeB.deltaRadius = 0;
|
||||
}
|
||||
|
@ -627,11 +628,11 @@ void ParticleSystem::update(float dt)
|
|||
_particleIdx = 0;
|
||||
|
||||
Point currentPosition = Point::ZERO;
|
||||
if (_positionType == kPositionTypeFree)
|
||||
if (_positionType == POSITION_TYPE_FREE)
|
||||
{
|
||||
currentPosition = this->convertToWorldSpace(Point::ZERO);
|
||||
}
|
||||
else if (_positionType == kPositionTypeRelative)
|
||||
else if (_positionType == POSITION_TYPE_RELATIVE)
|
||||
{
|
||||
currentPosition = _position;
|
||||
}
|
||||
|
@ -648,7 +649,7 @@ void ParticleSystem::update(float dt)
|
|||
if (p->timeToLive > 0)
|
||||
{
|
||||
// Mode A: gravity, direction, tangential accel & radial accel
|
||||
if (_emitterMode == kParticleModeGravity)
|
||||
if (_emitterMode == MODE_GRAVITY)
|
||||
{
|
||||
Point tmp, radial, tangential;
|
||||
|
||||
|
@ -705,7 +706,7 @@ void ParticleSystem::update(float dt)
|
|||
|
||||
Point newPos;
|
||||
|
||||
if (_positionType == kPositionTypeFree || _positionType == kPositionTypeRelative)
|
||||
if (_positionType == POSITION_TYPE_FREE || _positionType == POSITION_TYPE_RELATIVE)
|
||||
{
|
||||
Point diff = currentPosition - p->startPos;
|
||||
newPos = p->pos - diff;
|
||||
|
@ -857,170 +858,170 @@ bool ParticleSystem::isBlendAdditive() const
|
|||
// ParticleSystem - Properties of Gravity Mode
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getTangentialAccel() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT( _emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.tangentialAccel;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getTangentialAccelVar() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.tangentialAccelVar;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getRadialAccel() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.radialAccel;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getRadialAccelVar() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.radialAccelVar;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool ParticleSystem::getRotationIsDir() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.rotationIsDir;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const Point& ParticleSystem::getGravity()
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.gravity;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getSpeed() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.speed;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getSpeedVar() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity");
|
||||
CCASSERT(_emitterMode == MODE_GRAVITY, "Particle Mode should be Gravity");
|
||||
return modeA.speedVar;
|
||||
}
|
||||
|
||||
// ParticleSystem - Properties of Radius Mode
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getStartRadius() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
|
||||
CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
|
||||
return modeB.startRadius;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getStartRadiusVar() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
|
||||
CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
|
||||
return modeB.startRadiusVar;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getEndRadius() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
|
||||
CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
|
||||
return modeB.endRadius;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getEndRadiusVar() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
|
||||
CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
|
||||
return modeB.endRadiusVar;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getRotatePerSecond() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
|
||||
CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
|
||||
return modeB.rotatePerSecond;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
float ParticleSystem::getRotatePerSecondVar() const
|
||||
{
|
||||
CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius");
|
||||
CCASSERT(_emitterMode == MODE_RADIUS, "Particle Mode should be Radius");
|
||||
return modeB.rotatePerSecondVar;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,45 +40,6 @@ NS_CC_BEGIN
|
|||
|
||||
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
|
||||
*/
|
||||
|
@ -166,6 +127,41 @@ emitter.startSpin = 0;
|
|||
class CC_DLL ParticleSystem : public Node, public TextureProtocol
|
||||
{
|
||||
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.
|
||||
This plist files can be created manually or with Particle Designer:
|
||||
http://particledesigner.71squared.com/
|
||||
|
@ -371,8 +367,8 @@ public:
|
|||
/** particles movement type: Free or Grouped
|
||||
@since v0.8
|
||||
*/
|
||||
inline tPositionType getPositionType() const { return _positionType; };
|
||||
inline void setPositionType(tPositionType type) { _positionType = type; };
|
||||
inline PositionType getPositionType() const { return _positionType; };
|
||||
inline void setPositionType(PositionType type) { _positionType = type; };
|
||||
|
||||
// Overrides
|
||||
virtual void update(float dt) override;
|
||||
|
@ -531,7 +527,7 @@ protected:
|
|||
/** particles movement type: Free or Grouped
|
||||
@since v0.8
|
||||
*/
|
||||
tPositionType _positionType;
|
||||
PositionType _positionType;
|
||||
};
|
||||
|
||||
// end of particle_nodes group
|
||||
|
|
|
@ -63,7 +63,7 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setupVBO();
|
||||
#endif
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||
// 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)
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
|
||||
// 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
|
||||
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
|
||||
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]);
|
||||
|
||||
|
@ -487,16 +487,16 @@ void ParticleSystemQuad::setupVBOandVAO()
|
|||
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW);
|
||||
|
||||
// vertices
|
||||
glEnableVertexAttribArray(kVertexAttrib_Position);
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
|
||||
|
||||
// colors
|
||||
glEnableVertexAttribArray(kVertexAttrib_Color);
|
||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
|
||||
|
||||
// tex coords
|
||||
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
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]);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW);
|
||||
|
|
|
@ -50,15 +50,15 @@ public:
|
|||
Image();
|
||||
virtual ~Image();
|
||||
|
||||
typedef enum
|
||||
enum Format
|
||||
{
|
||||
kFmtJpg = 0,
|
||||
kFmtPng,
|
||||
kFmtTiff,
|
||||
kFmtWebp,
|
||||
kFmtRawData,
|
||||
kFmtUnKnown
|
||||
}EImageFormat;
|
||||
FORMAT_JPG,
|
||||
FORMAT_PNG,
|
||||
FORMAT_TIFF,
|
||||
FORMAT_WEBP,
|
||||
FORMAT_RAW_DATA,
|
||||
FORMAT_UNKOWN
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
@param imageType the type of image, currently only supporting two types.
|
||||
@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.
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
*/
|
||||
bool initWithImageData(void * pData,
|
||||
int nDataLen,
|
||||
EImageFormat eFmt = kFmtUnKnown,
|
||||
Format eFmt = FORMAT_UNKOWN,
|
||||
int nWidth = 0,
|
||||
int nHeight = 0,
|
||||
int nBitsPerComponent = 8);
|
||||
|
@ -194,7 +194,7 @@ private:
|
|||
@param imageType the type of image, currently only supporting two types.
|
||||
@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
|
||||
|
|
|
@ -91,7 +91,7 @@ Image::~Image()
|
|||
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;
|
||||
|
||||
|
@ -128,7 +128,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType)
|
||||
bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType)
|
||||
{
|
||||
bool bRet = false;
|
||||
unsigned long nSize = 0;
|
||||
|
@ -148,7 +148,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image
|
|||
|
||||
bool Image::initWithImageData(void * pData,
|
||||
int nDataLen,
|
||||
EImageFormat eFmt/* = eSrcFmtPng*/,
|
||||
Format eFmt/* = eSrcFmtPng*/,
|
||||
int nWidth/* = 0*/,
|
||||
int nHeight/* = 0*/,
|
||||
int nBitsPerComponent/* = 8*/)
|
||||
|
@ -158,27 +158,27 @@ bool Image::initWithImageData(void * pData,
|
|||
{
|
||||
CC_BREAK_IF(! pData || nDataLen <= 0);
|
||||
|
||||
if (kFmtPng == eFmt)
|
||||
if (FORMAT_PNG == eFmt)
|
||||
{
|
||||
bRet = _initWithPngData(pData, nDataLen);
|
||||
break;
|
||||
}
|
||||
else if (kFmtJpg == eFmt)
|
||||
else if (FORMAT_JPG == eFmt)
|
||||
{
|
||||
bRet = _initWithJpgData(pData, nDataLen);
|
||||
break;
|
||||
}
|
||||
else if (kFmtTiff == eFmt)
|
||||
else if (FORMAT_TIFF == eFmt)
|
||||
{
|
||||
bRet = _initWithTiffData(pData, nDataLen);
|
||||
break;
|
||||
}
|
||||
else if (kFmtWebp == eFmt)
|
||||
else if (FORMAT_WEBP == eFmt)
|
||||
{
|
||||
bRet = _initWithWebpData(pData, nDataLen);
|
||||
break;
|
||||
}
|
||||
else if (kFmtRawData == eFmt)
|
||||
else if (FORMAT_RAW_DATA == eFmt)
|
||||
{
|
||||
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
|
||||
break;
|
||||
|
|
|
@ -416,7 +416,7 @@ Image::~Image()
|
|||
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;
|
||||
unsigned long nSize = 0;
|
||||
|
@ -433,7 +433,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType)
|
||||
bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType)
|
||||
{
|
||||
/*
|
||||
* FileUtils::fullPathFromRelativePath() is not thread-safe.
|
||||
|
@ -451,7 +451,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image
|
|||
|
||||
bool Image::initWithImageData(void * pData,
|
||||
int nDataLen,
|
||||
EImageFormat eFmt,
|
||||
Format eFmt,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
int nBitsPerComponent)
|
||||
|
@ -465,11 +465,11 @@ bool Image::initWithImageData(void * pData,
|
|||
do
|
||||
{
|
||||
CC_BREAK_IF(! pData || nDataLen <= 0);
|
||||
if (eFmt == kFmtRawData)
|
||||
if (eFmt == FORMAT_RAW_DATA)
|
||||
{
|
||||
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
|
||||
}
|
||||
else if (eFmt == kFmtWebp)
|
||||
else if (eFmt == FORMAT_WEBP)
|
||||
{
|
||||
bRet = _initWithWebpData(pData, nDataLen);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
|||
bool hasAlpha;
|
||||
CGImageAlphaInfo info;
|
||||
CGSize imageSize;
|
||||
Texture2DPixelFormat pixelFormat;
|
||||
Texture2D::PixelFormat pixelFormat;
|
||||
|
||||
info = CGImageGetAlphaInfo(image);
|
||||
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)
|
||||
{
|
||||
pixelFormat = kTexture2DPixelFormat_Default;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelFormat = kTexture2DPixelFormat_RGB565;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: No colorspace means a mask image
|
||||
pixelFormat = kTexture2DPixelFormat_A8;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_A8;
|
||||
}
|
||||
|
||||
imageSize.width = CGImageGetWidth(image);
|
||||
|
@ -100,9 +100,9 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
|||
|
||||
switch(pixelFormat)
|
||||
{
|
||||
case kTexture2DPixelFormat_RGBA8888:
|
||||
case kTexture2DPixelFormat_RGBA4444:
|
||||
case kTexture2DPixelFormat_RGB5A1:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
data = new unsigned char[POTHigh * POTWide * 4];
|
||||
info = hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast;
|
||||
|
@ -110,14 +110,14 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
|||
CGColorSpaceRelease(colorSpace);
|
||||
break;
|
||||
|
||||
case kTexture2DPixelFormat_RGB565:
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
data = new unsigned char[POTHigh * POTWide * 4];
|
||||
info = kCGImageAlphaNoneSkipLast;
|
||||
context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
break;
|
||||
case kTexture2DPixelFormat_A8:
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
data = new unsigned char[POTHigh * POTWide];
|
||||
info = kCGImageAlphaOnly;
|
||||
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
|
||||
|
||||
if(pixelFormat == kTexture2DPixelFormat_RGB565)
|
||||
if(pixelFormat == Texture2D::PIXEL_FORMAT_RGB565)
|
||||
{
|
||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
|
||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
||||
|
@ -153,7 +153,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
|||
data = tempData;
|
||||
|
||||
}
|
||||
else if (pixelFormat == kTexture2DPixelFormat_RGBA4444)
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444)
|
||||
{
|
||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
|
||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
||||
|
@ -172,7 +172,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
|||
data = tempData;
|
||||
|
||||
}
|
||||
else if (pixelFormat == kTexture2DPixelFormat_RGB5A1)
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1)
|
||||
{
|
||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
|
||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
||||
|
@ -542,7 +542,7 @@ Image::~Image()
|
|||
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);
|
||||
if (_enabledScale)
|
||||
|
@ -585,7 +585,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm
|
|||
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().
|
||||
|
@ -612,7 +612,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|||
unsigned int* inPixel32 = NULL;
|
||||
unsigned short* outPixel16 = NULL;
|
||||
bool hasAlpha;
|
||||
Texture2DPixelFormat pixelFormat;
|
||||
Texture2D::PixelFormat pixelFormat;
|
||||
|
||||
hasAlpha = this->hasAlpha();
|
||||
|
||||
|
@ -627,21 +627,21 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|||
{
|
||||
if (bpp >= 8)
|
||||
{
|
||||
pixelFormat = kTexture2DPixelFormat_RGB888;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("cocos2d: Texture2D: Using RGB565 texture since image has no alpha");
|
||||
pixelFormat = kTexture2DPixelFormat_RGB565;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
|
||||
}
|
||||
}
|
||||
|
||||
switch(pixelFormat) {
|
||||
case kTexture2DPixelFormat_RGBA8888:
|
||||
case kTexture2DPixelFormat_RGBA4444:
|
||||
case kTexture2DPixelFormat_RGB5A1:
|
||||
case kTexture2DPixelFormat_RGB565:
|
||||
case kTexture2DPixelFormat_A8:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
tempData = (unsigned char*)(this->getData());
|
||||
CCASSERT(tempData != NULL, "NULL image data.");
|
||||
|
||||
|
@ -666,7 +666,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|||
}
|
||||
|
||||
break;
|
||||
case kTexture2DPixelFormat_RGB888:
|
||||
case Texture2D::PIXEL_FORMAT_RGB888:
|
||||
tempData = (unsigned char*)(this->getData());
|
||||
CCASSERT(tempData != NULL, "NULL image data.");
|
||||
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
|
||||
|
||||
if(pixelFormat == kTexture2DPixelFormat_RGB565) {
|
||||
if(pixelFormat == Texture2D::PIXEL_FORMAT_RGB565) {
|
||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
|
||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
||||
inPixel32 = (unsigned int*)data;
|
||||
|
@ -713,7 +713,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|||
delete [] data;
|
||||
data = tempData;
|
||||
}
|
||||
else if (pixelFormat == kTexture2DPixelFormat_RGBA4444) {
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444) {
|
||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
|
||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
||||
inPixel32 = (unsigned int*)data;
|
||||
|
@ -732,7 +732,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|||
delete [] data;
|
||||
data = tempData;
|
||||
}
|
||||
else if (pixelFormat == kTexture2DPixelFormat_RGB5A1) {
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1) {
|
||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
|
||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
||||
inPixel32 = (unsigned int*)data;
|
||||
|
@ -751,10 +751,10 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|||
delete []data;
|
||||
data = tempData;
|
||||
}
|
||||
else if (pixelFormat == kTexture2DPixelFormat_A8)
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_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?
|
||||
|
@ -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,
|
||||
Format eFmt,
|
||||
int nWidth,
|
||||
int nHeight,
|
||||
int nBitsPerComponent)
|
||||
|
@ -797,11 +797,11 @@ bool Image::initWithImageData(void * pData,
|
|||
{
|
||||
CC_BREAK_IF(! pData || nDataLen <= 0);
|
||||
|
||||
if (eFmt == kFmtRawData)
|
||||
if (eFmt == FORMAT_RAW_DATA)
|
||||
{
|
||||
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
|
||||
}
|
||||
else if (eFmt == Image::kFmtWebp)
|
||||
else if (eFmt == Image::FORMAT_WEBP)
|
||||
{
|
||||
bRet = _initWithWebpData(pData, nDataLen);
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ bool Image::initWithImageData(void * pData,
|
|||
_height = (short)info.height;
|
||||
_width = (short)info.width;
|
||||
_bitsPerComponent = info.bitsPerComponent;
|
||||
if (eFmt == kFmtJpg)
|
||||
if (eFmt == FORMAT_JPG)
|
||||
{
|
||||
_hasAlpha = true;
|
||||
_preMulti = false;
|
||||
|
|
|
@ -136,7 +136,8 @@ SOURCES = ../actions/CCAction.cpp \
|
|||
../CCScheduler.cpp \
|
||||
../ccFPSImages.c \
|
||||
../ccTypes.cpp \
|
||||
../cocos2d.cpp
|
||||
../cocos2d.cpp \
|
||||
../CCDeprecated.cpp
|
||||
|
||||
COCOS_ROOT = ../..
|
||||
|
||||
|
|
|
@ -130,7 +130,8 @@ SOURCES = ../actions/CCAction.cpp \
|
|||
../CCScheduler.cpp \
|
||||
../ccFPSImages.c \
|
||||
../ccTypes.cpp \
|
||||
../cocos2d.cpp
|
||||
../cocos2d.cpp \
|
||||
../CCDeprecated.cpp
|
||||
|
||||
include cocos2dx.mk
|
||||
|
||||
|
|
|
@ -45,6 +45,31 @@ typedef struct _hashUniformEntry
|
|||
UT_hash_handle hh; // hash entry
|
||||
} 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()
|
||||
: _program(0)
|
||||
, _vertShader(0)
|
||||
|
@ -197,28 +222,28 @@ void GLProgram::addAttribute(const char* attributeName, GLuint index)
|
|||
|
||||
void GLProgram::updateUniforms()
|
||||
{
|
||||
_uniforms[kUniformPMatrix] = glGetUniformLocation(_program, kUniformPMatrix_s);
|
||||
_uniforms[kUniformMVMatrix] = glGetUniformLocation(_program, kUniformMVMatrix_s);
|
||||
_uniforms[kUniformMVPMatrix] = glGetUniformLocation(_program, kUniformMVPMatrix_s);
|
||||
_uniforms[UNIFORM_P_MATRIX] = glGetUniformLocation(_program, UNIFORM_NAME_P_MATRIX);
|
||||
_uniforms[UNIFORM_MV_MATRIX] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_MV_MATRIX);
|
||||
_uniforms[UNIFORM_MVP_MATRIX] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_MVP_MATRIX);
|
||||
|
||||
_uniforms[kUniformTime] = glGetUniformLocation(_program, kUniformTime_s);
|
||||
_uniforms[kUniformSinTime] = glGetUniformLocation(_program, kUniformSinTime_s);
|
||||
_uniforms[kUniformCosTime] = glGetUniformLocation(_program, kUniformCosTime_s);
|
||||
_uniforms[GLProgram::UNIFORM_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_TIME);
|
||||
_uniforms[GLProgram::UNIFORM_SIN_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_SIN_TIME);
|
||||
_uniforms[GLProgram::UNIFORM_COS_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_COS_TIME);
|
||||
|
||||
_usesTime = (
|
||||
_uniforms[kUniformTime] != -1 ||
|
||||
_uniforms[kUniformSinTime] != -1 ||
|
||||
_uniforms[kUniformCosTime] != -1
|
||||
_uniforms[GLProgram::UNIFORM_TIME] != -1 ||
|
||||
_uniforms[GLProgram::UNIFORM_SIN_TIME] != -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();
|
||||
|
||||
// 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()
|
||||
|
@ -509,9 +534,9 @@ void GLProgram::setUniformsForBuiltins()
|
|||
|
||||
kmMat4Multiply(&matrixMVP, &matrixP, &matrixMV);
|
||||
|
||||
setUniformLocationWithMatrix4fv(_uniforms[kUniformPMatrix], matrixP.mat, 1);
|
||||
setUniformLocationWithMatrix4fv(_uniforms[kUniformMVMatrix], matrixMV.mat, 1);
|
||||
setUniformLocationWithMatrix4fv(_uniforms[kUniformMVPMatrix], matrixMVP.mat, 1);
|
||||
setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_P_MATRIX], matrixP.mat, 1);
|
||||
setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MV_MATRIX], matrixMV.mat, 1);
|
||||
setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MVP_MATRIX], matrixMVP.mat, 1);
|
||||
|
||||
if(_usesTime)
|
||||
{
|
||||
|
@ -521,14 +546,14 @@ void GLProgram::setUniformsForBuiltins()
|
|||
// Getting Mach time per frame per shader using time could be extremely expensive.
|
||||
float time = director->getTotalFrames() * director->getAnimationInterval();
|
||||
|
||||
setUniformLocationWith4f(_uniforms[kUniformTime], time/10.0, time, time*2, time*4);
|
||||
setUniformLocationWith4f(_uniforms[kUniformSinTime], 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_TIME], time/10.0, time, time*2, time*4);
|
||||
setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_SIN_TIME], time/8.0, time/4.0, time/2.0, sinf(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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
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
|
||||
{
|
||||
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();
|
||||
virtual ~GLProgram();
|
||||
/** Initializes the GLProgram with a vertex and fragment with bytes array */
|
||||
|
@ -116,9 +118,9 @@ public:
|
|||
- kUniformPMatrix
|
||||
- kUniformMVMatrix
|
||||
- kUniformMVPMatrix
|
||||
- kUniformSampler
|
||||
- GLProgram::UNIFORM_SAMPLER
|
||||
|
||||
And it will bind "kUniformSampler" to 0
|
||||
And it will bind "GLProgram::UNIFORM_SAMPLER" to 0
|
||||
|
||||
*/
|
||||
void updateUniforms();
|
||||
|
@ -198,7 +200,7 @@ private:
|
|||
GLuint _program;
|
||||
GLuint _vertShader;
|
||||
GLuint _fragShader;
|
||||
GLint _uniforms[kUniform_MAX];
|
||||
GLint _uniforms[UNIFORM_MAX];
|
||||
struct _hashUniformEntry* _hashForUniforms;
|
||||
bool _usesTime;
|
||||
};
|
||||
|
|
|
@ -100,14 +100,14 @@ void ShaderCache::loadDefaultShaders()
|
|||
GLProgram *p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_PositionTextureColor);
|
||||
|
||||
_programs->setObject(p, kShader_PositionTextureColor);
|
||||
_programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR);
|
||||
p->release();
|
||||
|
||||
// Position Texture Color alpha test
|
||||
p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest);
|
||||
|
||||
_programs->setObject(p, kShader_PositionTextureColorAlphaTest);
|
||||
_programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
p->release();
|
||||
|
||||
//
|
||||
|
@ -116,7 +116,7 @@ void ShaderCache::loadDefaultShaders()
|
|||
p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_PositionColor);
|
||||
|
||||
_programs->setObject(p, kShader_PositionColor);
|
||||
_programs->setObject(p, GLProgram::SHADER_NAME_POSITION_COLOR);
|
||||
p->release();
|
||||
|
||||
//
|
||||
|
@ -125,7 +125,7 @@ void ShaderCache::loadDefaultShaders()
|
|||
p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_PositionTexture);
|
||||
|
||||
_programs->setObject(p, kShader_PositionTexture);
|
||||
_programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE);
|
||||
p->release();
|
||||
|
||||
//
|
||||
|
@ -134,7 +134,7 @@ void ShaderCache::loadDefaultShaders()
|
|||
p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_PositionTexture_uColor);
|
||||
|
||||
_programs->setObject(p ,kShader_PositionTexture_uColor);
|
||||
_programs->setObject(p ,GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR);
|
||||
p->release();
|
||||
|
||||
//
|
||||
|
@ -143,7 +143,7 @@ void ShaderCache::loadDefaultShaders()
|
|||
p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_PositionTextureA8Color);
|
||||
|
||||
_programs->setObject(p, kShader_PositionTextureA8Color);
|
||||
_programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR);
|
||||
p->release();
|
||||
|
||||
//
|
||||
|
@ -152,7 +152,7 @@ void ShaderCache::loadDefaultShaders()
|
|||
p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_Position_uColor);
|
||||
|
||||
_programs->setObject(p, kShader_Position_uColor);
|
||||
_programs->setObject(p, GLProgram::SHADER_NAME_POSITION_U_COLOR);
|
||||
p->release();
|
||||
|
||||
//
|
||||
|
@ -161,7 +161,7 @@ void ShaderCache::loadDefaultShaders()
|
|||
p = new GLProgram();
|
||||
loadDefaultShader(p, kShaderType_PositionLengthTexureColor);
|
||||
|
||||
_programs->setObject(p, kShader_PositionLengthTexureColor);
|
||||
_programs->setObject(p, GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR);
|
||||
p->release();
|
||||
}
|
||||
|
||||
|
@ -170,54 +170,54 @@ void ShaderCache::reloadDefaultShaders()
|
|||
// reset all programs and reload them
|
||||
|
||||
// Position Texture Color shader
|
||||
GLProgram *p = programForKey(kShader_PositionTextureColor);
|
||||
GLProgram *p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR);
|
||||
p->reset();
|
||||
loadDefaultShader(p, kShaderType_PositionTextureColor);
|
||||
|
||||
// Position Texture Color alpha test
|
||||
p = programForKey(kShader_PositionTextureColorAlphaTest);
|
||||
p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
p->reset();
|
||||
loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest);
|
||||
|
||||
//
|
||||
// Position, Color shader
|
||||
//
|
||||
p = programForKey(kShader_PositionColor);
|
||||
p = programForKey(GLProgram::SHADER_NAME_POSITION_COLOR);
|
||||
p->reset();
|
||||
loadDefaultShader(p, kShaderType_PositionColor);
|
||||
|
||||
//
|
||||
// Position Texture shader
|
||||
//
|
||||
p = programForKey(kShader_PositionTexture);
|
||||
p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE);
|
||||
p->reset();
|
||||
loadDefaultShader(p, kShaderType_PositionTexture);
|
||||
|
||||
//
|
||||
// Position, Texture attribs, 1 Color as uniform shader
|
||||
//
|
||||
p = programForKey(kShader_PositionTexture_uColor);
|
||||
p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR);
|
||||
p->reset();
|
||||
loadDefaultShader(p, kShaderType_PositionTexture_uColor);
|
||||
|
||||
//
|
||||
// Position Texture A8 Color shader
|
||||
//
|
||||
p = programForKey(kShader_PositionTextureA8Color);
|
||||
p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR);
|
||||
p->reset();
|
||||
loadDefaultShader(p, kShaderType_PositionTextureA8Color);
|
||||
|
||||
//
|
||||
// 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();
|
||||
loadDefaultShader(p, kShaderType_Position_uColor);
|
||||
|
||||
//
|
||||
// Position, Legth(TexCoords, Color (used by Draw Node basically )
|
||||
//
|
||||
p = programForKey(kShader_PositionLengthTexureColor);
|
||||
p = programForKey(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR);
|
||||
p->reset();
|
||||
loadDefaultShader(p, kShaderType_PositionLengthTexureColor);
|
||||
}
|
||||
|
@ -228,60 +228,60 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type)
|
|||
case kShaderType_PositionTextureColor:
|
||||
p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColor_frag);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
break;
|
||||
case kShaderType_PositionTextureColorAlphaTest:
|
||||
p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
break;
|
||||
case kShaderType_PositionColor:
|
||||
p->initWithVertexShaderByteArray(ccPositionColor_vert ,ccPositionColor_frag);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
|
||||
break;
|
||||
case kShaderType_PositionTexture:
|
||||
p->initWithVertexShaderByteArray(ccPositionTexture_vert ,ccPositionTexture_frag);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
break;
|
||||
case kShaderType_PositionTexture_uColor:
|
||||
p->initWithVertexShaderByteArray(ccPositionTexture_uColor_vert, ccPositionTexture_uColor_frag);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
break;
|
||||
case kShaderType_PositionTextureA8Color:
|
||||
p->initWithVertexShaderByteArray(ccPositionTextureA8Color_vert, ccPositionTextureA8Color_frag);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
break;
|
||||
case kShaderType_Position_uColor:
|
||||
p->initWithVertexShaderByteArray(ccPosition_uColor_vert, ccPosition_uColor_frag);
|
||||
|
||||
p->addAttribute("aVertex", kVertexAttrib_Position);
|
||||
p->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
|
||||
break;
|
||||
case kShaderType_PositionLengthTexureColor:
|
||||
p->initWithVertexShaderByteArray(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(kAttributeNameColor, kVertexAttrib_Color);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -232,37 +232,37 @@ void ccGLEnableVertexAttribs( unsigned int flags )
|
|||
ccGLBindVAO(0);
|
||||
|
||||
/* Position */
|
||||
bool enablePosition = flags & kVertexAttribFlag_Position;
|
||||
bool enablePosition = flags & VERTEX_ATTRIB_FLAG_POSITION;
|
||||
|
||||
if( enablePosition != s_bVertexAttribPosition ) {
|
||||
if( enablePosition )
|
||||
glEnableVertexAttribArray( kVertexAttrib_Position );
|
||||
glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION );
|
||||
else
|
||||
glDisableVertexAttribArray( kVertexAttrib_Position );
|
||||
glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION );
|
||||
|
||||
s_bVertexAttribPosition = enablePosition;
|
||||
}
|
||||
|
||||
/* 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 )
|
||||
glEnableVertexAttribArray( kVertexAttrib_Color );
|
||||
glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR );
|
||||
else
|
||||
glDisableVertexAttribArray( kVertexAttrib_Color );
|
||||
glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR );
|
||||
|
||||
s_bVertexAttribColor = enableColor;
|
||||
}
|
||||
|
||||
/* 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 )
|
||||
glEnableVertexAttribArray( kVertexAttrib_TexCoords );
|
||||
glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS );
|
||||
else
|
||||
glDisableVertexAttribArray( kVertexAttrib_TexCoords );
|
||||
glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS );
|
||||
|
||||
s_bVertexAttribTexCoords = enableTexCoords;
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ class GLProgram;
|
|||
|
||||
/** vertex attrib flags */
|
||||
enum {
|
||||
kVertexAttribFlag_None = 0,
|
||||
VERTEX_ATTRIB_FLAT_NONE = 0,
|
||||
|
||||
kVertexAttribFlag_Position = 1 << 0,
|
||||
kVertexAttribFlag_Color = 1 << 1,
|
||||
kVertexAttribFlag_TexCoords = 1 << 2,
|
||||
VERTEX_ATTRIB_FLAG_POSITION = 1 << 0,
|
||||
VERTEX_ATTRIB_FLAG_COLOR = 1 << 1,
|
||||
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 */
|
||||
|
@ -105,9 +105,9 @@ void CC_DLL ccSetProjectionMatrixDirty(void);
|
|||
/** Will enable the vertex attribs that are passed as flags.
|
||||
Possible flags:
|
||||
|
||||
* kVertexAttribFlag_Position
|
||||
* kVertexAttribFlag_Color
|
||||
* kVertexAttribFlag_TexCoords
|
||||
* VERTEX_ATTRIB_FLAG_POSITION
|
||||
* VERTEX_ATTRIB_FLAG_COLOR
|
||||
* VERTEX_ATTRIB_FLAG_TEX_COORDS
|
||||
|
||||
These flags can be ORed. The flags that are not present, will be disabled.
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated
|
|||
_quad.tr.colors = tmpColor;
|
||||
|
||||
// shader program
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
||||
// update texture (calls updateBlendFunc)
|
||||
setTexture(pTexture);
|
||||
|
@ -554,7 +554,7 @@ void Sprite::draw(void)
|
|||
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
|
||||
|
||||
ccGLBindTexture2D( _texture->getName() );
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
|
||||
#define kQuadSize sizeof(_quad.bl)
|
||||
#ifdef EMSCRIPTEN
|
||||
|
@ -566,15 +566,15 @@ void Sprite::draw(void)
|
|||
|
||||
// vertex
|
||||
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
|
||||
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
|
||||
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);
|
||||
|
@ -1102,7 +1102,7 @@ void Sprite::setTexture(Texture2D *texture)
|
|||
if (NULL == texture)
|
||||
{
|
||||
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.");
|
||||
|
||||
texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY);
|
||||
|
|
|
@ -94,7 +94,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity)
|
|||
_descendants = new Array();
|
||||
_descendants->initWithCapacity(capacity);
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ TextFieldTTF::~TextFieldTTF()
|
|||
// 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();
|
||||
if(pRet && pRet->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
|
||||
|
@ -106,7 +106,7 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, c
|
|||
// 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)
|
||||
{
|
||||
|
|
|
@ -103,11 +103,11 @@ public:
|
|||
//char * description();
|
||||
|
||||
/** 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 */
|
||||
static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize);
|
||||
/** 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 */
|
||||
bool initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize);
|
||||
|
||||
|
|
|
@ -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)
|
||||
// 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
|
||||
static bool PVRHaveAlphaPremultiplied_ = false;
|
||||
|
@ -64,7 +64,7 @@ Texture2D::Texture2D()
|
|||
: _PVRHaveAlphaPremultiplied(true)
|
||||
, _pixelsWide(0)
|
||||
, _pixelsHigh(0)
|
||||
, _pixelFormat(kTexture2DPixelFormat_Default)
|
||||
, _pixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT)
|
||||
, _name(0)
|
||||
, _maxS(0.0)
|
||||
, _maxT(0.0)
|
||||
|
@ -89,7 +89,7 @@ Texture2D::~Texture2D()
|
|||
}
|
||||
}
|
||||
|
||||
Texture2DPixelFormat Texture2D::getPixelFormat() const
|
||||
Texture2D::PixelFormat Texture2D::getPixelFormat() const
|
||||
{
|
||||
return _pixelFormat;
|
||||
}
|
||||
|
@ -172,11 +172,11 @@ bool Texture2D::hasPremultipliedAlpha() const
|
|||
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;
|
||||
//Hack: bitsPerPixelForFormat returns wrong number for RGB_888 textures. See function.
|
||||
if(pixelFormat == kTexture2DPixelFormat_RGB888)
|
||||
if(pixelFormat == Texture2D::PIXEL_FORMAT_RGB888)
|
||||
{
|
||||
bitsPerPixel = 24;
|
||||
}
|
||||
|
@ -217,28 +217,28 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat 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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
break;
|
||||
default:
|
||||
|
@ -256,7 +256,7 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat,
|
|||
_hasPremultipliedAlpha = false;
|
||||
_hasMipmaps = false;
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTexture));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
|
|||
unsigned short* outPixel16 = NULL;
|
||||
bool hasAlpha = image->hasAlpha();
|
||||
Size imageSize = Size((float)(image->getWidth()), (float)(image->getHeight()));
|
||||
Texture2DPixelFormat pixelFormat;
|
||||
Texture2D::PixelFormat pixelFormat;
|
||||
size_t bpp = image->getBitsPerComponent();
|
||||
|
||||
// compute pixel format
|
||||
|
@ -313,11 +313,11 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
|
|||
{
|
||||
if (bpp >= 8)
|
||||
{
|
||||
pixelFormat = kTexture2DPixelFormat_RGB888;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
|
||||
}
|
||||
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
|
||||
unsigned int length = width * height;
|
||||
|
||||
if (pixelFormat == kTexture2DPixelFormat_RGB565)
|
||||
if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB565)
|
||||
{
|
||||
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"
|
||||
|
||||
|
@ -377,7 +377,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
|
|||
((((*inPixel32 >> 24) & 0xFF) >> 4) << 0); // A
|
||||
}
|
||||
}
|
||||
else if (pixelFormat == kTexture2DPixelFormat_RGB5A1)
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGB5A1)
|
||||
{
|
||||
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
|
||||
inPixel32 = (unsigned int*)image->getData();
|
||||
|
@ -393,7 +393,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
|
|||
((((*inPixel32 >> 24) & 0xFF) >> 7) << 0); // A
|
||||
}
|
||||
}
|
||||
else if (pixelFormat == kTexture2DPixelFormat_A8)
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_A8)
|
||||
{
|
||||
// Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "AAAAAAAA"
|
||||
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"
|
||||
inPixel32 = (unsigned int*)image->getData();
|
||||
|
@ -433,7 +433,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
|
|||
}
|
||||
|
||||
// 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;
|
||||
|
||||
|
@ -461,20 +461,20 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
|||
bool bRet = false;
|
||||
Image::ETextAlign eAlign;
|
||||
|
||||
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment)
|
||||
if (Label::VERTICAL_TEXT_ALIGNMENT_TOP == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop
|
||||
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignTop
|
||||
: (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
|
||||
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignCenter
|
||||
: (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
|
||||
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignBottom
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -591,7 +591,7 @@ void Texture2D::drawAtPoint(const Point& point)
|
|||
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->setUniformsForBuiltins();
|
||||
|
||||
|
@ -600,13 +600,13 @@ void Texture2D::drawAtPoint(const Point& point)
|
|||
|
||||
#ifdef EMSCRIPTEN
|
||||
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);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates);
|
||||
#endif // EMSCRIPTEN
|
||||
|
||||
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.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->setUniformsForBuiltins();
|
||||
|
||||
|
@ -633,13 +633,13 @@ void Texture2D::drawInRect(const Rect& rect)
|
|||
|
||||
#ifdef EMSCRIPTEN
|
||||
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);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
#else
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates);
|
||||
#endif // EMSCRIPTEN
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
@ -789,34 +789,34 @@ const char* Texture2D::getStringForFormat() const
|
|||
{
|
||||
switch (_pixelFormat)
|
||||
{
|
||||
case kTexture2DPixelFormat_RGBA8888:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
return "RGBA8888";
|
||||
|
||||
case kTexture2DPixelFormat_RGB888:
|
||||
case Texture2D::PIXEL_FORMAT_RGB888:
|
||||
return "RGB888";
|
||||
|
||||
case kTexture2DPixelFormat_RGB565:
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
return "RGB565";
|
||||
|
||||
case kTexture2DPixelFormat_RGBA4444:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
return "RGBA4444";
|
||||
|
||||
case kTexture2DPixelFormat_RGB5A1:
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
return "RGB5A1";
|
||||
|
||||
case kTexture2DPixelFormat_AI88:
|
||||
case Texture2D::PIXEL_FORMAT_AI88:
|
||||
return "AI88";
|
||||
|
||||
case kTexture2DPixelFormat_A8:
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
return "A8";
|
||||
|
||||
case kTexture2DPixelFormat_I8:
|
||||
case Texture2D::PIXEL_FORMAT_I8:
|
||||
return "I8";
|
||||
|
||||
case kTexture2DPixelFormat_PVRTC4:
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC4:
|
||||
return "PVRTC4";
|
||||
|
||||
case kTexture2DPixelFormat_PVRTC2:
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC2:
|
||||
return "PVRTC2";
|
||||
|
||||
default:
|
||||
|
@ -833,50 +833,50 @@ const char* Texture2D::getStringForFormat() const
|
|||
//
|
||||
// implementation Texture2D (PixelFormat)
|
||||
|
||||
void Texture2D::setDefaultAlphaPixelFormat(Texture2DPixelFormat format)
|
||||
void Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat format)
|
||||
{
|
||||
g_defaultAlphaPixelFormat = format;
|
||||
}
|
||||
|
||||
Texture2DPixelFormat Texture2D::getDefaultAlphaPixelFormat()
|
||||
Texture2D::PixelFormat Texture2D::getDefaultAlphaPixelFormat()
|
||||
{
|
||||
return g_defaultAlphaPixelFormat;
|
||||
}
|
||||
|
||||
unsigned int Texture2D::getBitsPerPixelForFormat(Texture2DPixelFormat format) const
|
||||
unsigned int Texture2D::getBitsPerPixelForFormat(Texture2D::PixelFormat format) const
|
||||
{
|
||||
unsigned int ret=0;
|
||||
|
||||
switch (format) {
|
||||
case kTexture2DPixelFormat_RGBA8888:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
ret = 32;
|
||||
break;
|
||||
case kTexture2DPixelFormat_RGB888:
|
||||
case Texture2D::PIXEL_FORMAT_RGB888:
|
||||
// It is 32 and not 24, since its internal representation uses 32 bits.
|
||||
ret = 32;
|
||||
break;
|
||||
case kTexture2DPixelFormat_RGB565:
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
ret = 16;
|
||||
break;
|
||||
case kTexture2DPixelFormat_RGBA4444:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
ret = 16;
|
||||
break;
|
||||
case kTexture2DPixelFormat_RGB5A1:
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
ret = 16;
|
||||
break;
|
||||
case kTexture2DPixelFormat_AI88:
|
||||
case Texture2D::PIXEL_FORMAT_AI88:
|
||||
ret = 16;
|
||||
break;
|
||||
case kTexture2DPixelFormat_A8:
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
ret = 8;
|
||||
break;
|
||||
case kTexture2DPixelFormat_I8:
|
||||
case Texture2D::PIXEL_FORMAT_I8:
|
||||
ret = 8;
|
||||
break;
|
||||
case kTexture2DPixelFormat_PVRTC4:
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC4:
|
||||
ret = 4;
|
||||
break;
|
||||
case kTexture2DPixelFormat_PVRTC2:
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC2:
|
||||
ret = 2;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -45,37 +45,6 @@ class Image;
|
|||
|
||||
//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;
|
||||
|
||||
/**
|
||||
|
@ -102,14 +71,46 @@ class CC_DLL Texture2D : public Object
|
|||
#endif // EMSCRIPTEN
|
||||
{
|
||||
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.
|
||||
If the UIImage contains alpha channel, then the options are:
|
||||
- generate 32-bit textures: kTexture2DPixelFormat_RGBA8888 (default one)
|
||||
- generate 24-bit textures: kTexture2DPixelFormat_RGB888
|
||||
- generate 16-bit textures: kTexture2DPixelFormat_RGBA4444
|
||||
- generate 16-bit textures: kTexture2DPixelFormat_RGB5A1
|
||||
- generate 16-bit textures: kTexture2DPixelFormat_RGB565
|
||||
- generate 8-bit textures: kTexture2DPixelFormat_A8 (only use it if you use just 1 color)
|
||||
- generate 32-bit textures: Texture2D::PIXEL_FORMAT_RGBA8888 (default one)
|
||||
- generate 24-bit textures: Texture2D::PIXEL_FORMAT_RGB888
|
||||
- generate 16-bit textures: Texture2D::PIXEL_FORMAT_RGBA4444
|
||||
- generate 16-bit textures: Texture2D::PIXEL_FORMAT_RGB5A1
|
||||
- generate 16-bit textures: Texture2D::PIXEL_FORMAT_RGB565
|
||||
- generate 8-bit textures: Texture2D::PIXEL_FORMAT_A8 (only use it if you use just 1 color)
|
||||
|
||||
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)
|
||||
|
@ -119,13 +120,13 @@ public:
|
|||
|
||||
@since v0.8
|
||||
*/
|
||||
static void setDefaultAlphaPixelFormat(Texture2DPixelFormat format);
|
||||
static void setDefaultAlphaPixelFormat(Texture2D::PixelFormat format);
|
||||
|
||||
/** returns the alpha pixel format
|
||||
@since v0.8
|
||||
*/
|
||||
static Texture2DPixelFormat getDefaultAlphaPixelFormat();
|
||||
CC_DEPRECATED_ATTRIBUTE static Texture2DPixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); };
|
||||
static Texture2D::PixelFormat getDefaultAlphaPixelFormat();
|
||||
CC_DEPRECATED_ATTRIBUTE static Texture2D::PixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); };
|
||||
|
||||
/** 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
|
||||
|
@ -148,7 +149,7 @@ public:
|
|||
void* keepData(void *data, unsigned int length);
|
||||
|
||||
/** 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.
|
||||
|
@ -168,7 +169,7 @@ public:
|
|||
bool initWithImage(Image * uiImage);
|
||||
|
||||
/** 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*/
|
||||
bool initWithString(const char *text, const FontDefinition& textDefinition);
|
||||
|
||||
|
@ -230,8 +231,8 @@ public:
|
|||
/** Helper functions that returns bits per pixels for a given format.
|
||||
@since v2.0
|
||||
*/
|
||||
unsigned int getBitsPerPixelForFormat(Texture2DPixelFormat format) const;
|
||||
CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2DPixelFormat format) const { return getBitsPerPixelForFormat(format); };
|
||||
unsigned int getBitsPerPixelForFormat(Texture2D::PixelFormat format) const;
|
||||
CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2D::PixelFormat format) const { return getBitsPerPixelForFormat(format); };
|
||||
|
||||
/** content size */
|
||||
const Size& getContentSizeInPixels();
|
||||
|
@ -240,7 +241,7 @@ public:
|
|||
bool hasMipmaps() const;
|
||||
|
||||
/** Gets the pixel format of the texture */
|
||||
Texture2DPixelFormat getPixelFormat() const;
|
||||
Texture2D::PixelFormat getPixelFormat() const;
|
||||
|
||||
/** Gets the width of the texture in pixels */
|
||||
unsigned int getPixelsWide() const;
|
||||
|
@ -274,7 +275,7 @@ private:
|
|||
|
||||
protected:
|
||||
/** pixel format of the texture */
|
||||
Texture2DPixelFormat _pixelFormat;
|
||||
Texture2D::PixelFormat _pixelFormat;
|
||||
|
||||
/** width in pixels */
|
||||
unsigned int _pixelsWide;
|
||||
|
|
|
@ -262,16 +262,16 @@ void TextureAtlas::setupVBOandVAO()
|
|||
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW);
|
||||
|
||||
// vertices
|
||||
glEnableVertexAttribArray(kVertexAttrib_Position);
|
||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
|
||||
|
||||
// colors
|
||||
glEnableVertexAttribArray(kVertexAttrib_Color);
|
||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
|
||||
|
||||
// tex coords
|
||||
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
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]);
|
||||
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;
|
||||
}
|
||||
|
||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
||||
ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
||||
|
||||
// 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
|
||||
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
|
||||
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]);
|
||||
|
||||
|
|
|
@ -207,8 +207,8 @@ void TextureCache::loadImage()
|
|||
const char *filename = pAsyncStruct->filename.c_str();
|
||||
|
||||
// compute image type
|
||||
Image::EImageFormat imageType = computeImageFormatType(pAsyncStruct->filename);
|
||||
if (imageType == Image::kFmtUnKnown)
|
||||
Image::Format imageType = computeImageFormatType(pAsyncStruct->filename);
|
||||
if (imageType == Image::FORMAT_UNKOWN)
|
||||
{
|
||||
CCLOG("unsupported format %s",filename);
|
||||
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")))
|
||||
{
|
||||
ret = Image::kFmtJpg;
|
||||
ret = Image::FORMAT_JPG;
|
||||
}
|
||||
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")))
|
||||
{
|
||||
ret = Image::kFmtTiff;
|
||||
ret = Image::FORMAT_TIFF;
|
||||
}
|
||||
else if ((std::string::npos != filename.find(".webp")) || (std::string::npos != filename.find(".WEBP")))
|
||||
{
|
||||
ret = Image::kFmtWebp;
|
||||
ret = Image::FORMAT_WEBP;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -365,22 +365,22 @@ Texture2D * TextureCache::addImage(const char * path)
|
|||
}
|
||||
else
|
||||
{
|
||||
Image::EImageFormat eImageFormat = Image::kFmtUnKnown;
|
||||
Image::Format eImageFormat = Image::FORMAT_UNKOWN;
|
||||
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"))
|
||||
{
|
||||
eImageFormat = Image::kFmtJpg;
|
||||
eImageFormat = Image::FORMAT_JPG;
|
||||
}
|
||||
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"))
|
||||
{
|
||||
eImageFormat = Image::kFmtWebp;
|
||||
eImageFormat = Image::FORMAT_WEBP;
|
||||
}
|
||||
|
||||
pImage = new Image();
|
||||
|
@ -433,7 +433,7 @@ Texture2D * TextureCache::addPVRImage(const char* path)
|
|||
{
|
||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||
// cache the texture file name
|
||||
VolatileTexture::addImageTexture(texture, fullpath.c_str(), Image::kFmtRawData);
|
||||
VolatileTexture::addImageTexture(texture, fullpath.c_str(), Image::FORMAT_RAW_DATA);
|
||||
#endif
|
||||
_textures->setObject(texture, key.c_str());
|
||||
texture->autorelease();
|
||||
|
@ -641,9 +641,9 @@ VolatileTexture::VolatileTexture(Texture2D *t)
|
|||
: _texture(t)
|
||||
, _cashedImageType(kInvalid)
|
||||
, _textureData(NULL)
|
||||
, _pixelFormat(kTexture2DPixelFormat_RGBA8888)
|
||||
, _pixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888)
|
||||
, _fileName("")
|
||||
, _fmtImage(Image::kFmtPng)
|
||||
, _fmtImage(Image::FORMAT_PNG)
|
||||
, _text("")
|
||||
, _uiImage(NULL)
|
||||
{
|
||||
|
@ -660,7 +660,7 @@ VolatileTexture::~VolatileTexture()
|
|||
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)
|
||||
{
|
||||
|
@ -705,7 +705,7 @@ VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt)
|
|||
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)
|
||||
{
|
||||
|
@ -785,7 +785,7 @@ void VolatileTexture::reloadAllTextures()
|
|||
|
||||
if (std::string::npos != lowerCase.find(".pvr"))
|
||||
{
|
||||
Texture2DPixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
|
||||
|
||||
vt->_texture->initWithPVRFile(vt->_fileName.c_str());
|
||||
|
@ -799,7 +799,7 @@ void VolatileTexture::reloadAllTextures()
|
|||
|
||||
if (pImage && pImage->initWithImageData((void*)pBuffer, nSize, vt->_fmtImage))
|
||||
{
|
||||
Texture2DPixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
|
||||
vt->_texture->initWithImage(pImage);
|
||||
Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat);
|
||||
|
|
|
@ -161,7 +161,7 @@ public:
|
|||
private:
|
||||
void addImageAsyncCallBack(float dt);
|
||||
void loadImage();
|
||||
Image::EImageFormat computeImageFormatType(std::string& filename);
|
||||
Image::Format computeImageFormatType(std::string& filename);
|
||||
|
||||
public:
|
||||
struct AsyncStruct
|
||||
|
@ -179,7 +179,7 @@ protected:
|
|||
{
|
||||
AsyncStruct *asyncStruct;
|
||||
Image *image;
|
||||
Image::EImageFormat imageType;
|
||||
Image::Format imageType;
|
||||
} ImageInfo;
|
||||
|
||||
std::thread* _loadingThread;
|
||||
|
@ -218,9 +218,9 @@ public:
|
|||
VolatileTexture(Texture2D *t);
|
||||
~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 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 setTexParameters(Texture2D *t, const ccTexParams &texParams);
|
||||
|
@ -245,10 +245,10 @@ protected:
|
|||
|
||||
void *_textureData;
|
||||
Size _textureSize;
|
||||
Texture2DPixelFormat _pixelFormat;
|
||||
Texture2D::PixelFormat _pixelFormat;
|
||||
|
||||
std::string _fileName;
|
||||
Image::EImageFormat _fmtImage;
|
||||
Image::Format _fmtImage;
|
||||
|
||||
ccTexParams _texParams;
|
||||
std::string _text;
|
||||
|
|
|
@ -46,35 +46,35 @@ NS_CC_BEGIN
|
|||
static const ccPVRTexturePixelFormatInfo PVRTableFormats[] = {
|
||||
|
||||
// 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
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
// available.
|
||||
#ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||
// 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
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
};
|
||||
|
||||
|
@ -235,7 +235,7 @@ TexturePVR::TexturePVR()
|
|||
, _hasPremultipliedAlpha(false)
|
||||
, _forcePremultipliedAlpha(false)
|
||||
, _retainName(false)
|
||||
, _format(kTexture2DPixelFormat_Default)
|
||||
, _format(Texture2D::PIXEL_FORMAT_DEFAULT)
|
||||
, _pixelFormatInfo(NULL)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef struct _ccPVRTexturePixelFormatInfo {
|
|||
uint32_t bpp;
|
||||
bool compressed;
|
||||
bool alpha;
|
||||
Texture2DPixelFormat ccPixelFormat;
|
||||
Texture2D::PixelFormat ccPixelFormat;
|
||||
} ccPVRTexturePixelFormatInfo;
|
||||
|
||||
/**
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
inline bool isForcePremultipliedAlpha() const { return _forcePremultipliedAlpha; }
|
||||
/** how many mipmaps the texture has. 1 means one level (level 0 */
|
||||
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 void setRetainName(bool retainName) { _retainName = retainName; }
|
||||
|
||||
|
@ -136,7 +136,7 @@ protected:
|
|||
|
||||
// cocos2d integration
|
||||
bool _retainName;
|
||||
Texture2DPixelFormat _format;
|
||||
Texture2D::PixelFormat _format;
|
||||
|
||||
const ccPVRTexturePixelFormatInfo *_pixelFormatInfo;
|
||||
};
|
||||
|
|
|
@ -208,9 +208,9 @@ void TMXLayer::parseInternalProperties()
|
|||
{
|
||||
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
|
||||
|
||||
|
|
|
@ -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();
|
||||
scheduleUpdate();
|
||||
|
|
|
@ -48,7 +48,7 @@ BatchNode::BatchNode()
|
|||
bool BatchNode::init()
|
||||
{
|
||||
bool ret = Node::init();
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag)
|
|||
GLProgram *shader = new GLProgram();
|
||||
shader->initWithVertexShaderFilename(vert, frag);
|
||||
|
||||
shader->addAttribute("aVertex", kVertexAttrib_Position);
|
||||
shader->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
shader->link();
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ void* Texture2DMutable::keepData(void* data, unsigned int lenght)
|
|||
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_->initWithImageFile(imageFile);
|
||||
|
@ -57,22 +57,22 @@ bool Texture2DMutable::initWithImageFile(const char *imageFile)
|
|||
bool hasAlpha = image_->hasAlpha();
|
||||
Size imageSize = Size((float)(image_->getWidth()), (float)(image_->getHeight()));
|
||||
size_t bpp = image_->getBitsPerComponent();
|
||||
cocos2d::Texture2DPixelFormat pixelFormat;
|
||||
cocos2d::Texture2D::PixelFormat pixelFormat;
|
||||
|
||||
// compute pixel format
|
||||
if(hasAlpha)
|
||||
{
|
||||
pixelFormat = kTexture2DPixelFormat_Default;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bpp >= 8)
|
||||
{
|
||||
pixelFormat = kTexture2DPixelFormat_RGB888;
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (pixelFormat) {
|
||||
case kTexture2DPixelFormat_RGBA8888: bytesPerPixel_ = 4; break;
|
||||
case kTexture2DPixelFormat_A8: bytesPerPixel_ = 1; break;
|
||||
case kTexture2DPixelFormat_RGBA4444:
|
||||
case kTexture2DPixelFormat_RGB565:
|
||||
case kTexture2DPixelFormat_RGB5A1:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888: bytesPerPixel_ = 4; break;
|
||||
case Texture2D::PIXEL_FORMAT_A8: bytesPerPixel_ = 1; break;
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
bytesPerPixel_ = 2;
|
||||
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 = _pixelsHigh - pt.y;
|
||||
|
||||
if(_pixelFormat == kTexture2DPixelFormat_RGBA8888){
|
||||
if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA8888){
|
||||
unsigned int *pixel = (unsigned int *)data_;
|
||||
pixel = pixel + (y * _pixelsWide) + x;
|
||||
c.r = *pixel & 0xff;
|
||||
c.g = (*pixel >> 8) & 0xff;
|
||||
c.b = (*pixel >> 16) & 0xff;
|
||||
c.a = (*pixel >> 24) & 0xff;
|
||||
} else if(_pixelFormat == kTexture2DPixelFormat_RGBA4444){
|
||||
} else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444){
|
||||
GLushort *pixel = (GLushort *)data_;
|
||||
pixel = pixel + (y * _pixelsWide) + x;
|
||||
c.a = ((*pixel & 0xf) << 4) | (*pixel & 0xf);
|
||||
c.b = (((*pixel >> 4) & 0xf) << 4) | ((*pixel >> 4) & 0xf);
|
||||
c.g = (((*pixel >> 8) & 0xf) << 4) | ((*pixel >> 8) & 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_;
|
||||
pixel = pixel + (y * _pixelsWide) + x;
|
||||
c.r = ((*pixel >> 11) & 0x1f)<<3;
|
||||
c.g = ((*pixel >> 6) & 0x1f)<<3;
|
||||
c.b = ((*pixel >> 1) & 0x1f)<<3;
|
||||
c.a = (*pixel & 0x1)*255;
|
||||
} else if(_pixelFormat == kTexture2DPixelFormat_RGB565){
|
||||
} else if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGB565){
|
||||
GLushort *pixel = (GLushort *)data_;
|
||||
pixel = pixel + (y * _pixelsWide) + x;
|
||||
c.b = (*pixel & 0x1f)<<3;
|
||||
c.g = ((*pixel >> 5) & 0x3f)<<2;
|
||||
c.r = ((*pixel >> 11) & 0x1f)<<3;
|
||||
c.a = 255;
|
||||
} else if(_pixelFormat == kTexture2DPixelFormat_A8){
|
||||
} else if(_pixelFormat == Texture2D::PIXEL_FORMAT_A8){
|
||||
GLubyte *pixel = (GLubyte *)data_;
|
||||
c.a = pixel[(y * _pixelsWide) + x];
|
||||
// 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
|
||||
// portable =/
|
||||
|
||||
if(_pixelFormat == kTexture2DPixelFormat_RGBA8888){
|
||||
if(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA8888){
|
||||
unsigned int *pixel = (unsigned int *)data_;
|
||||
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_;
|
||||
pixel = pixel + (y * _pixelsWide) + x;
|
||||
*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_;
|
||||
pixel = pixel + (y * _pixelsWide) + x;
|
||||
*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_;
|
||||
pixel = pixel + (y * _pixelsWide) + x;
|
||||
*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_;
|
||||
pixel[(y * _pixelsWide) + x] = c.a;
|
||||
} else {
|
||||
|
@ -264,19 +264,19 @@ void Texture2DMutable::apply()
|
|||
|
||||
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_);
|
||||
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_);
|
||||
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_);
|
||||
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_);
|
||||
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_);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -40,12 +40,12 @@ public:
|
|||
void releaseData(void *data);
|
||||
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);
|
||||
|
||||
/** 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);
|
||||
|
|
|
@ -42,7 +42,7 @@ GLESDebugDraw::GLESDebugDraw( float32 ratio )
|
|||
|
||||
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");
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ void GLESDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, con
|
|||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -118,7 +118,7 @@ void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Col
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
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);
|
||||
|
||||
|
||||
|
@ -178,7 +178,7 @@ void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Colo
|
|||
p1.x * mRatio, p1.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);
|
||||
|
||||
|
@ -211,7 +211,7 @@ void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& colo
|
|||
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);
|
||||
// glPointSize(1.0f);
|
||||
|
@ -242,7 +242,7 @@ void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color)
|
|||
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);
|
||||
|
||||
CC_INCREMENT_GL_DRAWS(1);
|
||||
|
|
|
@ -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) {
|
||||
if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) {
|
||||
((LabelTTF *)pNode)->setHorizontalAlignment(TextAlignment(pIntegerLabeled));
|
||||
((LabelTTF *)pNode)->setHorizontalAlignment(Label::TextAlignment(pIntegerLabeled));
|
||||
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) {
|
||||
((LabelTTF *)pNode)->setVerticalAlignment(VerticalTextAlignment(pIntegerLabeled));
|
||||
((LabelTTF *)pNode)->setVerticalAlignment(Label::VerticalTextAlignment(pIntegerLabeled));
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ InputDelegate::InputDelegate(void)
|
|||
, _accelerometerEnabled(false)
|
||||
, _keypadEnabled(false)
|
||||
, _touchPriority(0)
|
||||
, _touchMode(kTouchesAllAtOnce)
|
||||
, _touchMode(Layer::TOUCHES_ALL_AT_ONCE)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ void InputDelegate::setTouchEnabled(bool enabled)
|
|||
_touchEnabled = enabled;
|
||||
if (enabled)
|
||||
{
|
||||
if( _touchMode == kTouchesAllAtOnce )
|
||||
if( _touchMode == Layer::TOUCHES_ALL_AT_ONCE )
|
||||
{
|
||||
Director::getInstance()->getTouchDispatcher()->addStandardDelegate(this, 0);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ ControlPotentiometer* ControlPotentiometer::create(const char* backgroundFile, c
|
|||
|
||||
// Prepare progress for potentiometer
|
||||
ProgressTimer *progressTimer = ProgressTimer::create(Sprite::create(progressFile));
|
||||
//progressTimer.type = kProgressTimerTypeRadialCW;
|
||||
//progressTimer.type = ProgressTimer::RADIALCW;
|
||||
if (pRet->initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite))
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
|
|
@ -124,9 +124,9 @@ bool ControlSwitchSprite::initWithMaskSprite(
|
|||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
getShaderProgram()->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
getShaderProgram()->addAttribute(kAttributeNameColor, kVertexAttrib_Color);
|
||||
getShaderProgram()->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
getShaderProgram()->link();
|
||||
|
@ -157,7 +157,7 @@ void ControlSwitchSprite::draw()
|
|||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
||||
ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
||||
ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
getShaderProgram()->setUniformsForBuiltins();
|
||||
|
||||
|
@ -177,15 +177,15 @@ void ControlSwitchSprite::draw()
|
|||
|
||||
// vertex
|
||||
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
|
||||
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
|
||||
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);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ void CCSkeleton::initialize () {
|
|||
blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
setOpacityModifyRGB(true);
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -136,13 +136,13 @@ void SpriteProgressToRadial::onEnter()
|
|||
ProgressTo *to2 = ProgressTo::create(2, 100);
|
||||
|
||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1));
|
||||
left->setType( kProgressTimerTypeRadial );
|
||||
left->setType( ProgressTimer::RADIAL );
|
||||
addChild(left);
|
||||
left->setPosition(Point(100, s.height/2));
|
||||
left->runAction( RepeatForever::create(to1));
|
||||
|
||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
||||
right->setType(kProgressTimerTypeRadial);
|
||||
right->setType(ProgressTimer::RADIAL);
|
||||
// Makes the ridial CCW
|
||||
right->setReverseProgress(true);
|
||||
addChild(right);
|
||||
|
@ -171,7 +171,7 @@ void SpriteProgressToHorizontal::onEnter()
|
|||
ProgressTo *to2 = ProgressTo::create(2, 100);
|
||||
|
||||
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
|
||||
left->setMidpoint(Point(0,0));
|
||||
// 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));
|
||||
|
||||
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
|
||||
right->setMidpoint(Point(1, 0));
|
||||
// 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);
|
||||
|
||||
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
|
||||
left->setMidpoint(Point(0,0));
|
||||
|
@ -222,7 +222,7 @@ void SpriteProgressToVertical::onEnter()
|
|||
left->runAction( RepeatForever::create(to1));
|
||||
|
||||
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
|
||||
right->setMidpoint(Point(0, 1));
|
||||
// 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
|
||||
*/
|
||||
ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock));
|
||||
left->setType(kProgressTimerTypeRadial);
|
||||
left->setType(ProgressTimer::RADIAL);
|
||||
addChild(left);
|
||||
left->setMidpoint(Point(0.25f, 0.75f));
|
||||
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
|
||||
*/
|
||||
ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock));
|
||||
right->setType(kProgressTimerTypeRadial);
|
||||
right->setType(ProgressTimer::RADIAL);
|
||||
right->setMidpoint(Point(0.75f, 0.25f));
|
||||
|
||||
/**
|
||||
|
@ -295,7 +295,7 @@ void SpriteProgressBarVarious::onEnter()
|
|||
ProgressTo *to = ProgressTo::create(2, 100);
|
||||
|
||||
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
|
||||
left->setMidpoint(Point(0.5f, 0.5f));
|
||||
|
@ -306,7 +306,7 @@ void SpriteProgressBarVarious::onEnter()
|
|||
left->runAction(RepeatForever::create(to->clone()));
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -316,7 +316,7 @@ void SpriteProgressBarVarious::onEnter()
|
|||
middle->runAction(RepeatForever::create(to->clone()));
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -352,7 +352,7 @@ void SpriteProgressBarTintAndFade::onEnter()
|
|||
NULL);
|
||||
|
||||
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
|
||||
left->setMidpoint(Point(0.5f, 0.5f));
|
||||
|
@ -366,7 +366,7 @@ void SpriteProgressBarTintAndFade::onEnter()
|
|||
left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f));
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -379,7 +379,7 @@ void SpriteProgressBarTintAndFade::onEnter()
|
|||
middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f));
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -414,7 +414,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
|
|||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -424,7 +424,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
|
|||
left->runAction(RepeatForever::create(to->clone()));
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -434,7 +434,7 @@ void SpriteProgressWithSpriteFrame::onEnter()
|
|||
middle->runAction(RepeatForever::create(to->clone()));
|
||||
|
||||
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
|
||||
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
|
||||
|
|
|
@ -141,7 +141,7 @@ void Box2DTestLayer::draw()
|
|||
Layer::draw();
|
||||
|
||||
#if CC_ENABLE_BOX2D_INTEGRATION
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
kmGLPushMatrix();
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ void Box2DView::draw()
|
|||
{
|
||||
Layer::draw();
|
||||
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
kmGLPushMatrix();
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ GLESDebugDraw::GLESDebugDraw( float32 ratio )
|
|||
|
||||
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");
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ void GLESDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, con
|
|||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -116,7 +116,7 @@ void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Col
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
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);
|
||||
|
||||
|
||||
|
@ -176,7 +176,7 @@ void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Colo
|
|||
p1.x * mRatio, p1.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);
|
||||
|
||||
|
@ -209,7 +209,7 @@ void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& colo
|
|||
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);
|
||||
// glPointSize(1.0f);
|
||||
|
@ -240,7 +240,7 @@ void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color)
|
|||
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);
|
||||
|
||||
CC_INCREMENT_GL_DRAWS(1);
|
||||
|
|
|
@ -723,8 +723,8 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane)
|
|||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
||||
#else
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue);
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
||||
_sprite->setShaderProgram(program );
|
||||
#endif
|
||||
|
@ -756,8 +756,8 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane)
|
|||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
||||
#else
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue);
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
||||
_sprite->setShaderProgram( program );
|
||||
#endif
|
||||
|
@ -821,8 +821,8 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane)
|
|||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, _alphaThreshold);
|
||||
#else
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue);
|
||||
GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
|
||||
GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
|
||||
program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
|
||||
_sprite->setShaderProgram(program);
|
||||
#endif
|
||||
|
|
|
@ -215,7 +215,7 @@ void Effect5::onExit()
|
|||
{
|
||||
EffectAdvanceTextLayer::onExit();
|
||||
|
||||
Director::getInstance()->setProjection(kDirectorProjection3D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_3D);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
|
|
@ -154,7 +154,7 @@ void ArmatureTestLayer::onEnter()
|
|||
|
||||
addChild(menu, 100);
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
||||
}
|
||||
void ArmatureTestLayer::onExit()
|
||||
|
@ -539,7 +539,7 @@ std::string TestBox2DDetector::title()
|
|||
}
|
||||
void TestBox2DDetector::draw()
|
||||
{
|
||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||
ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION );
|
||||
|
||||
kmGLPushMatrix();
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ SocketIOTestLayer::SocketIOTestLayer(void)
|
|||
menuRequest->addChild(itemTestEndpointDisconnect);
|
||||
|
||||
// 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->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y));
|
||||
this->addChild(_sioClientStatus);
|
||||
|
|
|
@ -49,19 +49,19 @@ WebSocketTestLayer::WebSocketTestLayer()
|
|||
|
||||
|
||||
// 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->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y + 25));
|
||||
this->addChild(_sendTextStatus);
|
||||
|
||||
// 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->setPosition(Point(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25));
|
||||
this->addChild(_sendBinaryStatus);
|
||||
|
||||
// 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->setPosition(Point(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25));
|
||||
this->addChild(_errorStatus);
|
||||
|
|
|
@ -39,11 +39,11 @@ static std::string fontList[] =
|
|||
static int fontCount = sizeof(fontList) / sizeof(*fontList);
|
||||
|
||||
static int vAlignIdx = 0;
|
||||
static VerticalTextAlignment verticalAlignment[] =
|
||||
static Label::VerticalTextAlignment verticalAlignment[] =
|
||||
{
|
||||
kVerticalTextAlignmentTop,
|
||||
kVerticalTextAlignmentCenter,
|
||||
kVerticalTextAlignmentBottom,
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_TOP,
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_CENTER,
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM,
|
||||
};
|
||||
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 *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,
|
||||
blockSize, kTextAlignmentCenter, verticalAlignment[vAlignIdx]);
|
||||
blockSize, Label::TEXT_ALIGNMENT_CENTER, verticalAlignment[vAlignIdx]);
|
||||
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 *centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);
|
||||
|
|
|
@ -348,19 +348,19 @@ LabelTTFAlignment::LabelTTFAlignment()
|
|||
Size s = Director::getInstance()->getWinSize();
|
||||
|
||||
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->setAnchorPoint(Point(0.5f,0.5f));
|
||||
this->addChild(ttf0);
|
||||
|
||||
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->setAnchorPoint(Point(0.5f,0.5f));
|
||||
this->addChild(ttf1);
|
||||
|
||||
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->setAnchorPoint(Point(0.5f,0.5f));
|
||||
this->addChild(ttf2);
|
||||
|
@ -953,8 +953,8 @@ LabelTTFTest::LabelTTFTest()
|
|||
this->addChild(menu);
|
||||
|
||||
_plabel = NULL;
|
||||
_horizAlign = kTextAlignmentLeft;
|
||||
_vertAlign = kVerticalTextAlignmentTop;
|
||||
_horizAlign = Label::TEXT_ALIGNMENT_LEFT;
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
|
||||
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
@ -988,37 +988,37 @@ void LabelTTFTest::updateAlignment()
|
|||
|
||||
void LabelTTFTest::setAlignmentLeft(Object* pSender)
|
||||
{
|
||||
_horizAlign = kTextAlignmentLeft;
|
||||
_horizAlign = Label::TEXT_ALIGNMENT_LEFT;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentCenter(Object* pSender)
|
||||
{
|
||||
_horizAlign = kTextAlignmentCenter;
|
||||
_horizAlign = Label::TEXT_ALIGNMENT_CENTER;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentRight(Object* pSender)
|
||||
{
|
||||
_horizAlign = kTextAlignmentRight;
|
||||
_horizAlign = Label::TEXT_ALIGNMENT_RIGHT;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentTop(Object* pSender)
|
||||
{
|
||||
_vertAlign = kVerticalTextAlignmentTop;
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentMiddle(Object* pSender)
|
||||
{
|
||||
_vertAlign = kVerticalTextAlignmentCenter;
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_CENTER;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentBottom(Object* pSender)
|
||||
{
|
||||
_vertAlign = kVerticalTextAlignmentBottom;
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
|
@ -1027,24 +1027,24 @@ const char* LabelTTFTest::getCurrentAlignment()
|
|||
const char* vertical = NULL;
|
||||
const char* horizontal = NULL;
|
||||
switch (_vertAlign) {
|
||||
case kVerticalTextAlignmentTop:
|
||||
case Label::VERTICAL_TEXT_ALIGNMENT_TOP:
|
||||
vertical = "Top";
|
||||
break;
|
||||
case kVerticalTextAlignmentCenter:
|
||||
case Label::VERTICAL_TEXT_ALIGNMENT_CENTER:
|
||||
vertical = "Middle";
|
||||
break;
|
||||
case kVerticalTextAlignmentBottom:
|
||||
case Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM:
|
||||
vertical = "Bottom";
|
||||
break;
|
||||
}
|
||||
switch (_horizAlign) {
|
||||
case kTextAlignmentLeft:
|
||||
case Label::TEXT_ALIGNMENT_LEFT:
|
||||
horizontal = "Left";
|
||||
break;
|
||||
case kTextAlignmentCenter:
|
||||
case Label::TEXT_ALIGNMENT_CENTER:
|
||||
horizontal = "Center";
|
||||
break;
|
||||
case kTextAlignmentRight:
|
||||
case Label::TEXT_ALIGNMENT_RIGHT:
|
||||
horizontal = "Right";
|
||||
break;
|
||||
}
|
||||
|
@ -1070,8 +1070,8 @@ LabelTTFMultiline::LabelTTFMultiline()
|
|||
"Paint Boy",
|
||||
32,
|
||||
Size(s.width/2,200),
|
||||
kTextAlignmentCenter,
|
||||
kVerticalTextAlignmentTop);
|
||||
Label::TEXT_ALIGNMENT_CENTER,
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
|
||||
center->setPosition(Point(s.width / 2, 150));
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
|
|||
Size size = Director::getInstance()->getWinSize();
|
||||
|
||||
// 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->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png");
|
||||
|
@ -1250,13 +1250,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender)
|
|||
switch(item->getTag())
|
||||
{
|
||||
case LeftAlign:
|
||||
this->_labelShouldRetain->setAlignment(kTextAlignmentLeft);
|
||||
this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_LEFT);
|
||||
break;
|
||||
case CenterAlign:
|
||||
this->_labelShouldRetain->setAlignment(kTextAlignmentCenter);
|
||||
this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_CENTER);
|
||||
break;
|
||||
case RightAlign:
|
||||
this->_labelShouldRetain->setAlignment(kTextAlignmentRight);
|
||||
this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_RIGHT);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1348,11 +1348,11 @@ BMFontOneAtlas::BMFontOneAtlas()
|
|||
{
|
||||
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);
|
||||
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);
|
||||
label2->setPosition(Point(s.width/2, s.height/3*1));
|
||||
}
|
||||
|
@ -1379,7 +1379,7 @@ BMFontUnicode::BMFontUnicode()
|
|||
|
||||
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);
|
||||
label1->setPosition(Point(s.width/2, s.height/5*4));
|
||||
|
||||
|
|
|
@ -191,8 +191,8 @@ private:
|
|||
const char* getCurrentAlignment();
|
||||
private:
|
||||
LabelTTF* _plabel;
|
||||
TextAlignment _horizAlign;
|
||||
VerticalTextAlignment _vertAlign;
|
||||
Label::TextAlignment _horizAlign;
|
||||
Label::VerticalTextAlignment _vertAlign;
|
||||
};
|
||||
|
||||
class LabelTTFMultiline : public AtlasDemo
|
||||
|
|
|
@ -26,8 +26,8 @@ enum {
|
|||
MenuLayerMainMenu::MenuLayerMainMenu()
|
||||
{
|
||||
setTouchEnabled(true);
|
||||
setTouchPriority(kMenuHandlerPriority + 1);
|
||||
setTouchMode(kTouchesOneByOne);
|
||||
setTouchPriority(Menu::HANDLER_PRIORITY + 1);
|
||||
setTouchMode(Layer::TOUCHES_ONE_BY_ONE);
|
||||
|
||||
// Font Item
|
||||
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)
|
||||
{
|
||||
Director* director = Director::getInstance();
|
||||
director->getTouchDispatcher()->setPriority(kMenuHandlerPriority+1, this);
|
||||
director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY+1, this);
|
||||
unscheduleAllSelectors();
|
||||
log("TOUCHES ALLOWED AGAIN");
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void MenuLayerMainMenu::menuCallbackDisabled(Object* sender)
|
|||
{
|
||||
// hijack all touch events for 5 seconds
|
||||
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);
|
||||
log("TOUCHES DISABLED FOR 5 SECONDS");
|
||||
}
|
||||
|
@ -491,10 +491,10 @@ MenuLayerPriorityTest::MenuLayerPriorityTest()
|
|||
MenuItemFont::setFontSize(48);
|
||||
item1 = MenuItemFont::create("Toggle priority", [&](Object *sender) {
|
||||
if( _priority) {
|
||||
_menu2->setHandlerPriority(kMenuHandlerPriority + 20);
|
||||
_menu2->setHandlerPriority(Menu::HANDLER_PRIORITY + 20);
|
||||
_priority = false;
|
||||
} else {
|
||||
_menu2->setHandlerPriority(kMenuHandlerPriority - 20);
|
||||
_menu2->setHandlerPriority(Menu::HANDLER_PRIORITY - 20);
|
||||
_priority = true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ class TouchPoint : public Node
|
|||
public:
|
||||
TouchPoint()
|
||||
{
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
}
|
||||
|
||||
virtual void draw()
|
||||
|
|
|
@ -512,12 +512,12 @@ std::string NodeToWorld::title()
|
|||
void CameraOrbitTest::onEnter()
|
||||
{
|
||||
TestCocosNodeDemo::onEnter();
|
||||
Director::getInstance()->setProjection(kDirectorProjection3D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_3D);
|
||||
}
|
||||
|
||||
void CameraOrbitTest::onExit()
|
||||
{
|
||||
Director::getInstance()->setProjection(kDirectorProjection2D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
TestCocosNodeDemo::onExit();
|
||||
}
|
||||
|
||||
|
@ -584,12 +584,12 @@ void CameraZoomTest::onEnter()
|
|||
{
|
||||
TestCocosNodeDemo::onEnter();
|
||||
|
||||
Director::getInstance()->setProjection(kDirectorProjection3D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_3D);
|
||||
}
|
||||
|
||||
void CameraZoomTest::onExit()
|
||||
{
|
||||
Director::getInstance()->setProjection(kDirectorProjection2D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
TestCocosNodeDemo::onExit();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#include "ParticleTest.h"
|
||||
// #include "CCActionInterval.h"
|
||||
// #include "CCMenu.h"
|
||||
// #include "CCLabelTTF.h"
|
||||
// #include "CCLabelAtlas.h"
|
||||
// #include "touch_dispatcher/CCTouchDispatcher.h"
|
||||
#include "../testResource.h"
|
||||
/*#include "support/CCPointExtension.h"*/
|
||||
|
||||
enum {
|
||||
kTagParticleCount = 1,
|
||||
|
@ -200,7 +194,7 @@ void DemoBigFlower::onEnter()
|
|||
// size, in pixels
|
||||
_emitter->setStartSize(80.0f);
|
||||
_emitter->setStartSizeVar(40.0f);
|
||||
_emitter->setEndSize(kParticleStartSizeEqualToEndSize);
|
||||
_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
|
||||
|
||||
// emits per second
|
||||
_emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());
|
||||
|
@ -285,7 +279,7 @@ void DemoRotFlower::onEnter()
|
|||
// size, in pixels
|
||||
_emitter->setStartSize(30.0f);
|
||||
_emitter->setStartSizeVar(00.0f);
|
||||
_emitter->setEndSize(kParticleStartSizeEqualToEndSize);
|
||||
_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
|
||||
|
||||
// emits per second
|
||||
_emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife());
|
||||
|
@ -650,10 +644,10 @@ void RadiusMode1::onEnter()
|
|||
_emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png"));
|
||||
|
||||
// duration
|
||||
_emitter->setDuration(kParticleDurationInfinity);
|
||||
_emitter->setDuration(ParticleSystem::DURATION_INFINITY);
|
||||
|
||||
// radius mode
|
||||
_emitter->setEmitterMode(kParticleModeRadius);
|
||||
_emitter->setEmitterMode(ParticleSystem::MODE_RADIUS);
|
||||
|
||||
// radius mode: start and end radius in pixels
|
||||
_emitter->setStartRadius(0);
|
||||
|
@ -701,7 +695,7 @@ void RadiusMode1::onEnter()
|
|||
// size, in pixels
|
||||
_emitter->setStartSize(32);
|
||||
_emitter->setStartSizeVar(0);
|
||||
_emitter->setEndSize(kParticleStartSizeEqualToEndSize);
|
||||
_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
|
||||
|
||||
// emits per second
|
||||
_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());
|
||||
|
@ -734,15 +728,15 @@ void RadiusMode2::onEnter()
|
|||
_emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png"));
|
||||
|
||||
// duration
|
||||
_emitter->setDuration(kParticleDurationInfinity);
|
||||
_emitter->setDuration(ParticleSystem::DURATION_INFINITY);
|
||||
|
||||
// radius mode
|
||||
_emitter->setEmitterMode(kParticleModeRadius);
|
||||
_emitter->setEmitterMode(ParticleSystem::MODE_RADIUS);
|
||||
|
||||
// radius mode: start and end radius in pixels
|
||||
_emitter->setStartRadius(100);
|
||||
_emitter->setStartRadiusVar(0);
|
||||
_emitter->setEndRadius(kParticleStartRadiusEqualToEndRadius);
|
||||
_emitter->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
|
||||
_emitter->setEndRadiusVar(0);
|
||||
|
||||
// radius mode: degrees per second
|
||||
|
@ -785,7 +779,7 @@ void RadiusMode2::onEnter()
|
|||
// size, in pixels
|
||||
_emitter->setStartSize(32);
|
||||
_emitter->setStartSizeVar(0);
|
||||
_emitter->setEndSize(kParticleStartSizeEqualToEndSize);
|
||||
_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
|
||||
|
||||
// emits per second
|
||||
_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());
|
||||
|
@ -818,15 +812,15 @@ void Issue704::onEnter()
|
|||
_emitter->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
|
||||
// duration
|
||||
_emitter->setDuration(kParticleDurationInfinity);
|
||||
_emitter->setDuration(ParticleSystem::DURATION_INFINITY);
|
||||
|
||||
// radius mode
|
||||
_emitter->setEmitterMode(kParticleModeRadius);
|
||||
_emitter->setEmitterMode(ParticleSystem::MODE_RADIUS);
|
||||
|
||||
// radius mode: start and end radius in pixels
|
||||
_emitter->setStartRadius(50);
|
||||
_emitter->setStartRadiusVar(0);
|
||||
_emitter->setEndRadius(kParticleStartRadiusEqualToEndRadius);
|
||||
_emitter->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
|
||||
_emitter->setEndRadiusVar(0);
|
||||
|
||||
// radius mode: degrees per second
|
||||
|
@ -869,7 +863,7 @@ void Issue704::onEnter()
|
|||
// size, in pixels
|
||||
_emitter->setStartSize(16);
|
||||
_emitter->setStartSizeVar(0);
|
||||
_emitter->setEndSize(kParticleStartSizeEqualToEndSize);
|
||||
_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
|
||||
|
||||
// emits per second
|
||||
_emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife());
|
||||
|
@ -1163,12 +1157,12 @@ void ParticleDemo::toggleCallback(Object* pSender)
|
|||
{
|
||||
if (_emitter != NULL)
|
||||
{
|
||||
if( _emitter->getPositionType() == kPositionTypeGrouped )
|
||||
_emitter->setPositionType( kPositionTypeFree );
|
||||
else if (_emitter->getPositionType() == kPositionTypeFree)
|
||||
_emitter->setPositionType(kPositionTypeRelative);
|
||||
else if (_emitter->getPositionType() == kPositionTypeRelative)
|
||||
_emitter->setPositionType( kPositionTypeGrouped );
|
||||
if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_GROUPED)
|
||||
_emitter->setPositionType(ParticleSystem::POSITION_TYPE_FREE);
|
||||
else if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_FREE)
|
||||
_emitter->setPositionType(ParticleSystem::POSITION_TYPE_RELATIVE);
|
||||
else if (_emitter->getPositionType() == ParticleSystem::POSITION_TYPE_RELATIVE)
|
||||
_emitter->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1403,10 +1397,10 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
setBlendAdditive(false);
|
||||
|
||||
// duration
|
||||
setDuration(kParticleDurationInfinity);
|
||||
setDuration(ParticleSystem::DURATION_INFINITY);
|
||||
|
||||
// Gravity Mode
|
||||
setEmitterMode(kParticleModeGravity);
|
||||
setEmitterMode(ParticleSystem::MODE_GRAVITY);
|
||||
|
||||
// Gravity Mode: gravity
|
||||
setGravity(Point(0,0));
|
||||
|
@ -1436,7 +1430,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles)
|
|||
// size, in pixels
|
||||
setStartSize(25.0f);
|
||||
setStartSizeVar(0);
|
||||
setEndSize(kParticleStartSizeEqualToEndSize);
|
||||
setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
|
||||
|
||||
// emits per seconds
|
||||
setEmissionRate(getTotalParticles()/getLife());
|
||||
|
@ -1513,7 +1507,7 @@ void MultipleParticleSystems::onEnter()
|
|||
|
||||
particleSystem->setPosition(Point(i*50 ,i*50));
|
||||
|
||||
particleSystem->setPositionType(kPositionTypeGrouped);
|
||||
particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
|
||||
addChild(particleSystem);
|
||||
}
|
||||
|
||||
|
@ -1570,7 +1564,7 @@ void MultipleParticleSystemsBatched::onEnter()
|
|||
|
||||
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist");
|
||||
|
||||
particleSystem->setPositionType(kPositionTypeGrouped);
|
||||
particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
|
||||
particleSystem->setPosition(Point(i*50 ,i*50));
|
||||
|
||||
batchNode->setTexture(particleSystem->getTexture());
|
||||
|
@ -1633,7 +1627,7 @@ void AddAndDeleteParticleSystems::onEnter()
|
|||
ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist");
|
||||
_batchNode->setTexture(particleSystem->getTexture());
|
||||
|
||||
particleSystem->setPositionType(kPositionTypeGrouped);
|
||||
particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
|
||||
particleSystem->setTotalParticles(200);
|
||||
|
||||
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");
|
||||
//add new
|
||||
|
||||
particleSystem->setPositionType(kPositionTypeGrouped);
|
||||
particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_GROUPED);
|
||||
particleSystem->setTotalParticles(200);
|
||||
|
||||
particleSystem->setPosition(Point(rand() % 300 ,rand() % 400));
|
||||
|
@ -1724,15 +1718,15 @@ void ReorderParticleSystems::onEnter()
|
|||
particleSystem->setTexture(_batchNode->getTexture());
|
||||
|
||||
// duration
|
||||
particleSystem->setDuration(kParticleDurationInfinity);
|
||||
particleSystem->setDuration(ParticleSystem::DURATION_INFINITY);
|
||||
|
||||
// radius mode
|
||||
particleSystem->setEmitterMode(kParticleModeRadius);
|
||||
particleSystem->setEmitterMode(ParticleSystem::MODE_RADIUS);
|
||||
|
||||
// radius mode: 100 pixels from center
|
||||
particleSystem->setStartRadius(100);
|
||||
particleSystem->setStartRadiusVar(0);
|
||||
particleSystem->setEndRadius(kParticleStartRadiusEqualToEndRadius);
|
||||
particleSystem->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS);
|
||||
particleSystem->setEndRadiusVar(0); // not used when start == end
|
||||
|
||||
// radius mode: degrees per second
|
||||
|
@ -1776,7 +1770,7 @@ void ReorderParticleSystems::onEnter()
|
|||
// size, in pixels
|
||||
particleSystem->setStartSize(32);
|
||||
particleSystem->setStartSizeVar(0);
|
||||
particleSystem->setEndSize(kParticleStartSizeEqualToEndSize);
|
||||
particleSystem->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);
|
||||
|
||||
// emits per second
|
||||
particleSystem->setEmissionRate(particleSystem->getTotalParticles()/particleSystem->getLife());
|
||||
|
@ -1787,7 +1781,7 @@ void ReorderParticleSystems::onEnter()
|
|||
|
||||
|
||||
_batchNode->addChild(particleSystem);
|
||||
particleSystem->setPositionType(kPositionTypeFree);
|
||||
particleSystem->setPositionType(ParticleSystem::POSITION_TYPE_FREE);
|
||||
|
||||
particleSystem->release();
|
||||
|
||||
|
|
|
@ -202,17 +202,17 @@ void ParticleMainScene::createParticleSystem()
|
|||
switch( subtestNumber)
|
||||
{
|
||||
case 1:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 2:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 3:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
|
@ -222,17 +222,17 @@ void ParticleMainScene::createParticleSystem()
|
|||
// particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
// break;
|
||||
case 4:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 5:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 6:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
|
@ -252,7 +252,7 @@ void ParticleMainScene::createParticleSystem()
|
|||
doTest();
|
||||
|
||||
// restore the default pixel format
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
}
|
||||
|
||||
void ParticleMainScene::testNCallback(Object* pSender)
|
||||
|
|
|
@ -67,36 +67,36 @@ void SubTest::initWithSubTest(int nSubTest, Node* p)
|
|||
break;
|
||||
///
|
||||
case 2:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
case 3:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
|
||||
///
|
||||
case 5:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
case 6:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
|
||||
///
|
||||
case 8:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
case 9:
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
|
@ -110,13 +110,13 @@ void SubTest::initWithSubTest(int nSubTest, Node* p)
|
|||
batchNode->retain();
|
||||
}
|
||||
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT);
|
||||
}
|
||||
|
||||
Sprite* SubTest::createSpriteWithTag(int tag)
|
||||
{
|
||||
// create
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
|
||||
Sprite* sprite = NULL;
|
||||
switch (subtestNumber)
|
||||
|
@ -194,7 +194,7 @@ Sprite* SubTest::createSpriteWithTag(int tag)
|
|||
break;
|
||||
}
|
||||
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT);
|
||||
|
||||
return sprite;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void TextureTest::performTestsPNG(const char* filename)
|
|||
TextureCache *cache = TextureCache::getInstance();
|
||||
|
||||
log("RGBA 8888");
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
gettimeofday(&now, NULL);
|
||||
texture = cache->addImage(filename);
|
||||
if( texture )
|
||||
|
@ -97,7 +97,7 @@ void TextureTest::performTestsPNG(const char* filename)
|
|||
cache->removeTexture(texture);
|
||||
|
||||
log("RGBA 4444");
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
gettimeofday(&now, NULL);
|
||||
texture = cache->addImage(filename);
|
||||
if( texture )
|
||||
|
@ -107,7 +107,7 @@ void TextureTest::performTestsPNG(const char* filename)
|
|||
cache->removeTexture(texture);
|
||||
|
||||
log("RGBA 5551");
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB5A1);
|
||||
gettimeofday(&now, NULL);
|
||||
texture = cache->addImage(filename);
|
||||
if( texture )
|
||||
|
@ -117,7 +117,7 @@ void TextureTest::performTestsPNG(const char* filename)
|
|||
cache->removeTexture(texture);
|
||||
|
||||
log("RGB 565");
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB565);
|
||||
gettimeofday(&now, NULL);
|
||||
texture = cache->addImage(filename);
|
||||
if( texture )
|
||||
|
|
|
@ -98,7 +98,7 @@ RenderTextureSave::RenderTextureSave()
|
|||
Size s = Director::getInstance()->getWinSize();
|
||||
|
||||
// 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->setPosition(Point(s.width / 2, s.height / 2));
|
||||
|
||||
|
@ -147,8 +147,8 @@ void RenderTextureSave::saveImage(cocos2d::Object *pSender)
|
|||
char jpg[20];
|
||||
sprintf(jpg, "image-%d.jpg", counter);
|
||||
|
||||
_target->saveToFile(png, kImageFormatPNG);
|
||||
_target->saveToFile(jpg, kImageFormatJPEG);
|
||||
_target->saveToFile(png, Image::FORMAT_PNG);
|
||||
_target->saveToFile(jpg, Image::FORMAT_JPG);
|
||||
|
||||
|
||||
Image *pImage = _target->newImage();
|
||||
|
@ -243,7 +243,7 @@ RenderTextureIssue937::RenderTextureIssue937()
|
|||
|
||||
|
||||
/* A2 & B2 setup */
|
||||
RenderTexture *rend = RenderTexture::create(32, 64, kTexture2DPixelFormat_RGBA8888);
|
||||
RenderTexture *rend = RenderTexture::create(32, 64, Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
|
||||
if (NULL == rend)
|
||||
{
|
||||
|
@ -441,7 +441,7 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil()
|
|||
Sprite *sprite = Sprite::create("Images/fire.png");
|
||||
sprite->setPosition(Point(s.width * 0.25f, 0));
|
||||
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);
|
||||
rend->beginWithClear(0, 0, 0, 0, 0, 0);
|
||||
|
@ -505,7 +505,7 @@ RenderTextureTargetNode::RenderTextureTargetNode()
|
|||
Size s = Director::getInstance()->getWinSize();
|
||||
|
||||
/* 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;
|
||||
|
||||
renderTexture->setPosition(Point(s.width/2, s.height/2));
|
||||
|
@ -591,7 +591,7 @@ void SpriteRenderTextureBug::SimpleSprite::draw()
|
|||
{
|
||||
Size s = Director::getInstance()->getWinSize();
|
||||
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->end();
|
||||
|
@ -607,22 +607,22 @@ void SpriteRenderTextureBug::SimpleSprite::draw()
|
|||
// Attributes
|
||||
//
|
||||
|
||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
||||
ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
||||
|
||||
#define kQuadSize sizeof(_quad.bl)
|
||||
long offset = (long)&_quad;
|
||||
|
||||
// vertex
|
||||
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
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -359,7 +359,7 @@ void SchedulerPauseResumeAllUser::pause(float dt)
|
|||
{
|
||||
log("Pausing");
|
||||
Director* director = Director::getInstance();
|
||||
_pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(kPriorityNonSystemMin);
|
||||
_pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN);
|
||||
CC_SAFE_RETAIN(_pausedTargets);
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ void SchedulerUnscheduleAllHard::onExit()
|
|||
if(!_actionManagerActive) {
|
||||
// Restore the director's action manager.
|
||||
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)
|
||||
{
|
||||
Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(kPriorityNonSystemMin);
|
||||
Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN);
|
||||
}
|
||||
|
||||
std::string SchedulerUnscheduleAllUserLevel::title()
|
||||
|
|
|
@ -166,7 +166,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag)
|
|||
GLProgram *shader = new GLProgram();
|
||||
shader->initWithVertexShaderFilename(vert, frag);
|
||||
|
||||
shader->addAttribute("aVertex", kVertexAttrib_Position);
|
||||
shader->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
shader->link();
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
|
@ -499,9 +499,9 @@ void SpriteBlur::initProgram()
|
|||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
getShaderProgram()->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
getShaderProgram()->addAttribute(kAttributeNameColor, kVertexAttrib_Color);
|
||||
getShaderProgram()->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
|
@ -521,7 +521,7 @@ void SpriteBlur::initProgram()
|
|||
|
||||
void SpriteBlur::draw()
|
||||
{
|
||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex );
|
||||
ccGLEnableVertexAttribs(VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
|
||||
BlendFunc blend = getBlendFunc();
|
||||
ccGLBlendFunc(blend.src, blend.dst);
|
||||
|
||||
|
@ -540,15 +540,15 @@ void SpriteBlur::draw()
|
|||
|
||||
// vertex
|
||||
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
|
||||
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
|
||||
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);
|
||||
|
@ -646,8 +646,8 @@ bool ShaderRetroEffect::init()
|
|||
GLProgram *p = new GLProgram();
|
||||
p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
p->link();
|
||||
p->updateUniforms();
|
||||
|
@ -740,8 +740,8 @@ ShaderFail::ShaderFail()
|
|||
GLProgram *p = new GLProgram();
|
||||
p->initWithVertexShaderByteArray(ccPositionTexture_vert, shader_frag_fail);
|
||||
|
||||
p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position);
|
||||
p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
||||
|
||||
p->link();
|
||||
p->updateUniforms();
|
||||
|
|
|
@ -1 +1 @@
|
|||
715f77e7fdc777c303783dad8b6ce3e1b19526d7
|
||||
4b0a077e077119ecd733b35f41231c3b6668d2f7
|
|
@ -1313,7 +1313,7 @@ void TexturePixelFormat::onEnter()
|
|||
addChild(background, -1);
|
||||
|
||||
// RGBA 8888 image (32-bit)
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Sprite *sprite1 = Sprite::create("Images/test-rgba1.png");
|
||||
sprite1->setPosition(Point(1*s.width/7, s.height/2+32));
|
||||
addChild(sprite1, 0);
|
||||
|
@ -1322,7 +1322,7 @@ void TexturePixelFormat::onEnter()
|
|||
TextureCache::getInstance()->removeTexture(sprite1->getTexture());
|
||||
|
||||
// RGBA 4444 image (16-bit)
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Sprite *sprite2 = Sprite::create("Images/test-rgba1.png");
|
||||
sprite2->setPosition(Point(2*s.width/7, s.height/2-32));
|
||||
addChild(sprite2, 0);
|
||||
|
@ -1331,7 +1331,7 @@ void TexturePixelFormat::onEnter()
|
|||
TextureCache::getInstance()->removeTexture(sprite2->getTexture());
|
||||
|
||||
// RGB5A1 image (16-bit)
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB5A1);
|
||||
Sprite *sprite3 = Sprite::create("Images/test-rgba1.png");
|
||||
sprite3->setPosition(Point(3*s.width/7, s.height/2+32));
|
||||
addChild(sprite3, 0);
|
||||
|
@ -1340,7 +1340,7 @@ void TexturePixelFormat::onEnter()
|
|||
TextureCache::getInstance()->removeTexture(sprite3->getTexture());
|
||||
|
||||
// RGB888 image
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB888);
|
||||
Sprite *sprite4 = Sprite::create("Images/test-rgba1.png");
|
||||
sprite4->setPosition(Point(4*s.width/7, s.height/2-32));
|
||||
addChild(sprite4, 0);
|
||||
|
@ -1349,7 +1349,7 @@ void TexturePixelFormat::onEnter()
|
|||
TextureCache::getInstance()->removeTexture(sprite4->getTexture());
|
||||
|
||||
// RGB565 image (16-bit)
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB565);
|
||||
Sprite *sprite5 = Sprite::create("Images/test-rgba1.png");
|
||||
sprite5->setPosition(Point(5*s.width/7, s.height/2+32));
|
||||
addChild(sprite5, 0);
|
||||
|
@ -1358,7 +1358,7 @@ void TexturePixelFormat::onEnter()
|
|||
TextureCache::getInstance()->removeTexture(sprite5->getTexture());
|
||||
|
||||
// A8 image (8-bit)
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
|
||||
Sprite *sprite6 = Sprite::create("Images/test-rgba1.png");
|
||||
sprite6->setPosition(Point(6*s.width/7, s.height/2-32));
|
||||
addChild(sprite6, 0);
|
||||
|
@ -1382,7 +1382,7 @@ void TexturePixelFormat::onEnter()
|
|||
sprite5->runAction(seq_4ever5);
|
||||
|
||||
// restore default
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT);
|
||||
TextureCache::getInstance()->dumpCachedTextureInfo();
|
||||
}
|
||||
|
||||
|
@ -1937,7 +1937,7 @@ TexturePVRv3Premult::TexturePVRv3Premult()
|
|||
transformSprite(pvr2);
|
||||
|
||||
// PNG
|
||||
Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
TextureCache::getInstance()->removeTextureForKey("Images/grossinis_sister1-testalpha.png");
|
||||
Sprite *png = Sprite::create("Images/grossinis_sister1-testalpha.png");
|
||||
addChild(png, 0);
|
||||
|
|
|
@ -150,12 +150,12 @@ void TMXOrthoTest::onEnter()
|
|||
{
|
||||
TileDemo::onEnter();
|
||||
|
||||
Director::getInstance()->setProjection(kDirectorProjection3D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_3D);
|
||||
}
|
||||
|
||||
void TMXOrthoTest::onExit()
|
||||
{
|
||||
Director::getInstance()->setProjection(kDirectorProjection2D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
TileDemo::onExit();
|
||||
}
|
||||
|
||||
|
@ -973,13 +973,13 @@ void TMXIsoVertexZ::onEnter()
|
|||
TileDemo::onEnter();
|
||||
|
||||
// TIP: 2d projection should be used
|
||||
Director::getInstance()->setProjection(kDirectorProjection2D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
}
|
||||
|
||||
void TMXIsoVertexZ::onExit()
|
||||
{
|
||||
// At exit use any other projection.
|
||||
// Director::getInstance()->setProjection:kDirectorProjection3D);
|
||||
// Director::getInstance()->setProjection:Director::PROJECTION_3D);
|
||||
TileDemo::onExit();
|
||||
}
|
||||
|
||||
|
@ -1042,13 +1042,13 @@ void TMXOrthoVertexZ::onEnter()
|
|||
TileDemo::onEnter();
|
||||
|
||||
// TIP: 2d projection should be used
|
||||
Director::getInstance()->setProjection(kDirectorProjection2D);
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
}
|
||||
|
||||
void TMXOrthoVertexZ::onExit()
|
||||
{
|
||||
// At exit use any other projection.
|
||||
// Director::getInstance()->setProjection:kDirectorProjection3D);
|
||||
// Director::getInstance()->setProjection:Director::PROJECTION_3D);
|
||||
TileDemo::onExit();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class FlipXLeftOver : public TransitionFlipX
|
|||
public:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
static TransitionScene* create(float t, Scene* s)
|
||||
{
|
||||
return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationRightOver);
|
||||
return TransitionZoomFlipAngular::create(t, s, TransitionScene::ORIENTATION_RIGHT_OVER);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// initialize director
|
||||
Director *pDirector = Director::getInstance();
|
||||
pDirector->setOpenGLView(EGLView::getInstance());
|
||||
pDirector->setProjection(kDirectorProjection2D);
|
||||
pDirector->setProjection(Director::PROJECTION_2D);
|
||||
|
||||
|
||||
Size screenSize = EGLView::getInstance()->getFrameSize();
|
||||
|
|
|
@ -29,7 +29,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// initialize director
|
||||
Director *pDirector = Director::getInstance();
|
||||
pDirector->setOpenGLView(EGLView::getInstance());
|
||||
pDirector->setProjection(kDirectorProjection2D);
|
||||
pDirector->setProjection(Director::PROJECTION_2D);
|
||||
|
||||
|
||||
Size screenSize = EGLView::getInstance()->getFrameSize();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue