OsgTextureUniform.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_OSGTEXTUREUNIFORM_H
#define SURGSIM_GRAPHICS_OSGTEXTUREUNIFORM_H
namespace SurgSim
{
namespace Graphics
{
template <class T>
class OsgTextureUniform : public Uniform<std::shared_ptr<T>>, public OsgUniformBase
{
public:
explicit OsgTextureUniform(const std::string& name);
void setMinimumTextureUnit(size_t unit);
size_t getMinimumTextureUnit() const;
virtual void set(const std::shared_ptr<T>& value);
virtual void set(const YAML::Node& node);
virtual const std::shared_ptr<T>& get() const;
virtual void addToStateSet(osg::StateSet* stateSet);
virtual void removeFromStateSet(osg::StateSet* stateSet);
private:
std::shared_ptr<T> m_texture;
osg::ref_ptr<osg::StateSet> m_stateset;
ptrdiff_t m_unit;
size_t m_minimumTextureUnit;
};
template <>
class OsgUniform<std::shared_ptr<OsgTexture1d>> : public OsgTextureUniform<OsgTexture1d>
{
public:
explicit OsgUniform(const std::string& name) : OsgTextureUniform<OsgTexture1d>(name)
{
}
};
template <>
class OsgUniform<std::shared_ptr<OsgTexture2d>> : public OsgTextureUniform<OsgTexture2d>
{
public:
explicit OsgUniform(const std::string& name) : OsgTextureUniform<OsgTexture2d>(name)
{
}
};
template <>
class OsgUniform<std::shared_ptr<OsgTexture3d>> : public OsgTextureUniform<OsgTexture3d>
{
public:
explicit OsgUniform(const std::string& name) : OsgTextureUniform<OsgTexture3d>(name)
{
}
};
template <>
class OsgUniform<std::shared_ptr<OsgTextureCubeMap>> : public OsgTextureUniform<OsgTextureCubeMap>
{
public:
explicit OsgUniform(const std::string& name) : OsgTextureUniform<OsgTextureCubeMap>(name)
{
}
};
template <>
class OsgUniform<std::shared_ptr<OsgTextureRectangle>> : public OsgTextureUniform<OsgTextureRectangle>
{
public:
explicit OsgUniform(const std::string& name) : OsgTextureUniform<OsgTextureRectangle>(name)
{
}
};
}; // namespace Graphics
}; // namespace SurgSim
#endif // SURGSIM_GRAPHICS_OSGTEXTUREUNIFORM_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgTextureUniform::getMinimumTextureUnit
size_t getMinimumTextureUnit() const
Definition: OsgTextureUniform-inl.h:127
SurgSim::Graphics::OsgTextureUniform::m_stateset
osg::ref_ptr< osg::StateSet > m_stateset
Definition: OsgTextureUniform.h:66
std
STL namespace.
SurgSim::Graphics::OsgUniform< std::shared_ptr< OsgTexture3d > >::OsgUniform
OsgUniform(const std::string &name)
Constructor.
Definition: OsgTextureUniform.h:106
SurgSim::Graphics::OsgTextureCubeMap
OSG implementation of a Cube Map Texture.
Definition: OsgTextureCubeMap.h:38
SurgSim::Graphics::OsgUniform
OSG implementation of graphics uniform with a value of type T.
Definition: OsgCamera.h:46
SurgSim::Graphics::OsgTextureUniform::m_texture
std::shared_ptr< T > m_texture
Texture.
Definition: OsgTextureUniform.h:64
SurgSim::Graphics::OsgUniform< std::shared_ptr< OsgTexture2d > >::OsgUniform
OsgUniform(const std::string &name)
Constructor.
Definition: OsgTextureUniform.h:94
SurgSim::Graphics::OsgTexture3d
OSG implementation of a 3D Texture.
Definition: OsgTexture3d.h:38
SurgSim::Graphics::OsgUniformBase
Base OSG implementation of graphics uniforms.
Definition: OsgUniformBase.h:41
SurgSim::Graphics::OsgUniform< std::shared_ptr< OsgTextureRectangle > >::OsgUniform
OsgUniform(const std::string &name)
Constructor.
Definition: OsgTextureUniform.h:130
SurgSim::Graphics::OsgTextureUniform::removeFromStateSet
virtual void removeFromStateSet(osg::StateSet *stateSet)
Removes this uniform from the OSG state set.
Definition: OsgTextureUniform-inl.h:111
SurgSim::Graphics::OsgTextureUniform::OsgTextureUniform
OsgTextureUniform(const std::string &name)
Constructor.
Definition: OsgTextureUniform-inl.h:37
SurgSim::Graphics::OsgTextureUniform::setMinimumTextureUnit
void setMinimumTextureUnit(size_t unit)
This is the texture unit from where the search for a free texture unit will start.
Definition: OsgTextureUniform-inl.h:120
SurgSim::Graphics::Uniform
Base class for a graphics uniform with a value of type T.
Definition: Uniform.h:32
SurgSim::Graphics::OsgTextureUniform
OSG implementation of graphics uniform with a texture value.
Definition: OsgTextureUniform.h:30
SurgSim::Graphics::OsgTextureRectangle
OSG implementation of a Rectangle Texture.
Definition: OsgTextureRectangle.h:40
SurgSim::Graphics::OsgTextureUniform::addToStateSet
virtual void addToStateSet(osg::StateSet *stateSet)
Adds this uniform to the OSG state set.
Definition: OsgTextureUniform-inl.h:72
SurgSim::Graphics::OsgTextureUniform::m_unit
ptrdiff_t m_unit
Texture unit.
Definition: OsgTextureUniform.h:69
SurgSim::Graphics::OsgUniform< std::shared_ptr< OsgTexture1d > >::OsgUniform
OsgUniform(const std::string &name)
Constructor.
Definition: OsgTextureUniform.h:82
SurgSim::Graphics::OsgTexture1d
OSG implementation of a 1D Texture.
Definition: OsgTexture1d.h:38
SurgSim::Graphics::OsgUniform< std::shared_ptr< OsgTextureCubeMap > >::OsgUniform
OsgUniform(const std::string &name)
Constructor.
Definition: OsgTextureUniform.h:118
SurgSim::Graphics::OsgTexture2d
OSG implementation of a 2D Texture.
Definition: OsgTexture2d.h:42
SurgSim::Graphics::OsgTextureUniform::m_minimumTextureUnit
size_t m_minimumTextureUnit
The smallest unit to be used.
Definition: OsgTextureUniform.h:72