fix android error

This commit is contained in:
patricejiang 2019-03-13 09:56:29 +08:00
parent fb87eec3f5
commit 53975ee428
No known key found for this signature in database
GPG Key ID: 301C66D10A4E92C3
4 changed files with 20 additions and 7 deletions

View File

@ -920,6 +920,11 @@ void Texture2D::setTexParameters(const Texture2D::TexParams &params)
_texture->updateSamplerDescriptor(sd);
}
void Texture2D::setTexParameters(const backend::SamplerDescriptor &desc)
{
_texture->updateSamplerDescriptor(desc);
}
// TODO coulsonwang
//// implementation Texture2D (GLFilter)
void Texture2D::generateMipmap()

View File

@ -155,14 +155,21 @@ public:
/**
Extension to set the Min / Mag filter
*/
typedef struct _TexParams {
struct TexParams {
backend::SamplerFilter minFilter;
backend::SamplerFilter magFilter;
backend::SamplerAddressMode wrapS;
backend::SamplerAddressMode wrapT;
bool mipmapEnabled = true;
backend::SamplerFilter mipmapFilter = backend::SamplerFilter::LINEAR;
}TexParams;
TexParams(backend::SamplerFilter _minFilter, backend::SamplerFilter _magFilter,
backend::SamplerAddressMode _wrapS, backend::SamplerAddressMode _wrapT)
:minFilter(_minFilter), magFilter(_magFilter), wrapS(_wrapS), wrapT(_wrapT)
{}
TexParams() = default;
};
public:
/** sets the default pixel format for UIImagescontains alpha channel.
@ -304,7 +311,8 @@ public:
void setTexParameters(const TexParams &params);
void setTexParameters(const backend::SamplerDescriptor &desc);
/** Generates mipmap images for the texture.
It only works if the texture size is POT (power of 2).
@since v0.99.0

View File

@ -887,7 +887,7 @@ void VolatileTextureMgr::reloadAllTextures()
if (vt->_hasMipmaps) {
vt->_texture->generateMipmap();
}
vt->_texture->setSamplerDescriptor(vt->_samplerDescriptor);
vt->_texture->setTexParameters(vt->_samplerDescriptor);
}
_isReloading = false;

View File

@ -1592,12 +1592,12 @@ void TextureGlClamp::onEnter()
auto sprite = Sprite::create("Images/pattern1.png", Rect(0,0,512,256));
addChild(sprite, -1, kTagSprite1);
sprite->setPosition(Vec2(size.width/2,size.height/2));
Texture2D::TexParams texParams= {
Texture2D::TexParams texParams(
backend::SamplerFilter::LINEAR,
backend::SamplerFilter::LINEAR,
backend::SamplerAddressMode::CLAMP_TO_EDGE,
backend::SamplerAddressMode::CLAMP_TO_EDGE,
};
backend::SamplerAddressMode::CLAMP_TO_EDGE
);
sprite->getTexture()->setTexParameters(texParams);
auto rotate = RotateBy::create(4, 360);
sprite->runAction(rotate);