本文整理汇总了C++中osg::StateSet::setTextureAttributeAndModes方法的典型用法代码示例。如果您正苦于以下问题:C++ StateSet::setTextureAttributeAndModes方法的具体用法?C++ StateSet::setTextureAttributeAndModes怎么用?C++ StateSet::setTextureAttributeAndModes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::StateSet
的用法示例。
在下文中一共展示了StateSet::setTextureAttributeAndModes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTextureCubeMap
void test::createTextureCubeMap(osg::StateSet& ss)
{
osg::ref_ptr<osg::TextureCubeMap> texture=new osg::TextureCubeMap;
texture->setImage(osg::TextureCubeMap::POSITIVE_X,
osgDB::readImageFile(std::string(OSGFilePath)+std::string("/Cubemap_snow/posx.jpg")));
texture->setImage(osg::TextureCubeMap::NEGATIVE_X,
osgDB::readImageFile(std::string(OSGFilePath)+std::string("/Cubemap_snow/negx.jpg")));
texture->setImage(osg::TextureCubeMap::POSITIVE_Y,
osgDB::readImageFile(std::string(OSGFilePath)+std::string("/Cubemap_snow/posy.jpg")));
texture->setImage(osg::TextureCubeMap::NEGATIVE_Y,
osgDB::readImageFile(std::string(OSGFilePath)+std::string("/Cubemap_snow/negy.jpg")));
texture->setImage(osg::TextureCubeMap::POSITIVE_Z,
osgDB::readImageFile(std::string(OSGFilePath)+std::string("/Cubemap_snow/posz.jpg")));
texture->setImage(osg::TextureCubeMap::NEGATIVE_Z,
osgDB::readImageFile(std::string(OSGFilePath)+std::string("/Cubemap_snow/negz.jpg")));
texture->setWrap(osg::Texture::WRAP_S,
osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_T,
osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_R,
osg::Texture::CLAMP_TO_EDGE);
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
ss.setTextureAttributeAndModes(0,texture.get());
ss.setTextureAttributeAndModes(0,new osg::TexGen);
}
示例2:
void test::createTexture2D(osg::StateSet& ss)
{
osg::ref_ptr<osg::Texture2D> texture=new osg::Texture2D;
texture->setImage(osgDB::readImageFile(std::string(OSGFilePath)+std::string("/Images/clockface.jpg")));
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_BORDER);
texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_BORDER);
texture->setBorderColor(osg::Vec4(1,1,0,1));
ss.setTextureAttributeAndModes(0,texture.get());
}
示例3: createTexture2D
void createTexture2D( osg::StateSet& ss, bool useCustomizedData )
{
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
if ( useCustomizedData ) texture->setImage( createCustomMipmap(32) );
else texture->setImage( createInternalMipmap(32) );
texture->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
texture->setFilter( osg::Texture::MAG_FILTER, osg::Texture::LINEAR );
texture->setWrap( osg::Texture::WRAP_S, osg::Texture::REPEAT );
texture->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT );
ss.setTextureAttributeAndModes( 0, texture.get(), osg::StateAttribute::ON );
}
示例4: AttachToRenderState
void ShaderParamTextureCubeMap::AttachToRenderState(osg::StateSet &stateSet)
{
dtCore::RefPtr<osg::TextureCubeMap> texCube;
if (GetTexture().empty() && GetTextureSourceType() != ShaderParamTexture::TextureSourceType::AUTO)
{
throw dtUtil::Exception(ShaderParameterException::INVALID_ATTRIBUTE,"Cannot attach to render state. Texture "
"for parameter " + GetName() + " has not been specified.", __FILE__, __LINE__);
}
osg::Uniform *uniform = NULL;
if (IsShared())
uniform = GetUniformParam();
// Create a new one if unshared or if shared but not set yet
if (uniform == NULL)
{
uniform = new osg::Uniform(osg::Uniform::SAMPLER_CUBE,GetName());
uniform->set((int)GetTextureUnit());
SetUniformParam(*uniform);
}
stateSet.addUniform(uniform);
// Load (if necessary) and Set the Tex cube map on the StateSet
if(GetTextureSourceType() == ShaderParamTexture::TextureSourceType::CUBEMAP_IMAGE_POSITIVE_X ||
GetTextureSourceType() == ShaderParamTexture::TextureSourceType::CUBEMAP_IMAGE_NEGATIVE_X ||
GetTextureSourceType() == ShaderParamTexture::TextureSourceType::CUBEMAP_IMAGE_POSITIVE_Y ||
GetTextureSourceType() == ShaderParamTexture::TextureSourceType::CUBEMAP_IMAGE_NEGATIVE_Y ||
GetTextureSourceType() == ShaderParamTexture::TextureSourceType::CUBEMAP_IMAGE_POSITIVE_Z ||
GetTextureSourceType() == ShaderParamTexture::TextureSourceType::CUBEMAP_IMAGE_NEGATIVE_Z
)
{
texCube = static_cast<osg::TextureCubeMap*>(GetTextureObject());
// load or reload the image - allows caching from the template
// Note - ImageSourceDirty may not be relevant anymore cause it now loads the image when you call SetTexture().
// note - If shared, load only happens the first time it is assigned.
// check only if face 0 exists. Is this sufficient?
if (texCube->getImage(osg::TextureCubeMap::POSITIVE_X) == NULL || IsImageSourceDirty())
{
LoadImage();
ApplyTextureCubeMapValues();
}
//Assign the completed texture attribute to the render state.
stateSet.setTextureAttributeAndModes(GetTextureUnit(), texCube.get(), osg::StateAttribute::ON);
}
SetDirty(false);
}
示例5: DetachFromRenderState
void ShaderParamTextureCubeMap::DetachFromRenderState(osg::StateSet &stateSet)
{
osg::TextureCubeMap *texCube = static_cast<osg::TextureCubeMap*>(GetTextureObject());
if (texCube != NULL)
{
if (!IsShared())
{
osg::Image *image = new osg::Image();
texCube->setImage(osg::TextureCubeMap::POSITIVE_X, image);
texCube->setImage(osg::TextureCubeMap::NEGATIVE_X, image);
texCube->setImage(osg::TextureCubeMap::POSITIVE_Y, image);
texCube->setImage(osg::TextureCubeMap::NEGATIVE_Y, image);
texCube->setImage(osg::TextureCubeMap::POSITIVE_Z, image);
texCube->setImage(osg::TextureCubeMap::NEGATIVE_Z, image);
}
stateSet.setTextureAttributeAndModes(GetTextureUnit(),texCube,osg::StateAttribute::OFF);
}
// do normal parameter cleanup
ShaderParameter::DetachFromRenderState(stateSet);
}