mirror of https://github.com/axmolengine/axmol.git
alias backend::SamplerDescriptor
This commit is contained in:
parent
53975ee428
commit
1d0107c087
|
@ -320,8 +320,8 @@ CameraBackgroundSkyBoxBrush* CameraBackgroundSkyBoxBrush::create(
|
|||
Texture2D::TexParams tRepeatParams;
|
||||
tRepeatParams.magFilter = backend::SamplerFilter::LINEAR;
|
||||
tRepeatParams.minFilter = backend::SamplerFilter::LINEAR;
|
||||
tRepeatParams.wrapS = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
tRepeatParams.wrapT = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
tRepeatParams.sAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
tRepeatParams.tAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
texture->setTexParameters(tRepeatParams);
|
||||
|
||||
ret = new (std::nothrow) CameraBackgroundSkyBoxBrush;
|
||||
|
|
|
@ -392,8 +392,8 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c
|
|||
Texture2D::TexParams texParams;
|
||||
texParams.minFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.magFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.wrapS = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.wrapT = utils::toBackendAddressMode(textureData->wrapT);
|
||||
texParams.sAddressMode = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.tAddressMode = utils::toBackendAddressMode(textureData->wrapT);
|
||||
tex->setTexParameters(texParams);
|
||||
mesh->_isTransparent = (materialData->getTextureData(NTextureData::Usage::Transparency) != nullptr);
|
||||
}
|
||||
|
@ -407,8 +407,8 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c
|
|||
Texture2D::TexParams texParams;
|
||||
texParams.minFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.magFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.wrapS = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.wrapT = utils::toBackendAddressMode(textureData->wrapT);
|
||||
texParams.sAddressMode = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.tAddressMode = utils::toBackendAddressMode(textureData->wrapT);
|
||||
tex->setTexParameters(texParams);
|
||||
}
|
||||
mesh->setTexture(tex, NTextureData::Usage::Normal);
|
||||
|
@ -557,8 +557,8 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m
|
|||
Texture2D::TexParams texParams;
|
||||
texParams.minFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.magFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.wrapS = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.wrapT = utils::toBackendAddressMode(textureData->wrapT);
|
||||
texParams.sAddressMode = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.tAddressMode = utils::toBackendAddressMode(textureData->wrapT);
|
||||
tex->setTexParameters(texParams);
|
||||
mesh->_isTransparent = (materialData->getTextureData(NTextureData::Usage::Transparency) != nullptr);
|
||||
}
|
||||
|
@ -572,8 +572,8 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m
|
|||
Texture2D::TexParams texParams;
|
||||
texParams.minFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.magFilter = backend::SamplerFilter::LINEAR;
|
||||
texParams.wrapS = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.wrapT = utils::toBackendAddressMode(textureData->wrapT);
|
||||
texParams.sAddressMode = utils::toBackendAddressMode(textureData->wrapS);
|
||||
texParams.tAddressMode = utils::toBackendAddressMode(textureData->wrapT);
|
||||
tex->setTexParameters(texParams);
|
||||
}
|
||||
mesh->setTexture(tex, NTextureData::Usage::Normal);
|
||||
|
|
|
@ -91,8 +91,8 @@ void cocos2d::Terrain::setLightMap(const std::string& fileName)
|
|||
|
||||
Texture2D::TexParams tRepeatParams;//set texture parameters
|
||||
tRepeatParams.magFilter = tRepeatParams.minFilter = backend::SamplerFilter::LINEAR;
|
||||
tRepeatParams.wrapS = backend::SamplerAddressMode::REPEAT;
|
||||
tRepeatParams.wrapT = backend::SamplerAddressMode::REPEAT;
|
||||
tRepeatParams.sAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
tRepeatParams.tAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
_lightMap->setTexParameters(tRepeatParams);
|
||||
|
||||
}
|
||||
|
@ -824,8 +824,8 @@ bool Terrain::initTextures()
|
|||
}
|
||||
|
||||
Texture2D::TexParams texParam;
|
||||
texParam.wrapS = backend::SamplerAddressMode::REPEAT;
|
||||
texParam.wrapT = backend::SamplerAddressMode::REPEAT;
|
||||
texParam.sAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
texParam.tAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
if (_terrainData._alphaMapSrc.empty())
|
||||
{
|
||||
auto textImage = new (std::nothrow)Image();
|
||||
|
@ -846,8 +846,8 @@ bool Terrain::initTextures()
|
|||
image->initWithImageFile(_terrainData._alphaMapSrc);
|
||||
_alphaMap = new (std::nothrow)Texture2D();
|
||||
_alphaMap->initWithImage(image);
|
||||
texParam.wrapS = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
texParam.wrapT = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
texParam.sAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
texParam.tAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
texParam.minFilter = backend::SamplerFilter::LINEAR;
|
||||
texParam.magFilter = backend::SamplerFilter::LINEAR;
|
||||
_alphaMap->setTexParameters(texParam);
|
||||
|
@ -863,8 +863,8 @@ bool Terrain::initTextures()
|
|||
texture->generateMipmap();
|
||||
_detailMapTextures[i] = texture;
|
||||
|
||||
texParam.wrapS = backend::SamplerAddressMode::REPEAT;
|
||||
texParam.wrapT = backend::SamplerAddressMode::REPEAT;
|
||||
texParam.sAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
texParam.tAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
texParam.minFilter = backend::SamplerFilter::LINEAR;
|
||||
texParam.magFilter = backend::SamplerFilter::LINEAR;
|
||||
texture->setTexParameters(texParam);
|
||||
|
|
|
@ -253,9 +253,9 @@ bool Material::parseSampler(backend::ProgramState* programState, Properties* sam
|
|||
// valid options: REPEAT, CLAMP
|
||||
const char* wrapS = getOptionalString(samplerProperties, "wrapS", "CLAMP_TO_EDGE");
|
||||
if (strcasecmp(wrapS, "REPEAT")==0)
|
||||
texParams.wrapS = backend::SamplerAddressMode::REPEAT;
|
||||
texParams.sAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
else if(strcasecmp(wrapS, "CLAMP_TO_EDGE")==0)
|
||||
texParams.wrapS = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
texParams.sAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
else
|
||||
CCLOG("Invalid wrapS: %s", wrapS);
|
||||
|
||||
|
@ -263,9 +263,9 @@ bool Material::parseSampler(backend::ProgramState* programState, Properties* sam
|
|||
// valid options: REPEAT, CLAMP
|
||||
const char* wrapT = getOptionalString(samplerProperties, "wrapT", "CLAMP_TO_EDGE");
|
||||
if (strcasecmp(wrapT, "REPEAT")==0)
|
||||
texParams.wrapT = backend::SamplerAddressMode::REPEAT;
|
||||
texParams.tAddressMode = backend::SamplerAddressMode::REPEAT;
|
||||
else if(strcasecmp(wrapT, "CLAMP_TO_EDGE")==0)
|
||||
texParams.wrapT = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
texParams.tAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
else
|
||||
CCLOG("Invalid wrapT: %s", wrapT);
|
||||
|
||||
|
|
|
@ -908,19 +908,7 @@ Texture2D* Texture2D::getAlphaTexture() const
|
|||
return _alphaTexture;
|
||||
}
|
||||
|
||||
void Texture2D::setTexParameters(const Texture2D::TexParams ¶ms)
|
||||
{
|
||||
backend::SamplerDescriptor sd;
|
||||
sd.mipmapEnabled = true;
|
||||
sd.mipmapFilter = backend::SamplerFilter::DONT_CARE;
|
||||
sd.minFilter = params.minFilter;
|
||||
sd.magFilter = params.magFilter;
|
||||
sd.sAddressMode = params.wrapS;
|
||||
sd.tAddressMode = params.wrapT;
|
||||
_texture->updateSamplerDescriptor(sd);
|
||||
}
|
||||
|
||||
void Texture2D::setTexParameters(const backend::SamplerDescriptor &desc)
|
||||
void Texture2D::setTexParameters(const Texture2D::TexParams &desc)
|
||||
{
|
||||
_texture->updateSamplerDescriptor(desc);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CCTEXTURE2D_H__
|
||||
#define __CCTEXTURE2D_H__
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
@ -153,23 +152,9 @@ public:
|
|||
typedef std::map<Texture2D::PixelFormat, const PixelFormatInfo> PixelFormatInfoMap;
|
||||
|
||||
/**
|
||||
Extension to set the Min / Mag filter
|
||||
* Extension to set the Min / Mag filter
|
||||
*/
|
||||
struct TexParams {
|
||||
backend::SamplerFilter minFilter;
|
||||
backend::SamplerFilter magFilter;
|
||||
backend::SamplerAddressMode wrapS;
|
||||
backend::SamplerAddressMode wrapT;
|
||||
bool mipmapEnabled = true;
|
||||
backend::SamplerFilter mipmapFilter = backend::SamplerFilter::LINEAR;
|
||||
|
||||
TexParams(backend::SamplerFilter _minFilter, backend::SamplerFilter _magFilter,
|
||||
backend::SamplerAddressMode _wrapS, backend::SamplerAddressMode _wrapT)
|
||||
:minFilter(_minFilter), magFilter(_magFilter), wrapS(_wrapS), wrapT(_wrapT)
|
||||
{}
|
||||
|
||||
TexParams() = default;
|
||||
};
|
||||
using TexParams = backend::SamplerDescriptor;
|
||||
|
||||
public:
|
||||
/** sets the default pixel format for UIImagescontains alpha channel.
|
||||
|
@ -311,7 +296,6 @@ public:
|
|||
|
||||
|
||||
void setTexParameters(const TexParams ¶ms);
|
||||
void setTexParameters(const backend::SamplerDescriptor &desc);
|
||||
|
||||
/** Generates mipmap images for the texture.
|
||||
It only works if the texture size is POT (power of 2).
|
||||
|
@ -495,6 +479,3 @@ protected:
|
|||
/// @}
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif //__CCTEXTURE2D_H__
|
||||
|
||||
|
|
|
@ -292,14 +292,7 @@ bool TextureCube::init(const std::string& positive_x, const std::string& negativ
|
|||
|
||||
void TextureCube::setTexParameters(const Texture2D::TexParams& texParams)
|
||||
{
|
||||
backend::SamplerDescriptor samplerDescriptor;
|
||||
samplerDescriptor.mipmapEnabled = true;
|
||||
samplerDescriptor.mipmapFilter = backend::SamplerFilter::LINEAR;
|
||||
samplerDescriptor.minFilter = texParams.minFilter;
|
||||
samplerDescriptor.magFilter = texParams.magFilter;
|
||||
samplerDescriptor.tAddressMode = texParams.wrapT;
|
||||
samplerDescriptor.sAddressMode = texParams.wrapS;
|
||||
_texture->updateSamplerDescriptor(samplerDescriptor);
|
||||
_texture->updateSamplerDescriptor(texParams);
|
||||
}
|
||||
|
||||
bool TextureCube::reloadTexture()
|
||||
|
|
|
@ -188,21 +188,32 @@ enum class ColorWriteMask: uint32_t
|
|||
|
||||
struct SamplerDescriptor
|
||||
{
|
||||
bool mipmapEnabled = false;
|
||||
bool mipmapEnabled = true;
|
||||
SamplerFilter magFilter = SamplerFilter::LINEAR;
|
||||
SamplerFilter minFilter = SamplerFilter::LINEAR;
|
||||
SamplerFilter mipmapFilter = SamplerFilter::LINEAR;
|
||||
SamplerAddressMode sAddressMode = SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
SamplerAddressMode tAddressMode = SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
|
||||
SamplerDescriptor(bool _mipmapEnabled = false,
|
||||
SamplerFilter _magFilter = SamplerFilter::LINEAR,
|
||||
SamplerFilter _minFilter = SamplerFilter::LINEAR,
|
||||
SamplerFilter _mipmapFilter = SamplerFilter::LINEAR,
|
||||
SamplerAddressMode _sAddressMode = SamplerAddressMode::CLAMP_TO_EDGE,
|
||||
SamplerAddressMode _tAddressMode = SamplerAddressMode::CLAMP_TO_EDGE
|
||||
SamplerDescriptor() {}
|
||||
|
||||
SamplerDescriptor(
|
||||
SamplerFilter _magFilter,
|
||||
SamplerFilter _minFilter,
|
||||
SamplerAddressMode _sAddressMode,
|
||||
SamplerAddressMode _tAddressMode
|
||||
) : magFilter(_magFilter), minFilter(_minFilter),
|
||||
sAddressMode(_sAddressMode), tAddressMode(_tAddressMode) {}
|
||||
|
||||
SamplerDescriptor(bool _mipmapEnabled,
|
||||
SamplerFilter _magFilter,
|
||||
SamplerFilter _minFilter,
|
||||
SamplerFilter _mipmapFilter,
|
||||
SamplerAddressMode _sAddressMode,
|
||||
SamplerAddressMode _tAddressMode
|
||||
) :mipmapEnabled(_mipmapEnabled), magFilter(_magFilter), minFilter(_minFilter),
|
||||
mipmapFilter(_mipmapFilter), sAddressMode(_sAddressMode), tAddressMode(_tAddressMode) {}
|
||||
|
||||
};
|
||||
|
||||
enum class CullMode: uint32_t
|
||||
|
|
|
@ -3178,10 +3178,10 @@ void texParams_to_luaval(lua_State* L, const cocos2d::Texture2D::TexParams& inVa
|
|||
lua_pushnumber(L, (lua_Number) inValue.magFilter); /* L: table key value*/
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "wrapS"); /* L: table key */
|
||||
lua_pushnumber(L, (lua_Number) inValue.wrapS); /* L: table key value*/
|
||||
lua_pushnumber(L, (lua_Number) inValue.sAddressMode); /* L: table key value*/
|
||||
lua_rawset(L, -3);
|
||||
lua_pushstring(L, "wrapT"); /* L: table key */
|
||||
lua_pushnumber(L, (lua_Number) inValue.wrapT); /* L: table key value*/
|
||||
lua_pushnumber(L, (lua_Number) inValue.tAddressMode); /* L: table key value*/
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
|
|
|
@ -395,8 +395,8 @@ void Scene3DTestScene::createWorld3D()
|
|||
Texture2D::TexParams tRepeatParams;
|
||||
tRepeatParams.magFilter = GL_LINEAR;
|
||||
tRepeatParams.minFilter = GL_LINEAR;
|
||||
tRepeatParams.wrapS = GL_MIRRORED_REPEAT;
|
||||
tRepeatParams.wrapT = GL_MIRRORED_REPEAT;
|
||||
tRepeatParams.sAddressMode = GL_MIRRORED_REPEAT;
|
||||
tRepeatParams.tAddressMode = GL_MIRRORED_REPEAT;
|
||||
_textureCube->setTexParameters(tRepeatParams);
|
||||
|
||||
// pass the texture sampler to our custom shader
|
||||
|
|
|
@ -2113,8 +2113,8 @@ void Sprite3DCubeMapTest::addNewSpriteWithCoords(Vec2 p)
|
|||
Texture2D::TexParams tRepeatParams;
|
||||
tRepeatParams.magFilter = backend::SamplerFilter::LINEAR;
|
||||
tRepeatParams.minFilter = backend::SamplerFilter::LINEAR;
|
||||
tRepeatParams.wrapS = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
tRepeatParams.wrapT = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
tRepeatParams.sAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
tRepeatParams.tAddressMode = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
_textureCube->setTexParameters(tRepeatParams);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue