1 #include <osg/BindImageTexture> 2 3 using namespace osg; 4 compare(const osg::StateAttribute & sa) const5int BindImageTexture::compare(const osg::StateAttribute &sa) const 6 { 7 COMPARE_StateAttribute_Types(BindImageTexture,sa) 8 // Compare each parameter in turn against the rhs. 9 COMPARE_StateAttribute_Parameter(_target) 10 COMPARE_StateAttribute_Parameter(_imageunit) 11 COMPARE_StateAttribute_Parameter(_access) 12 COMPARE_StateAttribute_Parameter(_format) 13 COMPARE_StateAttribute_Parameter(_layered) 14 COMPARE_StateAttribute_Parameter(_level) 15 return 0; 16 } 17 apply(osg::State & state) const18void BindImageTexture::apply(osg::State& state) const 19 { 20 if(_target.valid()) 21 { 22 unsigned int contextID = state.getContextID(); 23 osg::Texture::TextureObject *to = _target->getTextureObject( contextID ); 24 if( !to || _target->isDirty( contextID )) 25 { 26 // _target never been applied yet or is dirty 27 state.applyTextureAttribute( state.getActiveTextureUnit(), _target.get()); 28 to = _target->getTextureObject( contextID ); 29 } 30 31 state.get<osg::GLExtensions>()->glBindImageTexture(_imageunit, to->id(), _level, _layered, _layer, _access, _format); 32 } 33 34 } 35