mirror of https://github.com/axmolengine/axmol.git
Merge pull request #11636 from super626/v3.6
fix bug some 3d sprite crash when texture missing on release mode
This commit is contained in:
commit
37c9a9cb98
|
@ -645,14 +645,18 @@ void Sprite3D::removeAllAttachNode()
|
|||
}
|
||||
_attachments.clear();
|
||||
}
|
||||
#if (!defined NDEBUG) || (defined CC_MODEL_VIEWER)
|
||||
|
||||
//Generate a dummy texture when the texture file is missing
|
||||
static Texture2D * getDummyTexture()
|
||||
{
|
||||
auto texture = Director::getInstance()->getTextureCache()->getTextureForKey("/dummyTexture");
|
||||
if(!texture)
|
||||
{
|
||||
#if (!defined NDEBUG)
|
||||
unsigned char data[] ={0,0,0,0};//1*1 pure red picture
|
||||
#else
|
||||
unsigned char data[] ={255,0,0,255};//1*1 pure red picture
|
||||
#endif
|
||||
Image * image =new (std::nothrow) Image();
|
||||
image->initWithRawData(data,sizeof(data),1,1,sizeof(unsigned char));
|
||||
texture=Director::getInstance()->getTextureCache()->addImage(image,"/dummyTexture");
|
||||
|
@ -660,7 +664,6 @@ static Texture2D * getDummyTexture()
|
|||
}
|
||||
return texture;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Sprite3D::visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
|
@ -749,7 +752,6 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
auto programstate = mesh->getGLProgramState();
|
||||
auto& meshCommand = mesh->getMeshCommand();
|
||||
|
||||
#if (!defined NDEBUG) || (defined CC_MODEL_VIEWER)
|
||||
GLuint textureID = 0;
|
||||
if(mesh->getTexture())
|
||||
{
|
||||
|
@ -761,10 +763,6 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
textureID = texture->getName();
|
||||
}
|
||||
|
||||
#else
|
||||
GLuint textureID = mesh->getTexture() ? mesh->getTexture()->getName() : 0;
|
||||
#endif
|
||||
|
||||
bool isTransparent = (mesh->_isTransparent || color.a < 1.f);
|
||||
float globalZ = isTransparent ? 0 : _globalZOrder;
|
||||
if (isTransparent)
|
||||
|
|
Loading…
Reference in New Issue