mirror of https://github.com/axmolengine/axmol.git
Constant fixes
Director::PROJECTION_2D, 3D,... -> Director::Projection::_2D, _3D, ... Label::TEXT_ALIGNMENT_... -> Label::HAlignment::... Label::TEXT_VERTICAL_ALIGNMENT_... -> Label::VAlignment::... Texture2D::PIXEL_FORMAT_... -> Texture2D::PixelFormat::... BlendFunc::BLEND_FUNC_DISABLE -> BlendFunc::DISABLE Also adds more constant for BlendFunc
This commit is contained in:
parent
4417e9c829
commit
16d0b43181
|
@ -45,7 +45,7 @@ const Color3B ccBLACK = Color3B::BLACK;
|
|||
const Color3B ccORANGE = Color3B::ORANGE;
|
||||
const Color3B ccGRAY = Color3B::GRAY;
|
||||
|
||||
const BlendFunc kCCBlendFuncDisable = BlendFunc::BLEND_FUNC_DISABLE;
|
||||
const BlendFunc kCCBlendFuncDisable = BlendFunc::DISABLE;
|
||||
|
||||
const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION;
|
||||
const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR;
|
||||
|
@ -96,10 +96,10 @@ 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 Director::Projection kCCDirectorProjection2D = Director::Projection::_2D;
|
||||
const Director::Projection kCCDirectorProjection3D = Director::Projection::_3D;
|
||||
const Director::Projection kCCDirectorProjectionCustom = Director::Projection::CUSTOM;
|
||||
const Director::Projection kCCDirectorProjectionDefault = Director::Projection::DEFAULT;
|
||||
|
||||
const int ConfigurationError = Configuration::ERROR;
|
||||
const int ConfigurationString = Configuration::STRING;
|
||||
|
@ -118,25 +118,25 @@ 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 Label::VAlignment kCCVerticalTextAlignmentTop = Label::VAlignment::TOP;
|
||||
const Label::VAlignment kCCVerticalTextAlignmentCenter = Label::VAlignment::CENTER;
|
||||
const Label::VAlignment kCCVerticalTextAlignmentBottom = Label::VAlignment::BOTTOM;
|
||||
|
||||
const int kCCTextAlignmentLeft = Label::TEXT_ALIGNMENT_LEFT;
|
||||
const int kCCTextAlignmentCenter = Label::TEXT_ALIGNMENT_CENTER;
|
||||
const int kCCTextAlignmentRight = Label::TEXT_ALIGNMENT_RIGHT;
|
||||
const Label::HAlignment kCCTextAlignmentLeft = Label::HAlignment::LEFT;
|
||||
const Label::HAlignment kCCTextAlignmentCenter = Label::HAlignment::CENTER;
|
||||
const Label::HAlignment kCCTextAlignmentRight = Label::HAlignment::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 Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888 = Texture2D::PixelFormat::RGBA8888;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888 = Texture2D::PixelFormat::RGB888;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565 = Texture2D::PixelFormat::RGB565;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8 = Texture2D::PixelFormat::A8;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8 = Texture2D::PixelFormat::I8;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88 = Texture2D::PixelFormat::AI88;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PixelFormat::RGBA4444;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PixelFormat::RGB5A1;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PixelFormat::PRVTC4;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PixelFormat::PRVTC2;
|
||||
const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default = Texture2D::PixelFormat::DEFAULT;
|
||||
|
||||
const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY;
|
||||
const int kCCMenuStateWaiting = Menu::STATE_WAITING;
|
||||
|
|
|
@ -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 = PROJECTION_3D;
|
||||
_projection = Projection::_3D;
|
||||
else if (strcmp(projection, "2d") == 0)
|
||||
_projection = PROJECTION_2D;
|
||||
_projection = Projection::_2D;
|
||||
else if (strcmp(projection, "custom") == 0)
|
||||
_projection = PROJECTION_CUSTOM;
|
||||
_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(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
else if( strcmp(pixel_format, "rgba4444") == 0 )
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
else if( strcmp(pixel_format, "rgba5551") == 0 )
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGB5A1);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1);
|
||||
|
||||
// PVR v2 has alpha premultiplied ?
|
||||
bool pvr_alpha_premultipled = conf->getBool("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", false);
|
||||
|
@ -385,16 +385,15 @@ void Director::setNextDeltaTimeZero(bool bNextDeltaTimeZero)
|
|||
_nextDeltaTimeZero = bNextDeltaTimeZero;
|
||||
}
|
||||
|
||||
void Director::setProjection(Projection kProjection)
|
||||
void Director::setProjection(Projection projection)
|
||||
{
|
||||
Size size = _winSizeInPoints;
|
||||
|
||||
setViewport();
|
||||
|
||||
switch (kProjection)
|
||||
switch (projection)
|
||||
{
|
||||
case PROJECTION_2D:
|
||||
{
|
||||
case Projection::_2D:
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadIdentity();
|
||||
kmMat4 orthoMatrix;
|
||||
|
@ -402,10 +401,9 @@ void Director::setProjection(Projection kProjection)
|
|||
kmGLMultMatrix(&orthoMatrix);
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadIdentity();
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case PROJECTION_3D:
|
||||
case Projection::_3D:
|
||||
{
|
||||
float zeye = this->getZEye();
|
||||
|
||||
|
@ -428,22 +426,20 @@ void Director::setProjection(Projection kProjection)
|
|||
kmVec3Fill( &up, 0.0f, 1.0f, 0.0f);
|
||||
kmMat4LookAt(&matrixLookup, &eye, ¢er, &up);
|
||||
kmGLMultMatrix(&matrixLookup);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROJECTION_CUSTOM:
|
||||
if (_projectionDelegate)
|
||||
{
|
||||
_projectionDelegate->updateProjection();
|
||||
}
|
||||
break;
|
||||
case Projection::CUSTOM:
|
||||
if (_projectionDelegate)
|
||||
_projectionDelegate->updateProjection();
|
||||
break;
|
||||
|
||||
default:
|
||||
CCLOG("cocos2d: Director: unrecognized projection");
|
||||
break;
|
||||
default:
|
||||
CCLOG("cocos2d: Director: unrecognized projection");
|
||||
break;
|
||||
}
|
||||
|
||||
_projection = kProjection;
|
||||
_projection = projection;
|
||||
ccSetProjectionMatrixDirty();
|
||||
}
|
||||
|
||||
|
@ -865,7 +861,7 @@ void Director::createStatsLabel()
|
|||
}
|
||||
|
||||
Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat();
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
unsigned char *data = NULL;
|
||||
unsigned int data_len = 0;
|
||||
getFPSImageData(&data, &data_len);
|
||||
|
|
|
@ -85,19 +85,19 @@ public:
|
|||
/** @typedef ccDirectorProjection
|
||||
Possible OpenGL projections used by director
|
||||
*/
|
||||
enum Projection
|
||||
enum class Projection
|
||||
{
|
||||
/// sets a 2D projection (orthogonal projection)
|
||||
PROJECTION_2D,
|
||||
_2D,
|
||||
|
||||
/// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500.
|
||||
PROJECTION_3D,
|
||||
_3D,
|
||||
|
||||
/// it calls "updateProjection" on the projection delegate.
|
||||
PROJECTION_CUSTOM,
|
||||
CUSTOM,
|
||||
|
||||
/// Default projection is 3D projection
|
||||
PROJECTION_DEFAULT = PROJECTION_3D,
|
||||
DEFAULT = _3D,
|
||||
};
|
||||
|
||||
/** returns a shared instance of the director */
|
||||
|
@ -127,7 +127,7 @@ public:
|
|||
/** Whether or not to display the FPS on the bottom-left corner */
|
||||
inline bool isDisplayStats(void) { return _displayStats; }
|
||||
/** Display the FPS on the bottom-left corner */
|
||||
inline void setDisplayStats(bool bDisplayStats) { _displayStats = bDisplayStats; }
|
||||
inline void setDisplayStats(bool displayStats) { _displayStats = displayStats; }
|
||||
|
||||
/** seconds per frame */
|
||||
inline float getSecondsPerFrame() { return _secondsPerFrame; }
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
void setOpenGLView(EGLView *pobOpenGLView);
|
||||
|
||||
inline bool isNextDeltaTimeZero(void) { return _nextDeltaTimeZero; }
|
||||
void setNextDeltaTimeZero(bool bNextDeltaTimeZero);
|
||||
void setNextDeltaTimeZero(bool nextDeltaTimeZero);
|
||||
|
||||
/** Whether or not the Director is paused */
|
||||
inline bool isPaused(void) { return _paused; }
|
||||
|
@ -149,7 +149,7 @@ public:
|
|||
@since v0.8.2
|
||||
*/
|
||||
inline Projection getProjection(void) { return _projection; }
|
||||
void setProjection(Projection kProjection);
|
||||
void setProjection(Projection projection);
|
||||
|
||||
/** Sets the glViewport*/
|
||||
void setViewport();
|
||||
|
@ -201,12 +201,12 @@ public:
|
|||
/** converts a UIKit coordinate to an OpenGL coordinate
|
||||
Useful to convert (multi) touch coordinates to the current layout (portrait or landscape)
|
||||
*/
|
||||
Point convertToGL(const Point& obPoint);
|
||||
Point convertToGL(const Point& point);
|
||||
|
||||
/** converts an OpenGL coordinate to a UIKit coordinate
|
||||
Useful to convert node points to window points for calls such as glScissor
|
||||
*/
|
||||
Point convertToUI(const Point& obPoint);
|
||||
Point convertToUI(const Point& point);
|
||||
|
||||
/// XXX: missing description
|
||||
float getZEye(void) const;
|
||||
|
@ -219,14 +219,14 @@ public:
|
|||
*
|
||||
* It will call pushScene: and then it will call startAnimation
|
||||
*/
|
||||
void runWithScene(Scene *pScene);
|
||||
void runWithScene(Scene *scene);
|
||||
|
||||
/** Suspends the execution of the running scene, pushing it on the stack of suspended scenes.
|
||||
* The new scene will be executed.
|
||||
* Try to avoid big stacks of pushed scenes to reduce memory allocation.
|
||||
* ONLY call it if there is a running scene.
|
||||
*/
|
||||
void pushScene(Scene *pScene);
|
||||
void pushScene(Scene *scene);
|
||||
|
||||
/** Pops out a scene from the queue.
|
||||
* This scene will replace the running one.
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
/** Replaces the running scene with a new one. The running scene is terminated.
|
||||
* ONLY call it if there is a running scene.
|
||||
*/
|
||||
void replaceScene(Scene *pScene);
|
||||
void replaceScene(Scene *scene);
|
||||
|
||||
/** Ends the execution, releases the running scene.
|
||||
It doesn't remove the OpenGL view from its parent. You have to do it manually.
|
||||
|
|
|
@ -220,10 +220,8 @@ void AtlasNode::setBlendFunc(const BlendFunc &blendFunc)
|
|||
|
||||
void AtlasNode::updateBlendFunc()
|
||||
{
|
||||
if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() ) {
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() )
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
}
|
||||
|
||||
void AtlasNode::setTexture(Texture2D *texture)
|
||||
|
|
|
@ -43,6 +43,9 @@ Color4B::Color4B(const Color4F &color4F)
|
|||
a((GLubyte)(color4F.a * 255.0f))
|
||||
{}
|
||||
|
||||
const BlendFunc BlendFunc::BLEND_FUNC_DISABLE = {GL_ONE, GL_ZERO};
|
||||
const BlendFunc BlendFunc::DISABLE = {GL_ONE, GL_ZERO};
|
||||
const BlendFunc BlendFunc::ALPHA_PREMULTIPLIED = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA};
|
||||
const BlendFunc BlendFunc::ALPHA_NON_PREMULTIPLIED = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA};
|
||||
const BlendFunc BlendFunc::ADDITIVE = {GL_SRC_ALPHA, GL_ONE};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -117,7 +117,7 @@ bool GridBase::initWithSize(const Size& gridSize)
|
|||
unsigned long POTHigh = ccNextPOT((unsigned int)s.height);
|
||||
|
||||
// we only use rgba8888
|
||||
Texture2D::PixelFormat format = Texture2D::PIXEL_FORMAT_RGBA8888;
|
||||
Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888;
|
||||
|
||||
void *data = calloc((int)(POTWide * POTHigh * 4), 1);
|
||||
if (! data)
|
||||
|
@ -203,7 +203,7 @@ void GridBase::beforeDraw(void)
|
|||
_directorProjection = director->getProjection();
|
||||
|
||||
// 2d projection
|
||||
// [director setProjection:Director::PROJECTION_2D];
|
||||
// [director setProjection:Director::Projection::_2D];
|
||||
set2DProjection();
|
||||
_grabber->beforeRender(_texture);
|
||||
}
|
||||
|
|
|
@ -804,8 +804,8 @@ CC_DEPRECATED_ATTRIBUTE typedef FontShadow ccFontShadow;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Label::VerticalTextAlignment CCVerticalTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Label::TextAlignment CCTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Label::VAlignment CCVerticalTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Label::HAlignment CCTextAlignment;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
|
||||
|
@ -860,10 +860,10 @@ CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeRadial;
|
|||
CC_DEPRECATED_ATTRIBUTE extern const int kCCProgressTimerTypeBar;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum ProgressTimer::Type ProgressTimerType;
|
||||
|
||||
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 extern const Director::Projection kCCDirectorProjection2D;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjection3D;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjectionCustom;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjectionDefault;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Director::Projection ccDirectorProjection;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationError;
|
||||
|
@ -873,25 +873,25 @@ CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationDouble;
|
|||
CC_DEPRECATED_ATTRIBUTE extern const int ConfigurationBoolean;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Configuration::Type ccConfigurationType;
|
||||
|
||||
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 Label::VAlignment kCCVerticalTextAlignmentTop;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentCenter;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentBottom;
|
||||
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentLeft;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentCenter;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const int kCCTextAlignmentRight;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentLeft;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentCenter;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentRight;
|
||||
|
||||
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 extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2;
|
||||
CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef enum Texture2D::PixelFormat CCTexture2DPixelFormat;
|
||||
|
||||
#define kCCLabelAutomaticWidth kLabelAutomaticWidth
|
||||
|
|
|
@ -300,8 +300,15 @@ struct BlendFunc
|
|||
GLenum src;
|
||||
//! destination blend function
|
||||
GLenum dst;
|
||||
|
||||
const static BlendFunc BLEND_FUNC_DISABLE;
|
||||
|
||||
//! Blending disabled. Uses {GL_ONE, GL_ZERO}
|
||||
const static BlendFunc DISABLE;
|
||||
//! Blending enabled for textures with Alpha premultiplied. Uses {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}
|
||||
const static BlendFunc ALPHA_PREMULTIPLIED;
|
||||
//! Blending enabled for textures with Alpha NON premultiplied. Uses {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}
|
||||
const static BlendFunc ALPHA_NON_PREMULTIPLIED;
|
||||
//! Enables Additive blending. Uses {GL_SRC_ALPHA, GL_ONE}
|
||||
const static BlendFunc ADDITIVE;
|
||||
};
|
||||
|
||||
class Label : public Object
|
||||
|
@ -309,20 +316,20 @@ class Label : public Object
|
|||
public:
|
||||
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m
|
||||
//! Vertical text alignment type
|
||||
enum VerticalTextAlignment
|
||||
enum class VAlignment
|
||||
{
|
||||
VERTICAL_TEXT_ALIGNMENT_TOP,
|
||||
VERTICAL_TEXT_ALIGNMENT_CENTER,
|
||||
VERTICAL_TEXT_ALIGNMENT_BOTTOM,
|
||||
TOP,
|
||||
CENTER,
|
||||
BOTTOM,
|
||||
};
|
||||
|
||||
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m
|
||||
//! Horizontal text alignment type
|
||||
enum TextAlignment
|
||||
enum class HAlignment
|
||||
{
|
||||
TEXT_ALIGNMENT_LEFT,
|
||||
TEXT_ALIGNMENT_CENTER,
|
||||
TEXT_ALIGNMENT_RIGHT,
|
||||
LEFT,
|
||||
CENTER,
|
||||
RIGHT,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -400,8 +407,8 @@ struct FontDefinition
|
|||
public:
|
||||
|
||||
FontDefinition():_fontSize(0),
|
||||
_alignment(Label::TEXT_ALIGNMENT_CENTER),
|
||||
_vertAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP),
|
||||
_alignment(Label::HAlignment::CENTER),
|
||||
_vertAlignment(Label::VAlignment::TOP),
|
||||
_fontFillColor(Color3B::WHITE)
|
||||
{ _dimensions = Size(0,0); }
|
||||
|
||||
|
@ -410,9 +417,9 @@ public:
|
|||
// font size
|
||||
int _fontSize;
|
||||
// horizontal alignment
|
||||
Label::Label::Label::TextAlignment _alignment;
|
||||
Label::HAlignment _alignment;
|
||||
// vertical alignment
|
||||
Label::Label::Label::VerticalTextAlignment _vertAlignment;
|
||||
Label::VAlignment _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, Label::TextAlignment alignment)
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, Label::HAlignment 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, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
|
||||
return LabelBMFont::create(str, fntFile, width, Label::HAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile)
|
||||
{
|
||||
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
|
||||
return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, Label::HAlignment::LEFT, Point::ZERO);
|
||||
}
|
||||
|
||||
//LabelBMFont - Creation & Init
|
||||
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::TextAlignment alignment/* = Label::TEXT_ALIGNMENT_LEFT*/, Point imageOffset/* = Point::ZERO*/)
|
||||
LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::HAlignment alignment/* = Label::HAlignment::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, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
|
||||
return initWithString(NULL, NULL, kLabelAutomaticWidth, Label::HAlignment::LEFT, 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*/)
|
||||
bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::HAlignment alignment/* = Label::HAlignment::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(Label::TEXT_ALIGNMENT_CENTER)
|
||||
, _alignment(Label::HAlignment::CENTER)
|
||||
, _width(-1.0f)
|
||||
, _configuration(NULL)
|
||||
, _lineBreakWithoutSpaces(false)
|
||||
|
@ -1094,7 +1094,7 @@ void LabelBMFont::updateLabel()
|
|||
}
|
||||
|
||||
// Step 2: Make alignment
|
||||
if (_alignment != Label::TEXT_ALIGNMENT_LEFT)
|
||||
if (_alignment != Label::HAlignment::LEFT)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
@ -1125,10 +1125,10 @@ void LabelBMFont::updateLabel()
|
|||
float shift = 0;
|
||||
switch (_alignment)
|
||||
{
|
||||
case Label::TEXT_ALIGNMENT_CENTER:
|
||||
case Label::HAlignment::CENTER:
|
||||
shift = getContentSize().width/2.0f - lineWidth/2.0f;
|
||||
break;
|
||||
case Label::TEXT_ALIGNMENT_RIGHT:
|
||||
case Label::HAlignment::RIGHT:
|
||||
shift = getContentSize().width - lineWidth;
|
||||
break;
|
||||
default:
|
||||
|
@ -1160,7 +1160,7 @@ void LabelBMFont::updateLabel()
|
|||
}
|
||||
|
||||
// LabelBMFont - Alignment
|
||||
void LabelBMFont::setAlignment(Label::TextAlignment alignment)
|
||||
void LabelBMFont::setAlignment(Label::HAlignment 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, Label::TextAlignment alignment, Point imageOffset);
|
||||
static LabelBMFont * create(const char *str, const char *fntFile, float width, Label::HAlignment alignment, Point imageOffset);
|
||||
|
||||
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, Label::HAlignment 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, Label::TextAlignment alignment = Label::TEXT_ALIGNMENT_LEFT, Point imageOffset = Point::ZERO);
|
||||
bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, Label::HAlignment alignment = Label::HAlignment::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(Label::TextAlignment alignment);
|
||||
virtual void setAlignment(Label::HAlignment 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
|
||||
Label::TextAlignment _alignment;
|
||||
Label::HAlignment _alignment;
|
||||
// max width until a line break is added
|
||||
float _width;
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ NS_CC_BEGIN
|
|||
//CCLabelTTF
|
||||
//
|
||||
LabelTTF::LabelTTF()
|
||||
: _alignment(Label::TEXT_ALIGNMENT_CENTER)
|
||||
, _vAlignment(Label::VERTICAL_TEXT_ALIGNMENT_TOP)
|
||||
: _alignment(Label::HAlignment::CENTER)
|
||||
, _vAlignment(Label::VAlignment::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, Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
Size::ZERO, Label::HAlignment::CENTER, Label::VAlignment::TOP);
|
||||
}
|
||||
|
||||
LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize,
|
||||
const Size& dimensions, Label::TextAlignment hAlignment)
|
||||
const Size& dimensions, Label::HAlignment hAlignment)
|
||||
{
|
||||
return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, Label::VAlignment::TOP);
|
||||
}
|
||||
|
||||
LabelTTF* LabelTTF::create(const char *string, const char *fontName, float fontSize,
|
||||
const Size &dimensions, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment)
|
||||
const Size &dimensions, Label::HAlignment hAlignment,
|
||||
Label::VAlignment 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, Label::TextAlignment alignment)
|
||||
const Size& dimensions, Label::HAlignment alignment)
|
||||
{
|
||||
return this->initWithString(label, fontName, fontSize, dimensions, alignment, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
return this->initWithString(label, fontName, fontSize, dimensions, alignment, Label::VAlignment::TOP);
|
||||
}
|
||||
|
||||
bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
|
||||
{
|
||||
return this->initWithString(label, fontName, fontSize,
|
||||
Size::ZERO, Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
Size::ZERO, Label::HAlignment::LEFT, Label::VAlignment::TOP);
|
||||
}
|
||||
|
||||
bool LabelTTF::initWithString(const char *string, const char *fontName, float fontSize,
|
||||
const cocos2d::Size &dimensions, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment)
|
||||
const cocos2d::Size &dimensions, Label::HAlignment hAlignment,
|
||||
Label::VAlignment 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();
|
||||
}
|
||||
|
||||
Label::TextAlignment LabelTTF::getHorizontalAlignment() const
|
||||
Label::HAlignment LabelTTF::getHorizontalAlignment() const
|
||||
{
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
void LabelTTF::setHorizontalAlignment(Label::TextAlignment alignment)
|
||||
void LabelTTF::setHorizontalAlignment(Label::HAlignment alignment)
|
||||
{
|
||||
if (alignment != _alignment)
|
||||
{
|
||||
|
@ -212,12 +212,12 @@ void LabelTTF::setHorizontalAlignment(Label::TextAlignment alignment)
|
|||
}
|
||||
}
|
||||
|
||||
Label::VerticalTextAlignment LabelTTF::getVerticalAlignment() const
|
||||
Label::VAlignment LabelTTF::getVerticalAlignment() const
|
||||
{
|
||||
return _vAlignment;
|
||||
}
|
||||
|
||||
void LabelTTF::setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment)
|
||||
void LabelTTF::setVerticalAlignment(Label::VAlignment 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,
|
||||
* Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_CENTER);
|
||||
* Label::HAlignment::LEFT, Label::VAlignment::CENTER);
|
||||
* LabelTTF *label2 = LabelTTF::create("alignment right", "/mnt/sdcard/Scissor Cuts.ttf", fontSize, blockSize,
|
||||
* Label::TEXT_ALIGNMENT_LEFT, Label::VERTICAL_TEXT_ALIGNMENT_CENTER);
|
||||
* Label::HAlignment::LEFT, Label::VAlignment::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, Label::TextAlignment hAlignment);
|
||||
const Size& dimensions, Label::HAlignment 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, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment);
|
||||
const Size& dimensions, Label::HAlignment hAlignment,
|
||||
Label::VAlignment 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, Label::TextAlignment hAlignment);
|
||||
const Size& dimensions, Label::HAlignment 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, Label::TextAlignment hAlignment,
|
||||
Label::VerticalTextAlignment vAlignment);
|
||||
const Size& dimensions, Label::HAlignment hAlignment,
|
||||
Label::VAlignment 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;
|
||||
|
||||
Label::TextAlignment getHorizontalAlignment() const;
|
||||
void setHorizontalAlignment(Label::TextAlignment alignment);
|
||||
Label::HAlignment getHorizontalAlignment() const;
|
||||
void setHorizontalAlignment(Label::HAlignment alignment);
|
||||
|
||||
Label::VerticalTextAlignment getVerticalAlignment() const;
|
||||
void setVerticalAlignment(Label::VerticalTextAlignment verticalAlignment);
|
||||
Label::VAlignment getVerticalAlignment() const;
|
||||
void setVerticalAlignment(Label::VAlignment 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 */
|
||||
Label::TextAlignment _alignment;
|
||||
Label::HAlignment _alignment;
|
||||
/** The vertical alignment of the label */
|
||||
Label::VerticalTextAlignment _vAlignment;
|
||||
Label::VAlignment _vAlignment;
|
||||
/** Font name used in the label */
|
||||
std::string * _fontName;
|
||||
/** Font size of the label */
|
||||
|
|
|
@ -691,8 +691,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h)
|
|||
{
|
||||
|
||||
// default blend function
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
|
||||
_displayedColor.r = _realColor.r = color.r;
|
||||
_displayedColor.g = _realColor.g = color.g;
|
||||
|
|
|
@ -49,9 +49,8 @@ MotionStreak::MotionStreak()
|
|||
, _vertices(NULL)
|
||||
, _colorPointer(NULL)
|
||||
, _texCoords(NULL)
|
||||
, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||
{
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
|
||||
MotionStreak::~MotionStreak()
|
||||
|
@ -123,8 +122,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co
|
|||
_colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4);
|
||||
|
||||
// Set blend mode
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
|
||||
// shader program
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
|
|
@ -51,7 +51,7 @@ RenderTexture::RenderTexture()
|
|||
, _texture(0)
|
||||
, _textureCopy(0)
|
||||
, _UITextureImage(NULL)
|
||||
, _pixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888)
|
||||
, _pixelFormat(Texture2D::PixelFormat::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(), Texture2D::PIXEL_FORMAT_RGBA8888, s);
|
||||
VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), Texture2D::PixelFormat::RGBA8888, s);
|
||||
|
||||
if ( _textureCopy )
|
||||
{
|
||||
VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), Texture2D::PIXEL_FORMAT_RGBA8888, s);
|
||||
VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), Texture2D::PixelFormat::RGBA8888, s);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -170,7 +170,7 @@ RenderTexture * RenderTexture::create(int w, int h)
|
|||
{
|
||||
RenderTexture *pRet = new RenderTexture();
|
||||
|
||||
if(pRet && pRet->initWithWidthAndHeight(w, h, Texture2D::PIXEL_FORMAT_RGBA8888, 0))
|
||||
if(pRet && pRet->initWithWidthAndHeight(w, h, Texture2D::PixelFormat::RGBA8888, 0))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
|
@ -186,7 +186,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
|
||||
bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat)
|
||||
{
|
||||
CCASSERT(eFormat != Texture2D::PIXEL_FORMAT_A8, "only RGB and RGBA formats are valid for a render texture");
|
||||
CCASSERT(eFormat != Texture2D::PixelFormat::A8, "only RGB and RGBA formats are valid for a render texture");
|
||||
|
||||
bool bRet = false;
|
||||
void *data = NULL;
|
||||
|
@ -276,8 +276,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
_texture->release();
|
||||
_sprite->setScaleY(-1);
|
||||
|
||||
BlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
|
||||
_sprite->setBlendFunc(tBlendFunc);
|
||||
_sprite->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO);
|
||||
|
@ -578,7 +577,7 @@ bool RenderTexture::saveToFile(const char *fileName, Image::Format format)
|
|||
/* get buffer as Image */
|
||||
Image* RenderTexture::newImage(bool flipImage)
|
||||
{
|
||||
CCASSERT(_pixelFormat == Texture2D::PIXEL_FORMAT_RGBA8888, "only RGBA8888 can be saved as image");
|
||||
CCASSERT(_pixelFormat == Texture2D::PixelFormat::RGBA8888, "only RGBA8888 can be saved as image");
|
||||
|
||||
if (NULL == _texture)
|
||||
{
|
||||
|
|
|
@ -171,7 +171,7 @@ protected:
|
|||
Texture2D* _texture;
|
||||
Texture2D* _textureCopy; // a copy of _texture
|
||||
Image* _UITextureImage;
|
||||
GLenum _pixelFormat;
|
||||
Texture2D::PixelFormat _pixelFormat;
|
||||
|
||||
// code for "auto" update
|
||||
GLbitfield _clearFlags;
|
||||
|
|
|
@ -485,10 +485,8 @@ void ParticleBatchNode::updateAllAtlasIndexes()
|
|||
|
||||
void ParticleBatchNode::updateBlendFunc(void)
|
||||
{
|
||||
if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha()) {
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha())
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
}
|
||||
|
||||
void ParticleBatchNode::setTexture(Texture2D* texture)
|
||||
|
@ -498,8 +496,7 @@ void ParticleBatchNode::setTexture(Texture2D* texture)
|
|||
// If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it
|
||||
if( texture && ! texture->hasPremultipliedAlpha() && ( _blendFunc.src == CC_BLEND_SRC && _blendFunc.dst == CC_BLEND_DST ) )
|
||||
{
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -815,8 +815,7 @@ void ParticleSystem::updateBlendFunc()
|
|||
}
|
||||
else
|
||||
{
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -832,21 +831,14 @@ void ParticleSystem::setBlendAdditive(bool additive)
|
|||
{
|
||||
if( additive )
|
||||
{
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE;
|
||||
_blendFunc = BlendFunc::ADDITIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( _texture && ! _texture->hasPremultipliedAlpha() )
|
||||
{
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
else
|
||||
{
|
||||
_blendFunc.src = CC_BLEND_SRC;
|
||||
_blendFunc.dst = CC_BLEND_DST;
|
||||
}
|
||||
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,17 +80,17 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
|||
{
|
||||
if(hasAlpha || bpp >= 8)
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
|
||||
pixelFormat = Texture2D::PixelFormat::DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
|
||||
pixelFormat = Texture2D::PixelFormat::RGB565;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: No colorspace means a mask image
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_A8;
|
||||
pixelFormat = Texture2D::PixelFormat::A8;
|
||||
}
|
||||
|
||||
imageSize.width = CGImageGetWidth(image);
|
||||
|
@ -100,9 +100,9 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT
|
|||
|
||||
switch(pixelFormat)
|
||||
{
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
case Texture2D::PixelFormat::RGBA8888:
|
||||
case Texture2D::PixelFormat::RGBA4444:
|
||||
case Texture2D::PixelFormat::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 Texture2D::PIXEL_FORMAT_RGB565:
|
||||
case Texture2D::PixelFormat::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 Texture2D::PIXEL_FORMAT_A8:
|
||||
case Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB565)
|
||||
if(pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGBA4444)
|
||||
else if (pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB5A1)
|
||||
else if (pixelFormat == Texture2D::PixelFormat::RGB5A1)
|
||||
{
|
||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
|
||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
||||
|
@ -627,21 +627,21 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|||
{
|
||||
if (bpp >= 8)
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
|
||||
pixelFormat = Texture2D::PixelFormat::RGB888;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("cocos2d: Texture2D: Using RGB565 texture since image has no alpha");
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
|
||||
pixelFormat = Texture2D::PixelFormat::RGB565;
|
||||
}
|
||||
}
|
||||
|
||||
switch(pixelFormat) {
|
||||
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:
|
||||
case Texture2D::PixelFormat::RGBA8888:
|
||||
case Texture2D::PixelFormat::RGBA4444:
|
||||
case Texture2D::PixelFormat::RGB5A1:
|
||||
case Texture2D::PixelFormat::RGB565:
|
||||
case Texture2D::PixelFormat::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 Texture2D::PIXEL_FORMAT_RGB888:
|
||||
case Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB565) {
|
||||
if(pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGBA4444) {
|
||||
else if (pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB5A1) {
|
||||
else if (pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_A8)
|
||||
else if (pixelFormat == Texture2D::PixelFormat::A8)
|
||||
{
|
||||
// fix me, how to convert to A8
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGBA8888;
|
||||
pixelFormat = Texture2D::PixelFormat::RGBA8888;
|
||||
|
||||
//
|
||||
//The code can not work, how to convert to A8?
|
||||
|
|
|
@ -1054,14 +1054,12 @@ void Sprite::updateBlendFunc(void)
|
|||
// it is possible to have an untextured sprite
|
||||
if (! _texture || ! _texture->hasPremultipliedAlpha())
|
||||
{
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
setOpacityModifyRGB(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_blendFunc.src = CC_BLEND_SRC;
|
||||
_blendFunc.dst = CC_BLEND_DST;
|
||||
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||
setOpacityModifyRGB(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -667,10 +667,7 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *pobSprite)
|
|||
void SpriteBatchNode::updateBlendFunc(void)
|
||||
{
|
||||
if (! _textureAtlas->getTexture()->hasPremultipliedAlpha())
|
||||
{
|
||||
_blendFunc.src = GL_SRC_ALPHA;
|
||||
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
}
|
||||
|
||||
// CocosNodeTexture protocol
|
||||
|
|
|
@ -70,7 +70,7 @@ TextFieldTTF::~TextFieldTTF()
|
|||
// static constructor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::TextAlignment alignment, const char *fontName, float fontSize)
|
||||
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment 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, Label::TextAlignment alignment, const char *fontName, float fontSize)
|
||||
bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment 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, Label::TextAlignment alignment, const char *fontName, float fontSize);
|
||||
static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment 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, Label::TextAlignment alignment, const char *fontName, float fontSize);
|
||||
bool initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment 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 Texture2D::PixelFormat g_defaultAlphaPixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
|
||||
static Texture2D::PixelFormat g_defaultAlphaPixelFormat = Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_DEFAULT)
|
||||
, _pixelFormat(Texture2D::PixelFormat::DEFAULT)
|
||||
, _name(0)
|
||||
, _maxS(0.0)
|
||||
, _maxT(0.0)
|
||||
|
@ -176,7 +176,7 @@ bool Texture2D::initWithData(const void *data, Texture2D::PixelFormat pixelForma
|
|||
{
|
||||
unsigned int bitsPerPixel;
|
||||
//Hack: bitsPerPixelForFormat returns wrong number for RGB_888 textures. See function.
|
||||
if(pixelFormat == Texture2D::PIXEL_FORMAT_RGB888)
|
||||
if(pixelFormat == Texture2D::PixelFormat::RGB888)
|
||||
{
|
||||
bitsPerPixel = 24;
|
||||
}
|
||||
|
@ -217,28 +217,28 @@ bool Texture2D::initWithData(const void *data, Texture2D::PixelFormat pixelForma
|
|||
|
||||
switch(pixelFormat)
|
||||
{
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
case Texture2D::PixelFormat::RGBA8888:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGB888:
|
||||
case Texture2D::PixelFormat::RGB888:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PixelFormat::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 Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
case Texture2D::PixelFormat::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 Texture2D::PIXEL_FORMAT_RGB565:
|
||||
case Texture2D::PixelFormat::RGB565:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_AI88:
|
||||
case Texture2D::PixelFormat::AI88:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
case Texture2D::PixelFormat::A8:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_I8:
|
||||
case Texture2D::PixelFormat::I8:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
default:
|
||||
|
@ -313,11 +313,11 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
|
|||
{
|
||||
if (bpp >= 8)
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
|
||||
pixelFormat = Texture2D::PixelFormat::RGB888;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
|
||||
pixelFormat = Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB565)
|
||||
if (pixelFormat == Texture2D::PixelFormat::RGB565)
|
||||
{
|
||||
if (hasAlpha)
|
||||
{
|
||||
|
@ -360,7 +360,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (pixelFormat == Texture2D::PIXEL_FORMAT_RGBA4444)
|
||||
else if (pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB5A1)
|
||||
else if (pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_A8)
|
||||
else if (pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB888)
|
||||
if (hasAlpha && pixelFormat == Texture2D::PixelFormat::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)*/, Label::TextAlignment hAlignment/* = Label::TEXT_ALIGNMENT_CENTER */, Label::VerticalTextAlignment vAlignment/* = Label::VERTICAL_TEXT_ALIGNMENT_TOP */)
|
||||
bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, Label::HAlignment hAlignment/* = Label::HAlignment::CENTER */, Label::VAlignment vAlignment/* = Label::VAlignment::TOP */)
|
||||
{
|
||||
FontDefinition tempDef;
|
||||
|
||||
|
@ -461,20 +461,20 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
|||
bool bRet = false;
|
||||
Image::ETextAlign eAlign;
|
||||
|
||||
if (Label::VERTICAL_TEXT_ALIGNMENT_TOP == textDefinition._vertAlignment)
|
||||
if (Label::VAlignment::TOP == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignTop
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignTop
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
||||
}
|
||||
else if (Label::VERTICAL_TEXT_ALIGNMENT_CENTER == textDefinition._vertAlignment)
|
||||
else if (Label::VAlignment::CENTER == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignCenter
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignCenter
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
||||
}
|
||||
else if (Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM == textDefinition._vertAlignment)
|
||||
else if (Label::VAlignment::BOTTOM == textDefinition._vertAlignment)
|
||||
{
|
||||
eAlign = (Label::TEXT_ALIGNMENT_CENTER == textDefinition._alignment) ? Image::kAlignBottom
|
||||
: (Label::TEXT_ALIGNMENT_LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
||||
eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignBottom
|
||||
: (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -789,34 +789,34 @@ const char* Texture2D::getStringForFormat() const
|
|||
{
|
||||
switch (_pixelFormat)
|
||||
{
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
case Texture2D::PixelFormat::RGBA8888:
|
||||
return "RGBA8888";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_RGB888:
|
||||
case Texture2D::PixelFormat::RGB888:
|
||||
return "RGB888";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
case Texture2D::PixelFormat::RGB565:
|
||||
return "RGB565";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PixelFormat::RGBA4444:
|
||||
return "RGBA4444";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
case Texture2D::PixelFormat::RGB5A1:
|
||||
return "RGB5A1";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_AI88:
|
||||
case Texture2D::PixelFormat::AI88:
|
||||
return "AI88";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
case Texture2D::PixelFormat::A8:
|
||||
return "A8";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_I8:
|
||||
case Texture2D::PixelFormat::I8:
|
||||
return "I8";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC4:
|
||||
case Texture2D::PixelFormat::PRVTC4:
|
||||
return "PVRTC4";
|
||||
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC2:
|
||||
case Texture2D::PixelFormat::PRVTC2:
|
||||
return "PVRTC2";
|
||||
|
||||
default:
|
||||
|
@ -848,35 +848,35 @@ unsigned int Texture2D::getBitsPerPixelForFormat(Texture2D::PixelFormat format)
|
|||
unsigned int ret=0;
|
||||
|
||||
switch (format) {
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
case Texture2D::PixelFormat::RGBA8888:
|
||||
ret = 32;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGB888:
|
||||
case Texture2D::PixelFormat::RGB888:
|
||||
// It is 32 and not 24, since its internal representation uses 32 bits.
|
||||
ret = 32;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
case Texture2D::PixelFormat::RGB565:
|
||||
ret = 16;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PixelFormat::RGBA4444:
|
||||
ret = 16;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
case Texture2D::PixelFormat::RGB5A1:
|
||||
ret = 16;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_AI88:
|
||||
case Texture2D::PixelFormat::AI88:
|
||||
ret = 16;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
case Texture2D::PixelFormat::A8:
|
||||
ret = 8;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_I8:
|
||||
case Texture2D::PixelFormat::I8:
|
||||
ret = 8;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC4:
|
||||
case Texture2D::PixelFormat::PRVTC4:
|
||||
ret = 4;
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_PRVTC2:
|
||||
case Texture2D::PixelFormat::PRVTC2:
|
||||
ret = 2;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -74,43 +74,42 @@ public:
|
|||
/** @typedef Texture2D::PixelFormat
|
||||
Possible texture pixel formats
|
||||
*/
|
||||
enum PixelFormat
|
||||
enum class PixelFormat
|
||||
{
|
||||
|
||||
//! 32-bit texture: RGBA8888
|
||||
PIXEL_FORMAT_RGBA8888,
|
||||
RGBA8888,
|
||||
//! 24-bit texture: RGBA888
|
||||
PIXEL_FORMAT_RGB888,
|
||||
RGB888,
|
||||
//! 16-bit texture without Alpha channel
|
||||
PIXEL_FORMAT_RGB565,
|
||||
RGB565,
|
||||
//! 8-bit textures used as masks
|
||||
PIXEL_FORMAT_A8,
|
||||
A8,
|
||||
//! 8-bit intensity texture
|
||||
PIXEL_FORMAT_I8,
|
||||
I8,
|
||||
//! 16-bit textures used as masks
|
||||
PIXEL_FORMAT_AI88,
|
||||
AI88,
|
||||
//! 16-bit textures: RGBA4444
|
||||
PIXEL_FORMAT_RGBA4444,
|
||||
RGBA4444,
|
||||
//! 16-bit textures: RGB5A1
|
||||
PIXEL_FORMAT_RGB5A1,
|
||||
RGB5A1,
|
||||
//! 4-bit PVRTC-compressed texture: PVRTC4
|
||||
PIXEL_FORMAT_PRVTC4,
|
||||
PRVTC4,
|
||||
//! 2-bit PVRTC-compressed texture: PVRTC2
|
||||
PIXEL_FORMAT_PRVTC2,
|
||||
|
||||
|
||||
PRVTC2,
|
||||
|
||||
//! Default texture format: RGBA8888
|
||||
PIXEL_FORMAT_DEFAULT = PIXEL_FORMAT_RGBA8888
|
||||
} ;
|
||||
DEFAULT = RGBA8888
|
||||
};
|
||||
|
||||
/** sets the default pixel format for UIImagescontains alpha channel.
|
||||
If the UIImage contains alpha channel, then the options are:
|
||||
- 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)
|
||||
- generate 32-bit textures: Texture2D::PixelFormat::RGBA8888 (default one)
|
||||
- generate 24-bit textures: Texture2D::PixelFormat::RGB888
|
||||
- generate 16-bit textures: Texture2D::PixelFormat::RGBA4444
|
||||
- generate 16-bit textures: Texture2D::PixelFormat::RGB5A1
|
||||
- generate 16-bit textures: Texture2D::PixelFormat::RGB565
|
||||
- generate 8-bit textures: Texture2D::PixelFormat::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)
|
||||
|
@ -169,7 +168,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), Label::TextAlignment hAlignment = Label::TEXT_ALIGNMENT_CENTER, Label::VerticalTextAlignment vAlignment = Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), Label::HAlignment hAlignment = Label::HAlignment::CENTER, Label::VAlignment vAlignment = Label::VAlignment::TOP);
|
||||
/** Initializes a texture from a string using a text definition*/
|
||||
bool initWithString(const char *text, const FontDefinition& textDefinition);
|
||||
|
||||
|
|
|
@ -641,7 +641,7 @@ VolatileTexture::VolatileTexture(Texture2D *t)
|
|||
: _texture(t)
|
||||
, _cashedImageType(kInvalid)
|
||||
, _textureData(NULL)
|
||||
, _pixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888)
|
||||
, _pixelFormat(Texture2D::PixelFormat::RGBA8888)
|
||||
, _fileName("")
|
||||
, _fmtImage(Image::FORMAT_PNG)
|
||||
, _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, Texture2D::PIXEL_FORMAT_RGBA8888},
|
||||
{GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, true, Texture2D::PixelFormat::RGBA8888},
|
||||
// 1: RGBA_8888
|
||||
{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true, Texture2D::PIXEL_FORMAT_RGBA8888},
|
||||
{GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true, Texture2D::PixelFormat::RGBA8888},
|
||||
// 2: RGBA_4444
|
||||
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true, Texture2D::PIXEL_FORMAT_RGBA4444},
|
||||
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true, Texture2D::PixelFormat::RGBA4444},
|
||||
// 3: RGBA_5551
|
||||
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true, Texture2D::PIXEL_FORMAT_RGB5A1},
|
||||
{GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true, Texture2D::PixelFormat::RGB5A1},
|
||||
// 4: RGB_565
|
||||
{GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false, Texture2D::PIXEL_FORMAT_RGB565},
|
||||
{GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false, Texture2D::PixelFormat::RGB565},
|
||||
// 5: RGB_888
|
||||
{GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false, Texture2D::PIXEL_FORMAT_RGB888},
|
||||
{GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false, Texture2D::PixelFormat::RGB888},
|
||||
// 6: A_8
|
||||
{GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PIXEL_FORMAT_A8},
|
||||
{GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PixelFormat::A8},
|
||||
// 7: L_8
|
||||
{GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PIXEL_FORMAT_I8},
|
||||
{GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PixelFormat::I8},
|
||||
// 8: LA_88
|
||||
{GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true, Texture2D::PIXEL_FORMAT_AI88},
|
||||
{GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true, Texture2D::PixelFormat::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, Texture2D::PIXEL_FORMAT_PRVTC2},
|
||||
{GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, false, Texture2D::PixelFormat::PRVTC2},
|
||||
// 10: PVRTC 2BPP RGBA
|
||||
{GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true, Texture2D::PIXEL_FORMAT_PRVTC2},
|
||||
{GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true, Texture2D::PixelFormat::PRVTC2},
|
||||
// 11: PVRTC 4BPP RGB
|
||||
{GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false, Texture2D::PIXEL_FORMAT_PRVTC4},
|
||||
{GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false, Texture2D::PixelFormat::PRVTC4},
|
||||
// 12: PVRTC 4BPP RGBA
|
||||
{GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true, Texture2D::PIXEL_FORMAT_PRVTC4},
|
||||
{GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true, Texture2D::PixelFormat::PRVTC4},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -235,7 +235,7 @@ TexturePVR::TexturePVR()
|
|||
, _hasPremultipliedAlpha(false)
|
||||
, _forcePremultipliedAlpha(false)
|
||||
, _retainName(false)
|
||||
, _format(Texture2D::PIXEL_FORMAT_DEFAULT)
|
||||
, _format(Texture2D::PixelFormat::DEFAULT)
|
||||
, _pixelFormatInfo(NULL)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -62,17 +62,17 @@ bool Texture2DMutable::initWithImageFile(const char *imageFile)
|
|||
// compute pixel format
|
||||
if(hasAlpha)
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_DEFAULT;
|
||||
pixelFormat = Texture2D::PixelFormat::DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bpp >= 8)
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB888;
|
||||
pixelFormat = Texture2D::PixelFormat::RGB888;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelFormat = Texture2D::PIXEL_FORMAT_RGB565;
|
||||
pixelFormat = Texture2D::PixelFormat::RGB565;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,11 +87,11 @@ bool Texture2DMutable::initWithData(const void* data, Texture2D::PixelFormat pix
|
|||
}
|
||||
|
||||
switch (pixelFormat) {
|
||||
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:
|
||||
case Texture2D::PixelFormat::RGBA8888: bytesPerPixel_ = 4; break;
|
||||
case Texture2D::PixelFormat::A8: bytesPerPixel_ = 1; break;
|
||||
case Texture2D::PixelFormat::RGBA4444:
|
||||
case Texture2D::PixelFormat::RGB565:
|
||||
case Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGBA8888){
|
||||
if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGBA4444){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB5A1){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB565){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_A8){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGBA8888){
|
||||
if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGBA4444){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB5A1){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_RGB565){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::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 == Texture2D::PIXEL_FORMAT_A8){
|
||||
} else if(_pixelFormat == Texture2D::PixelFormat::A8){
|
||||
GLubyte *pixel = (GLubyte *)data_;
|
||||
pixel[(y * _pixelsWide) + x] = c.a;
|
||||
} else {
|
||||
|
@ -264,19 +264,19 @@ void Texture2DMutable::apply()
|
|||
|
||||
switch(_pixelFormat)
|
||||
{
|
||||
case Texture2D::PIXEL_FORMAT_RGBA8888:
|
||||
case Texture2D::PixelFormat::RGBA8888:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGBA4444:
|
||||
case Texture2D::PixelFormat::RGBA4444:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data_);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGB5A1:
|
||||
case Texture2D::PixelFormat::RGB5A1:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data_);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_RGB565:
|
||||
case Texture2D::PixelFormat::RGB565:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _pixelsWide, _pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data_);
|
||||
break;
|
||||
case Texture2D::PIXEL_FORMAT_A8:
|
||||
case Texture2D::PixelFormat::A8:
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, _pixelsWide, _pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data_);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -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(Label::TextAlignment(pIntegerLabeled));
|
||||
((LabelTTF *)pNode)->setHorizontalAlignment(Label::HAlignment(pIntegerLabeled));
|
||||
} else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) {
|
||||
((LabelTTF *)pNode)->setVerticalAlignment(Label::VerticalTextAlignment(pIntegerLabeled));
|
||||
((LabelTTF *)pNode)->setVerticalAlignment(Label::VAlignment(pIntegerLabeled));
|
||||
} else {
|
||||
NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader);
|
||||
}
|
||||
|
|
|
@ -56,8 +56,7 @@ void CCSkeleton::initialize () {
|
|||
debugBones = false;
|
||||
timeScale = 1;
|
||||
|
||||
blendFunc.src = GL_ONE;
|
||||
blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
|
||||
setOpacityModifyRGB(true);
|
||||
|
||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||
|
|
|
@ -215,7 +215,7 @@ void Effect5::onExit()
|
|||
{
|
||||
EffectAdvanceTextLayer::onExit();
|
||||
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_3D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_3D);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
|
|
@ -81,7 +81,7 @@ SocketIOTestLayer::SocketIOTestLayer(void)
|
|||
menuRequest->addChild(itemTestEndpointDisconnect);
|
||||
|
||||
// Sahred Status Label
|
||||
_sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), Label::TEXT_ALIGNMENT_LEFT);
|
||||
_sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), Label::HAlignment::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), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
_sendTextStatus = LabelTTF::create("Send Text WS is waiting...", "Arial", 14, Size(160, 100), Label::HAlignment::CENTER, Label::VAlignment::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), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
_sendBinaryStatus = LabelTTF::create("Send Binary WS is waiting...", "Arial", 14, Size(160, 100), Label::HAlignment::CENTER, Label::VAlignment::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), Label::TEXT_ALIGNMENT_CENTER, Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
_errorStatus = LabelTTF::create("Error WS is waiting...", "Arial", 14, Size(160, 100), Label::HAlignment::CENTER, Label::VAlignment::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 Label::VerticalTextAlignment verticalAlignment[] =
|
||||
static Label::VAlignment verticalAlignment[] =
|
||||
{
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_TOP,
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_CENTER,
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM,
|
||||
Label::VAlignment::TOP,
|
||||
Label::VAlignment::CENTER,
|
||||
Label::VAlignment::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, Label::TEXT_ALIGNMENT_LEFT, verticalAlignment[vAlignIdx]);
|
||||
blockSize, Label::HAlignment::LEFT, verticalAlignment[vAlignIdx]);
|
||||
LabelTTF *center = LabelTTF::create("alignment center", pFont, fontSize,
|
||||
blockSize, Label::TEXT_ALIGNMENT_CENTER, verticalAlignment[vAlignIdx]);
|
||||
blockSize, Label::HAlignment::CENTER, verticalAlignment[vAlignIdx]);
|
||||
LabelTTF *right = LabelTTF::create("alignment right", pFont, fontSize,
|
||||
blockSize, Label::TEXT_ALIGNMENT_RIGHT, verticalAlignment[vAlignIdx]);
|
||||
blockSize, Label::HAlignment::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), Label::TEXT_ALIGNMENT_LEFT);
|
||||
Size(256, 32), Label::HAlignment::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), Label::TEXT_ALIGNMENT_CENTER);
|
||||
Size(245, 32), Label::HAlignment::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), Label::TEXT_ALIGNMENT_RIGHT);
|
||||
Size(245, 32), Label::HAlignment::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 = Label::TEXT_ALIGNMENT_LEFT;
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
|
||||
_horizAlign = Label::HAlignment::LEFT;
|
||||
_vertAlign = Label::VAlignment::TOP;
|
||||
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
@ -988,37 +988,37 @@ void LabelTTFTest::updateAlignment()
|
|||
|
||||
void LabelTTFTest::setAlignmentLeft(Object* pSender)
|
||||
{
|
||||
_horizAlign = Label::TEXT_ALIGNMENT_LEFT;
|
||||
_horizAlign = Label::HAlignment::LEFT;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentCenter(Object* pSender)
|
||||
{
|
||||
_horizAlign = Label::TEXT_ALIGNMENT_CENTER;
|
||||
_horizAlign = Label::HAlignment::CENTER;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentRight(Object* pSender)
|
||||
{
|
||||
_horizAlign = Label::TEXT_ALIGNMENT_RIGHT;
|
||||
_horizAlign = Label::HAlignment::RIGHT;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentTop(Object* pSender)
|
||||
{
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
|
||||
_vertAlign = Label::VAlignment::TOP;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentMiddle(Object* pSender)
|
||||
{
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_CENTER;
|
||||
_vertAlign = Label::VAlignment::CENTER;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
void LabelTTFTest::setAlignmentBottom(Object* pSender)
|
||||
{
|
||||
_vertAlign = Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM;
|
||||
_vertAlign = Label::VAlignment::BOTTOM;
|
||||
this->updateAlignment();
|
||||
}
|
||||
|
||||
|
@ -1027,24 +1027,24 @@ const char* LabelTTFTest::getCurrentAlignment()
|
|||
const char* vertical = NULL;
|
||||
const char* horizontal = NULL;
|
||||
switch (_vertAlign) {
|
||||
case Label::VERTICAL_TEXT_ALIGNMENT_TOP:
|
||||
case Label::VAlignment::TOP:
|
||||
vertical = "Top";
|
||||
break;
|
||||
case Label::VERTICAL_TEXT_ALIGNMENT_CENTER:
|
||||
case Label::VAlignment::CENTER:
|
||||
vertical = "Middle";
|
||||
break;
|
||||
case Label::VERTICAL_TEXT_ALIGNMENT_BOTTOM:
|
||||
case Label::VAlignment::BOTTOM:
|
||||
vertical = "Bottom";
|
||||
break;
|
||||
}
|
||||
switch (_horizAlign) {
|
||||
case Label::TEXT_ALIGNMENT_LEFT:
|
||||
case Label::HAlignment::LEFT:
|
||||
horizontal = "Left";
|
||||
break;
|
||||
case Label::TEXT_ALIGNMENT_CENTER:
|
||||
case Label::HAlignment::CENTER:
|
||||
horizontal = "Center";
|
||||
break;
|
||||
case Label::TEXT_ALIGNMENT_RIGHT:
|
||||
case Label::HAlignment::RIGHT:
|
||||
horizontal = "Right";
|
||||
break;
|
||||
}
|
||||
|
@ -1070,8 +1070,8 @@ LabelTTFMultiline::LabelTTFMultiline()
|
|||
"Paint Boy",
|
||||
32,
|
||||
Size(s.width/2,200),
|
||||
Label::TEXT_ALIGNMENT_CENTER,
|
||||
Label::VERTICAL_TEXT_ALIGNMENT_TOP);
|
||||
Label::HAlignment::CENTER,
|
||||
Label::VAlignment::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, Label::TEXT_ALIGNMENT_CENTER);
|
||||
this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, Label::HAlignment::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(Label::TEXT_ALIGNMENT_LEFT);
|
||||
this->_labelShouldRetain->setAlignment(Label::HAlignment::LEFT);
|
||||
break;
|
||||
case CenterAlign:
|
||||
this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_CENTER);
|
||||
this->_labelShouldRetain->setAlignment(Label::HAlignment::CENTER);
|
||||
break;
|
||||
case RightAlign:
|
||||
this->_labelShouldRetain->setAlignment(Label::TEXT_ALIGNMENT_RIGHT);
|
||||
this->_labelShouldRetain->setAlignment(Label::HAlignment::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, Label::TEXT_ALIGNMENT_LEFT, Point::ZERO);
|
||||
auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, Label::HAlignment::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, Label::TEXT_ALIGNMENT_LEFT, Point(0, 128));
|
||||
auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, Label::HAlignment::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, Label::TEXT_ALIGNMENT_LEFT);
|
||||
auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, Label::HAlignment::LEFT);
|
||||
addChild(label1);
|
||||
label1->setPosition(Point(s.width/2, s.height/5*4));
|
||||
|
||||
|
|
|
@ -191,8 +191,8 @@ private:
|
|||
const char* getCurrentAlignment();
|
||||
private:
|
||||
LabelTTF* _plabel;
|
||||
Label::TextAlignment _horizAlign;
|
||||
Label::VerticalTextAlignment _vertAlign;
|
||||
Label::HAlignment _horizAlign;
|
||||
Label::VAlignment _vertAlign;
|
||||
};
|
||||
|
||||
class LabelTTFMultiline : public AtlasDemo
|
||||
|
|
|
@ -858,10 +858,7 @@ LayerExtendedBlendOpacityTest::LayerExtendedBlendOpacityTest()
|
|||
layer3->setEndColor(Color3B(255, 0, 255));
|
||||
layer3->setStartOpacity(255);
|
||||
layer3->setEndOpacity(255);
|
||||
BlendFunc blend;
|
||||
blend.src = GL_SRC_ALPHA;
|
||||
blend.dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||
layer3->setBlendFunc(blend);
|
||||
layer3->setBlendFunc( BlendFunc::ALPHA_NON_PREMULTIPLIED );
|
||||
addChild(layer3);
|
||||
}
|
||||
|
||||
|
|
|
@ -512,12 +512,12 @@ std::string NodeToWorld::title()
|
|||
void CameraOrbitTest::onEnter()
|
||||
{
|
||||
TestCocosNodeDemo::onEnter();
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_3D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_3D);
|
||||
}
|
||||
|
||||
void CameraOrbitTest::onExit()
|
||||
{
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_2D);
|
||||
TestCocosNodeDemo::onExit();
|
||||
}
|
||||
|
||||
|
@ -584,12 +584,12 @@ void CameraZoomTest::onEnter()
|
|||
{
|
||||
TestCocosNodeDemo::onEnter();
|
||||
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_3D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_3D);
|
||||
}
|
||||
|
||||
void CameraZoomTest::onExit()
|
||||
{
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_2D);
|
||||
TestCocosNodeDemo::onExit();
|
||||
}
|
||||
|
||||
|
@ -797,8 +797,7 @@ NodeOpaqueTest::NodeOpaqueTest()
|
|||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
background = Sprite::create("Images/background1.png");
|
||||
BlendFunc blendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA};
|
||||
background->setBlendFunc(blendFunc);
|
||||
background->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
|
||||
background->setAnchorPoint(Point::ZERO);
|
||||
addChild(background);
|
||||
}
|
||||
|
@ -823,7 +822,7 @@ NodeNonOpaqueTest::NodeNonOpaqueTest()
|
|||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
background = Sprite::create("Images/background1.jpg");
|
||||
background->setBlendFunc(BlendFunc::BLEND_FUNC_DISABLE);
|
||||
background->setBlendFunc(BlendFunc::DISABLE);
|
||||
background->setAnchorPoint(Point::ZERO);
|
||||
addChild(background);
|
||||
}
|
||||
|
|
|
@ -1858,8 +1858,7 @@ void PremultipliedAlphaTest::onEnter()
|
|||
//this->emitter.blendFunc = (BlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };
|
||||
|
||||
// Cocos2d "normal" blend func for premul causes alpha to be ignored (oversaturates colors)
|
||||
BlendFunc tBlendFunc = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
|
||||
_emitter->setBlendFunc(tBlendFunc);
|
||||
_emitter->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
|
||||
|
||||
CCASSERT(_emitter->isOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless");
|
||||
|
||||
|
|
|
@ -202,17 +202,17 @@ void ParticleMainScene::createParticleSystem()
|
|||
switch( subtestNumber)
|
||||
{
|
||||
case 1:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 2:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 3:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 5:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
particleSystem->initWithTotalParticles(quantityParticles);
|
||||
particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png"));
|
||||
break;
|
||||
case 6:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_A8);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
}
|
||||
|
||||
void ParticleMainScene::testNCallback(Object* pSender)
|
||||
|
|
|
@ -67,36 +67,36 @@ void SubTest::initWithSubTest(int nSubTest, Node* p)
|
|||
break;
|
||||
///
|
||||
case 2:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
case 3:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
|
||||
///
|
||||
case 5:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
case 6:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
|
||||
batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
|
||||
///
|
||||
case 8:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100);
|
||||
p->addChild(batchNode, 0);
|
||||
break;
|
||||
case 9:
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_DEFAULT);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
||||
}
|
||||
|
||||
Sprite* SubTest::createSpriteWithTag(int tag)
|
||||
{
|
||||
// create
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
|
||||
|
||||
Sprite* sprite = NULL;
|
||||
switch (subtestNumber)
|
||||
|
@ -194,7 +194,7 @@ Sprite* SubTest::createSpriteWithTag(int tag)
|
|||
break;
|
||||
}
|
||||
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_DEFAULT);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
||||
|
||||
return sprite;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void TextureTest::performTestsPNG(const char* filename)
|
|||
TextureCache *cache = TextureCache::getInstance();
|
||||
|
||||
log("RGBA 8888");
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGB5A1);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGB565);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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, Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
_target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
|
||||
_target->retain();
|
||||
_target->setPosition(Point(s.width / 2, s.height / 2));
|
||||
|
||||
|
@ -243,7 +243,7 @@ RenderTextureIssue937::RenderTextureIssue937()
|
|||
|
||||
|
||||
/* A2 & B2 setup */
|
||||
RenderTexture *rend = RenderTexture::create(32, 64, Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
RenderTexture *rend = RenderTexture::create(32, 64, Texture2D::PixelFormat::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, Texture2D::PIXEL_FORMAT_RGBA4444, GL_DEPTH24_STENCIL8);
|
||||
RenderTexture *rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::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, Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
RenderTexture *renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::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, Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
rt->initWithWidthAndHeight(s.width, s.height, Texture2D::PixelFormat::RGBA8888);
|
||||
}
|
||||
rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
rt->end();
|
||||
|
|
|
@ -1 +1 @@
|
|||
4b0a077e077119ecd733b35f41231c3b6668d2f7
|
||||
65aa6a64b1eca738a6ddf151ab860c76eb5dd107
|
|
@ -1313,7 +1313,7 @@ void TexturePixelFormat::onEnter()
|
|||
addChild(background, -1);
|
||||
|
||||
// RGBA 8888 image (32-bit)
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGBA4444);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGB5A1);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGB888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_RGB565);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_A8);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Texture2D::PIXEL_FORMAT_DEFAULT);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT);
|
||||
TextureCache::getInstance()->dumpCachedTextureInfo();
|
||||
}
|
||||
|
||||
|
@ -1412,8 +1412,7 @@ void TextureBlend::onEnter()
|
|||
Sprite *cloud = Sprite::create("Images/test_blend.png");
|
||||
addChild(cloud, i+1, 100+i);
|
||||
cloud->setPosition(Point(50+25*i, 80));
|
||||
BlendFunc blendFunc1 = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
|
||||
cloud->setBlendFunc(blendFunc1);
|
||||
cloud->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
|
||||
|
||||
// CENTER sprites have also alpha pre-multiplied
|
||||
// they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
|
||||
|
@ -1937,7 +1936,7 @@ TexturePVRv3Premult::TexturePVRv3Premult()
|
|||
transformSprite(pvr2);
|
||||
|
||||
// PNG
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PIXEL_FORMAT_RGBA8888);
|
||||
Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::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(Director::PROJECTION_3D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_3D);
|
||||
}
|
||||
|
||||
void TMXOrthoTest::onExit()
|
||||
{
|
||||
Director::getInstance()->setProjection(Director::PROJECTION_2D);
|
||||
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(Director::PROJECTION_2D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_2D);
|
||||
}
|
||||
|
||||
void TMXIsoVertexZ::onExit()
|
||||
{
|
||||
// At exit use any other projection.
|
||||
// Director::getInstance()->setProjection:Director::PROJECTION_3D);
|
||||
// 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(Director::PROJECTION_2D);
|
||||
Director::getInstance()->setProjection(Director::Projection::_2D);
|
||||
}
|
||||
|
||||
void TMXOrthoVertexZ::onExit()
|
||||
{
|
||||
// At exit use any other projection.
|
||||
// Director::getInstance()->setProjection:Director::PROJECTION_3D);
|
||||
// Director::getInstance()->setProjection:Director::Projection::_3D);
|
||||
TileDemo::onExit();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// initialize director
|
||||
Director *pDirector = Director::getInstance();
|
||||
pDirector->setOpenGLView(EGLView::getInstance());
|
||||
pDirector->setProjection(Director::PROJECTION_2D);
|
||||
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(Director::PROJECTION_2D);
|
||||
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(Director::PROJECTION_2D);
|
||||
pDirector->setProjection(Director::Projection::_2D);
|
||||
|
||||
// Set the design resolution
|
||||
EGLView::getInstance()->setDesignResolutionSize(320, 480, kResolutionShowAll);
|
||||
|
|
|
@ -2245,8 +2245,8 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out )
|
|||
// defaul values
|
||||
const char * defautlFontName = "Arial";
|
||||
const int defaultFontSize = 32;
|
||||
Label::TextAlignment defaultTextAlignment = Label::TEXT_ALIGNMENT_LEFT;
|
||||
Label::VerticalTextAlignment defaultTextVAlignment = Label::VERTICAL_TEXT_ALIGNMENT_TOP;
|
||||
Label::HAlignment defaultTextAlignment = Label::HAlignment::LEFT;
|
||||
Label::VAlignment defaultTextVAlignment = Label::VAlignment::TOP;
|
||||
|
||||
// by default shadow and stroke are off
|
||||
out->_shadow._shadowEnabled = false;
|
||||
|
@ -2291,7 +2291,7 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out )
|
|||
JS_GetProperty(cx, jsobj, "fontAlignmentH", &jsr);
|
||||
double fontAlign = 0.0;
|
||||
JS_ValueToNumber(cx, jsr, &fontAlign);
|
||||
out->_alignment = (Label::TextAlignment)(int)fontAlign;
|
||||
out->_alignment = (Label::HAlignment)(int)fontAlign;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2305,7 +2305,7 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out )
|
|||
JS_GetProperty(cx, jsobj, "fontAlignmentV", &jsr);
|
||||
double fontAlign = 0.0;
|
||||
JS_ValueToNumber(cx, jsr, &fontAlign);
|
||||
out->_vertAlignment = (Label::VerticalTextAlignment)(int)fontAlign;
|
||||
out->_vertAlignment = (Label::VAlignment)(int)fontAlign;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1 +1 @@
|
|||
bfb95e6faa9b59a5045353dffbae4d7cad7d6655
|
||||
288a9a5c2ae9cb49d05ad4eca98a109b111b381b
|
Loading…
Reference in New Issue