• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ osg::State类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中osg::State的典型用法代码示例。如果您正苦于以下问题:C++ State类的具体用法?C++ State怎么用?C++ State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了State类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:33,代码来源:DepthPeelBin.cpp


示例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);
        }
    }
开发者ID:469447793,项目名称:osgearth,代码行数:29,代码来源:DrapingTechnique.cpp


示例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);
	}
开发者ID:BackupTheBerlios,项目名称:eu07-svn,代码行数:12,代码来源:terrainMaterial.cpp


示例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);
        }
开发者ID:Pjstaab,项目名称:openmw,代码行数:14,代码来源:lightmanager.cpp


示例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 );
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:15,代码来源:DepthPeelBin.cpp


示例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 );
    }
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:15,代码来源:RenderingEffects.cpp


示例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));
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:26,代码来源:BufferIndexBinding.cpp


示例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())));
    }
开发者ID:marchelbling,项目名称:osg,代码行数:7,代码来源:VertexArrayState.cpp


示例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 );
}
开发者ID:BackupTheBerlios,项目名称:yag2002-svn,代码行数:25,代码来源:vrc_lod.cpp


示例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;
 }
开发者ID:rhabacker,项目名称:osgearth,代码行数:9,代码来源:osgearth_shadercomp.cpp


示例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;
    }
}
开发者ID:yueying,项目名称:osg,代码行数:17,代码来源:Validator.cpp


示例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);
    }
开发者ID:marchelbling,项目名称:osg,代码行数:8,代码来源:VertexArrayState.cpp


示例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
}
开发者ID:aroth-fastprotect,项目名称:osgearth,代码行数:9,代码来源:Lighting.cpp


示例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() );
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:19,代码来源:DepthPeelBin.cpp


示例15: drawComplete

void DepthPeelBin::drawComplete( osg::State& state, unsigned int insertStateSetPosition )
{
    TRACEDUMP("DepthPeelBin::drawComplete");

    if (_stateset.valid())
    {
        state.removeStateSet(insertStateSetPosition);
        // state.apply();
    }
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:10,代码来源:DepthPeelBin.cpp


示例16: validate

bool Technique::validate(osg::State& state) const
{
    typedef std::vector<std::string> String_list;
    String_list extensions;

    getRequiredExtensions(extensions);

    for (String_list::const_iterator i=extensions.begin(); i!=extensions.end(); ++i) {
        if (!osg::isGLExtensionSupported(state.getContextID(),i->c_str())) return false;
    }

    return true;
}
开发者ID:151706061,项目名称:OpenSceneGraph,代码行数:13,代码来源:Technique.cpp


示例17:

void osgParticle::ParticleSystem::ArrayData::dispatchArrays(osg::State& state)
{
    osg::VertexArrayState* vas = state.getCurrentVertexArrayState();

    vas->lazyDisablingOfVertexAttributes();

    if (vertices.valid()) vas->setVertexArray(state, vertices.get());
    if (normals.valid()) vas->setNormalArray(state, normals.get());
    if (colors.valid()) vas->setColorArray(state, colors.get());
    if (texcoords2.valid()) vas->setTexCoordArray(state, 0, texcoords2.get());
    if (texcoords3.valid()) vas->setTexCoordArray(state, 0, texcoords3.get());

    vas->applyDisablingOfVertexAttributes(state);
}
开发者ID:marchelbling,项目名称:osg,代码行数:14,代码来源:ParticleSystem.cpp


示例18:

void Text3D::renderPerGlyph(osg::State & state) const
{
    osg::Matrix original_modelview = state.getModelViewMatrix();

    // ** for each line, do ...
    TextRenderInfo::const_iterator itLine, endLine = _textRenderInfo.end();
    for (itLine = _textRenderInfo.begin(); itLine!=endLine; ++itLine)
    {
        // ** for each glyph in the line, do ...
        LineRenderInfo::const_iterator it, end = itLine->end();
        for (it = itLine->begin(); it!=end; ++it)
        {

            osg::ref_ptr<osg::RefMatrix> matrix = new osg::RefMatrix(original_modelview);
            matrix->preMultTranslate(osg::Vec3d(it->_position.x(), it->_position.y(), it->_position.z()));
            state.applyModelViewMatrix(matrix.get());

            // ** apply the vertex array
            state.setVertexPointer(it->_glyph->getVertexArray());

            // ** render the front face of the glyph
            state.Normal(0.0f,0.0f,1.0f);

            osg::Geometry::PrimitiveSetList & pslFront = it->_glyph->getFrontPrimitiveSetList();
            for(osg::Geometry::PrimitiveSetList::const_iterator itr=pslFront.begin(), end = pslFront.end(); itr!=end; ++itr)
            {
                (*itr)->draw(state, false);
            }

            // ** render the wall face of the glyph
            state.setNormalPointer(it->_glyph->getNormalArray());
            osg::Geometry::PrimitiveSetList & pslWall = it->_glyph->getWallPrimitiveSetList();
            for(osg::Geometry::PrimitiveSetList::const_iterator itr=pslWall.begin(), end=pslWall.end(); itr!=end; ++itr)
            {
                (*itr)->draw(state, false);
            }
            state.disableNormalPointer();

            // ** render the back face of the glyph
            state.Normal(0.0f,0.0f,-1.0f);

            osg::Geometry::PrimitiveSetList & pslBack = it->_glyph->getBackPrimitiveSetList();
            for(osg::Geometry::PrimitiveSetList::const_iterator itr=pslBack.begin(), end=pslBack.end(); itr!=end; ++itr)
            {
                (*itr)->draw(state, false);
            }
        }
    }
}
开发者ID:seafengl,项目名称:osg-by-google,代码行数:49,代码来源:Text3D.cpp


示例19: fboExt

void
DepthPeelBin::PerContextInfo::cleanup( const osg::State& state )
{
    TRACEDUMP("  PerContextInfo::cleanup");

    glDeleteTextures( 3, _depthTex );
    _depthTex[ 0 ] = _depthTex[ 1 ] = _depthTex[ 2 ] = 0;

    glDeleteTextures( 1, &_colorTex );
    _colorTex = 0;

    osg::FBOExtensions* fboExt( osg::FBOExtensions::instance( state.getContextID(), true ) );
    osgwTools::glBindFramebuffer( fboExt, GL_FRAMEBUFFER_EXT, 0 );
    osgwTools::glDeleteFramebuffers( fboExt, 1, &_fbo );
    _fbo = 0;

    _glDeleteQueries( 1, &_queryID );
    _queryID = 0;

    _init = false;
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:21,代码来源:DepthPeelBin.cpp


示例20: glCallList

void Font::Glyph::draw(osg::State& state) const
{
    GLuint& globj = _globjList[state.getContextID()];

    // call the globj if already set otherwise compile and execute.
    if( globj != 0 )
    {
        glCallList( globj );
    }
    else 
    {
        globj = glGenLists( 1 );
        glNewList( globj, GL_COMPILE_AND_EXECUTE );

        glPixelStorei(GL_UNPACK_ALIGNMENT,getPacking());
        glDrawPixels(s(), t(),
                     (GLenum)getPixelFormat(),
                     (GLenum)getDataType(),
                     data() );

        glEndList();
    }
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:23,代码来源:Font.cpp



注:本文中的osg::State类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ osg::StateSet类代码示例发布时间:2022-05-31
下一篇:
C++ osg::SimpleSceneManagerRefPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap