cocos2d-x-3.2 不能混合颜色修改
2014-09-15 14:29
232 查看
1.cocos/editor-support/cocostudio/CCArmature.cpp
125行
bool Armature::init(const std::string& name)
{
bool bRet = false;
do
{
removeAllChildren();
CC_SAFE_DELETE(_animation);
_animation = new ArmatureAnimation();
_animation->init(this);
_boneDic.clear();
_topBoneList.clear();
- _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
+ _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
_name = name;
@@ -404,13 +404,20 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t
BlendFunc func = bone->getBlendFunc();
- if (func.src != _blendFunc.src || func.dst != _blendFunc.dst)
+ if (func.src != BlendFunc::ALPHA_PREMULTIPLIED.src || func.dst != BlendFunc::ALPHA_PREMULTIPLIED.dst)
{
skin->setBlendFunc(bone->getBlendFunc());
}
else
{
- skin->setBlendFunc(_blendFunc);
+ if (_blendFunc == BlendFunc::ALPHA_PREMULTIPLIED && !skin->getTexture()->hasPremultipliedAlpha())
+ {
+ skin->setBlendFunc(_blendFunc.ALPHA_NON_PREMULTIPLIED);
+ }
+ else
+ {
+ skin->setBlendFunc(_blendFunc);
+ }
}
skin->draw(renderer, transform, flags);
}
cocos/editor-support/cocostudio/CCBone.cpp
74行
// _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0);
_worldTransform = Mat4::IDENTITY;
_boneTransformDirty = true;
- _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
+ _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
_blendDirty = false;
_worldInfo = nullptr;
cocos/editor-support/cocostudio/CCDataReaderHelper.cpp
1050行
{
case BLEND_NORMAL:
{
- frameData->blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
+ frameData->blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
}
break;
case BLEND_ADD:
@@ -1614,8 +1614,8 @@ FrameData *DataReaderHelper::decodeFrame(const rapidjson::Value& json, DataInfo
frameData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, cocos2d::tweenfunc::Linear));
frameData->displayIndex = DICTOOL->getIntValue_json(json, A_DISPLAY_INDEX);
- frameData->blendFunc.src = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_SRC, BlendFunc::ALPHA_NON_PREMULTIPLIED.src));
- frameData->blendFunc.dst = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_DST, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst));
+ frameData->blendFunc.src = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_SRC, BlendFunc::ALPHA_PREMULTIPLIED.src));
+ frameData->blendFunc.dst = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_DST, BlendFunc::ALPHA_PREMULTIPLIED.dst));
frameData->isTween = DICTOOL->getBooleanValue_json(json, A_TWEEN_FRAME, true);
const char *event = DICTOOL->getStringValue_json(json, A_EVENT);
2 cocos/editor-support/cocostudio/CCDatas.cpp
254行
, easingParams(nullptr)
, isTween(true)
, displayIndex(0)
- , blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
+ , blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
, strEvent("")
, strMovement("")
125行
bool Armature::init(const std::string& name)
{
bool bRet = false;
do
{
removeAllChildren();
CC_SAFE_DELETE(_animation);
_animation = new ArmatureAnimation();
_animation->init(this);
_boneDic.clear();
_topBoneList.clear();
- _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
+ _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
_name = name;
@@ -404,13 +404,20 @@ void Armature::draw(cocos2d::Renderer *renderer, const Mat4 &transform, uint32_t
BlendFunc func = bone->getBlendFunc();
- if (func.src != _blendFunc.src || func.dst != _blendFunc.dst)
+ if (func.src != BlendFunc::ALPHA_PREMULTIPLIED.src || func.dst != BlendFunc::ALPHA_PREMULTIPLIED.dst)
{
skin->setBlendFunc(bone->getBlendFunc());
}
else
{
- skin->setBlendFunc(_blendFunc);
+ if (_blendFunc == BlendFunc::ALPHA_PREMULTIPLIED && !skin->getTexture()->hasPremultipliedAlpha())
+ {
+ skin->setBlendFunc(_blendFunc.ALPHA_NON_PREMULTIPLIED);
+ }
+ else
+ {
+ skin->setBlendFunc(_blendFunc);
+ }
}
skin->draw(renderer, transform, flags);
}
cocos/editor-support/cocostudio/CCBone.cpp
74行
// _worldTransform = AffineTransformMake(1, 0, 0, 1, 0, 0);
_worldTransform = Mat4::IDENTITY;
_boneTransformDirty = true;
- _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
+ _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
_blendDirty = false;
_worldInfo = nullptr;
cocos/editor-support/cocostudio/CCDataReaderHelper.cpp
1050行
{
case BLEND_NORMAL:
{
- frameData->blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
+ frameData->blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
}
break;
case BLEND_ADD:
@@ -1614,8 +1614,8 @@ FrameData *DataReaderHelper::decodeFrame(const rapidjson::Value& json, DataInfo
frameData->tweenEasing = (TweenType)(DICTOOL->getIntValue_json(json, A_TWEEN_EASING, cocos2d::tweenfunc::Linear));
frameData->displayIndex = DICTOOL->getIntValue_json(json, A_DISPLAY_INDEX);
- frameData->blendFunc.src = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_SRC, BlendFunc::ALPHA_NON_PREMULTIPLIED.src));
- frameData->blendFunc.dst = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_DST, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst));
+ frameData->blendFunc.src = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_SRC, BlendFunc::ALPHA_PREMULTIPLIED.src));
+ frameData->blendFunc.dst = (GLenum)(DICTOOL->getIntValue_json(json, A_BLEND_DST, BlendFunc::ALPHA_PREMULTIPLIED.dst));
frameData->isTween = DICTOOL->getBooleanValue_json(json, A_TWEEN_FRAME, true);
const char *event = DICTOOL->getStringValue_json(json, A_EVENT);
2 cocos/editor-support/cocostudio/CCDatas.cpp
254行
, easingParams(nullptr)
, isTween(true)
, displayIndex(0)
- , blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
+ , blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
, strEvent("")
, strMovement("")
相关文章推荐
- Ext Js 3.2修改文本颜色和在表格中插入图片,主要是性别进行判断来选择图片
- Cocos2d中使用颜色混合:加算,减算
- Cocos2d-x v3.3的颜色混合BlendFunc
- cocos2d-x 颜色混合
- cocos2d 颜色混合 ccBlendFunc 使用方法
- 修改 MrBayes 3.2 源码解决不能恢复断点的问题
- 【cocos2d-x 2.x 学习与应用总结】14: 自定义shader绘制混合颜色的矩形
- Cocos2d-x v3.X的颜色混合BlendFunc使用详解
- Cocos2d-x3.3的的颜色混合BlendFunc
- ActionBar 不能显示logo 的问题 ,背景颜色的修改, 以及ActionBar 的官方guide
- cocos2d-x 颜色混合
- cocos2d-x 颜色混合
- cocos2d-x 3.2 创建项目 Vec2等不能用的解决方案
- cocos2d-x 颜色混合
- 修改Cocos2d-X-3.2中的setup.py, 使其能用python3
- Ext 3.2 修改列的颜色
- cocos2d-x 颜色混合
- Cocos2d中使用颜色混合:加算,减算
- cocos2d-x颜色混合模式完成光照效果
- cocos2dx[3.2](15)——颜色混合BlendFunc