本文整理汇总了C++中osg::State类的典型用法代码示例。如果您正苦于以下问题:C++ State类的具体用法?C++ State怎么用?C++ State使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawFSTP
void DepthPeelBin::drawFSTP( osg::RenderInfo& renderInfo, osg::State& state, osg::GL2Extensions* ext, PerContextInfo& pci,
GLint& fstpLoc, GLint& texturePercentLoc )
{
TRACEDUMP("DepthPeelBin::drawFSTP");
// Set up the program and uniforms.
state.applyAttribute( _fstpProgram.get() );
if( fstpLoc < 0 )
#if OSG_SUPPORTS_UNIFORM_ID
fstpLoc = state.getUniformLocation( _fstpUniform->getNameID() );
#else
fstpLoc = state.getUniformLocation( _fstpUniform->getName() );
#endif
_fstpUniform->apply( ext, fstpLoc );
if( texturePercentLoc < 0 )
#if OSG_SUPPORTS_UNIFORM_ID
texturePercentLoc = state.getUniformLocation( _texturePercentUniform->getNameID() );
#else
texturePercentLoc = state.getUniformLocation( _texturePercentUniform->getName() );
#endif
_texturePercentUniform->apply( ext, texturePercentLoc );
state.setActiveTextureUnit( s_textureUnit+1 );
glBindTexture( GL_TEXTURE_2D, pci._colorTex );
state.applyAttribute( _fstpBlendFunc.get() );
state.applyMode( GL_BLEND, true );
state.applyMode( GL_DEPTH_TEST, false );
_fstp->draw( renderInfo );
state.setActiveTextureUnit( s_textureUnit+1 );
glBindTexture( GL_TEXTURE_2D, 0 );
}
示例2: apply
virtual void apply(osg::State& state) const {
osg::State::UniformMap::const_iterator i = state.getUniformMap().find("oe_isPickCamera");
bool isPickCamera = false;
if (i != state.getUniformMap().end())
{
if (!i->second.uniformVec.empty())
{
i->second.uniformVec.back().first->get(isPickCamera);
}
}
if (isPickCamera)
{
FilterMode minFilter = _min_filter;
FilterMode magFilter = _mag_filter;
DrapingTexture* ncThis = const_cast<DrapingTexture*>(this);
ncThis->_min_filter = NEAREST;
ncThis->_mag_filter = NEAREST;
ncThis->dirtyTextureParameters();
osg::Texture2D::apply(state);
ncThis->_min_filter = minFilter;
ncThis->_mag_filter = magFilter;
ncThis->dirtyTextureParameters();
}
else
{
osg::Texture2D::apply(state);
}
}
示例3: drawImplementation
virtual void drawImplementation(osg::State& state,const osg::Drawable* drawable) const
{
static osg::TexMat *tm= new osg::TexMat();
osg::Matrix mvm(state.getModelViewMatrix());
osg::Quat q;
q.set(mvm);
// state.getorcre
tm->setMatrix(osg::Matrix::rotate( q.inverse() ));
state.applyTextureAttribute(1,tm);
// drawable->getOrCreateStateSet()->
drawable->drawImplementation(state);
}
示例4: apply
virtual void apply(osg::State& state) const
{
osg::Matrix modelViewMatrix = state.getModelViewMatrix();
state.applyModelViewMatrix(state.getInitialViewMatrix());
for (unsigned int i=0; i<mLights.size(); ++i)
{
mLights[i]->setLightNum(i+mIndex);
mLights[i]->apply(state);
}
state.applyModelViewMatrix(modelViewMatrix);
}
示例5: drawInit
unsigned int DepthPeelBin::drawInit( osg::State& state, osgUtil::RenderLeaf*& previous )
{
TRACEDUMP("DepthPeelBin::drawInit");
unsigned int numToPop = (previous ? osgUtil::StateGraph::numToPop(previous->_parent) : 0);
if (numToPop>1) --numToPop;
unsigned int insertStateSetPosition = state.getStateSetStackSize() - numToPop;
if (_stateset.valid())
{
state.insertStateSet(insertStateSetPosition, _stateset.get());
}
return( insertStateSetPosition );
}
示例6: applyAllGlobalUniforms
void RenderingEffects::applyAllGlobalUniforms( osg::State& state, osg::GL2Extensions* gl2Ext )
{
UniformVector::iterator it;
for( it = _globalUniformVector.begin(); it != _globalUniformVector.end(); it++ )
{
osg::Uniform* uniform = (*it).get();
#if OSG_SUPPORTS_UNIFORM_ID
GLint location = state.getUniformLocation( uniform->getNameID() );
#else
GLint location = state.getUniformLocation( uniform->getName() );
#endif
if( location >= 0 )
uniform->apply( gl2Ext, location );
}
}
示例7: readData
void AtomicCounterBufferBinding::readData(osg::State & state, osg::UIntArray & uintArray) const
{
if (!_bufferObject) return;
GLBufferObject* bo = _bufferObject->getOrCreateGLBufferObject( state.getContextID() );
if (!bo) return;
GLint previousID = 0;
glGetIntegerv(GL_ATOMIC_COUNTER_BUFFER_BINDING, &previousID);
if (static_cast<GLuint>(previousID) != bo->getGLObjectID())
bo->_extensions->glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bo->getGLObjectID());
GLubyte* src = (GLubyte*)bo->_extensions->glMapBuffer(GL_ATOMIC_COUNTER_BUFFER,
GL_READ_ONLY_ARB);
if(src)
{
size_t size = osg::minimum<int>(_size, uintArray.getTotalDataSize());
memcpy((void*) &(uintArray.front()), src+_offset, size);
bo->_extensions->glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
}
if (static_cast<GLuint>(previousID) != bo->getGLObjectID())
bo->_extensions->glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, static_cast<GLuint>(previousID));
}
示例8: dispatch
virtual void dispatch(osg::State& state, const osg::Array* new_array, const osg::GLBufferObject* vbo)
{
VAS_NOTICE<<" TexCoordArrayDispatch::dispatch("<<new_array->getNumElements()<<", vbo="<<std::hex<<vbo<<std::dec<<") unit="<<unit<<std::endl;
state.setClientActiveTextureUnit(unit);
glTexCoordPointer(new_array->getDataSize(), new_array->getDataType(), 0, (const GLvoid *)(vbo->getOffset(new_array->getBufferIndex())));
}
示例9: drawImplementation
void LODDrawCallback::drawImplementation( osg::State& state, const osg::Drawable* p_drawable ) const
{
assert( _p_lodMesh && "lod mesh data not available!" );
const GLuint groupname = _p_lodMesh->getGroupName();
const GLuint objectname = _p_lodMesh->getObjectName();
const GLuint numpatches = _p_lodMesh->getNumPatches();
// need for LOD adaptation?
if ( _p_lodMesh->adaptLOD() )
{
glodBindObjectXform( objectname, GL_PROJECTION_MATRIX | GL_MODELVIEW_MATRIX );
glodAdaptGroup( groupname );
// reset the adaptation flag after every adaptation
// the adaptation is triggered by update callback
_p_lodMesh->setAdaptLOD( false );
}
// apply drawable's state
state.apply( p_drawable->getStateSet() );
// draw the object patches
for( GLuint patch = 0; patch < numpatches; ++patch )
glodDrawPatch( objectname, patch );
}
示例10: operator
// Return true to activate the shader function.
bool operator()(const osg::State& state)
{
osg::Camera* camera = *state.getGraphicsContext()->getCameras().begin();
if (!camera) return false;
osg::Viewport* viewport = camera->getViewport();
if (!viewport) return false;
return viewport->width() > 1000;
}
示例11: apply
void Validator::apply(osg::State& state) const
{
if (!_effect) return;
if (_effect->_tech_selected[state.getContextID()] == 0) {
Effect::Technique_list::iterator i;
int j = 0;
for (i=_effect->_techs.begin(); i!=_effect->_techs.end(); ++i, ++j) {
if ((*i)->validate(state)) {
_effect->_sel_tech[state.getContextID()] = j;
_effect->_tech_selected[state.getContextID()] = 1;
return;
}
}
OSG_WARN << "Warning: osgFX::Validator: could not find any techniques compatible with the current OpenGL context" << std::endl;
}
}
示例12: disable
virtual void disable(osg::State& state)
{
VAS_NOTICE<<" TexCoordArrayDispatch::disable() unit="<<unit<<std::endl;
//state.glClientActiveTexture(static_cast<GLenum>(GL_TEXTURE0+unit));
state.setClientActiveTextureUnit(unit);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
示例13:
void
MaterialGL3::apply(osg::State& state) const
{
#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE
osg::Material::apply(state);
#else
state.Color(_diffuseFront.r(), _diffuseFront.g(), _diffuseFront.b(), _diffuseFront.a());
#endif
}
示例14: createFileName
std::string DepthPeelBin::createFileName( osg::State& state, int pass, bool depth )
{
unsigned int contextID = state.getContextID();
int frameNumber = state.getFrameStamp()->getFrameNumber();
std::ostringstream ostr;
ostr << std::setfill( '0' );
ostr << "f" << std::setw( 6 ) << frameNumber <<
"_c" << std::setw( 2 ) << contextID << "_";
ostr << "peel_part" << _partitionNumber;
if( pass == -1 )
ostr << "_a";
else
ostr << "_b" << std::setw( 2 ) << pass;
if( depth )
ostr << "_z";
ostr << ".png";
return( ostr.str() );
}
示例15: drawComplete
void DepthPeelBin::drawComplete( osg::State& state, unsigned int insertStateSetPosition )
{
TRACEDUMP("DepthPeelBin::drawComplete");
if (_stateset.valid())
{
state.removeStateSet(insertStateSetPosition);
// state.apply();
}
}