add flexier Image Unit Binding implementation (allow different IUBs for a Texture)

This commit is contained in:
mp3butcher
2017-12-25 23:42:33 +01:00
committed by Julien Valentin
parent 5afd32b2d9
commit 2f8a262a0e
4 changed files with 139 additions and 0 deletions

View File

@@ -96,6 +96,7 @@ SET(TARGET_H
${HEADER_PATH}/ImageSequence
${HEADER_PATH}/ImageStream
${HEADER_PATH}/ImageUtils
${HEADER_PATH}/ImageTexture
${HEADER_PATH}/io_utils
${HEADER_PATH}/KdTree
${HEADER_PATH}/Light
@@ -307,6 +308,7 @@ SET(TARGET_SRC
ImageSequence.cpp
ImageStream.cpp
ImageUtils.cpp
ImageTexture.cpp
KdTree.cpp
Light.cpp
LightModel.cpp

28
src/osg/ImageTexture.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include <osg/ImageTexture>
using namespace osg;
int ImageTextureBinding::compare(const osg::StateAttribute &sa)const{
COMPARE_StateAttribute_Types(ImageTextureBinding,sa)
// Compare each parameter in turn against the rhs.
COMPARE_StateAttribute_Parameter(_target)
COMPARE_StateAttribute_Parameter(_imageunit)
COMPARE_StateAttribute_Parameter(_access)
COMPARE_StateAttribute_Parameter(_format)
COMPARE_StateAttribute_Parameter(_layered)
COMPARE_StateAttribute_Parameter(_level)
return 0;
}
void ImageTextureBinding::apply(osg::State&state)const{
if(_target.valid()){
osg::Texture::TextureObject *to = _target->getTextureObject( state.getContextID() );
if( !to ){
// _target never been applied yet
_target->apply(state);
to = _target->getTextureObject( state.getContextID() );
}
state.get<osg::GLExtensions>()->glBindImageTexture(_imageunit, to->id(), _level, _layered, _layer, _access, _format);
}
}