本文整理汇总了C++中osg::RenderInfo::getState方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderInfo::getState方法的具体用法?C++ RenderInfo::getState怎么用?C++ RenderInfo::getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::RenderInfo
的用法示例。
在下文中一共展示了RenderInfo::getState方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawImplementation
void RenderBin::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
{
osg::State& state = *renderInfo.getState();
// OSG_NOTICE<<"begin RenderBin::drawImplementation "<<className()<<" sortMode "<<getSortMode()<<std::endl;
unsigned int numToPop = (previous ? StateGraph::numToPop(previous->_parent) : 0);
if (numToPop>1) --numToPop;
unsigned int insertStateSetPosition = state.getStateSetStackSize() - numToPop;
if (_stateset.valid())
{
state.insertStateSet(insertStateSetPosition, _stateset.get());
}
// draw first set of draw bins.
RenderBinList::iterator rbitr;
for(rbitr = _bins.begin();
rbitr!=_bins.end() && rbitr->first<0;
++rbitr)
{
rbitr->second->draw(renderInfo,previous);
}
// draw fine grained ordering.
for(RenderLeafList::iterator rlitr= _renderLeafList.begin();
rlitr!= _renderLeafList.end();
++rlitr)
{
RenderLeaf* rl = *rlitr;
rl->render(renderInfo,previous);
previous = rl;
}
bool draw_forward = true; //(_sortMode!=SORT_BY_STATE) || (state.getFrameStamp()->getFrameNumber() % 2)==0;
// draw coarse grained ordering.
if (draw_forward)
{
for(StateGraphList::iterator oitr=_stateGraphList.begin();
oitr!=_stateGraphList.end();
++oitr)
{
for(StateGraph::LeafList::iterator dw_itr = (*oitr)->_leaves.begin();
dw_itr != (*oitr)->_leaves.end();
++dw_itr)
{
RenderLeaf* rl = dw_itr->get();
rl->render(renderInfo,previous);
previous = rl;
}
}
}
else
{
for(StateGraphList::reverse_iterator oitr=_stateGraphList.rbegin();
oitr!=_stateGraphList.rend();
++oitr)
{
for(StateGraph::LeafList::iterator dw_itr = (*oitr)->_leaves.begin();
dw_itr != (*oitr)->_leaves.end();
++dw_itr)
{
RenderLeaf* rl = dw_itr->get();
rl->render(renderInfo,previous);
previous = rl;
}
}
}
// draw post bins.
for(;
rbitr!=_bins.end();
++rbitr)
{
rbitr->second->draw(renderInfo,previous);
}
if (_stateset.valid())
{
state.removeStateSet(insertStateSetPosition);
// state.apply();
}
// OSG_NOTICE<<"end RenderBin::drawImplementation "<<className()<<std::endl;
}
示例2: if
void
TileDrawable::drawVertexArraysImplementation(osg::RenderInfo& renderInfo) const
{
State& state = *renderInfo.getState();
bool handleVertexAttributes = !_geom->getVertexAttribArrayList().empty();
//bool handleVertexAttributes = !_vertexAttribList.empty();
ArrayDispatchers& arrayDispatchers = state.getArrayDispatchers();
arrayDispatchers.reset();
arrayDispatchers.setUseVertexAttribAlias(state.getUseVertexAttributeAliasing());
arrayDispatchers.setUseGLBeginEndAdapter(false);
arrayDispatchers.activateNormalArray(_geom->getNormalBinding(), _geom->getNormalArray(), _geom->getNormalIndices());
arrayDispatchers.activateColorArray(_geom->getColorBinding(), _geom->getColorArray(), _geom->getColorIndices());
arrayDispatchers.activateSecondaryColorArray(_geom->getSecondaryColorBinding(), _geom->getSecondaryColorArray(), _geom->getSecondaryColorIndices());
arrayDispatchers.activateFogCoordArray(_geom->getFogCoordBinding(), _geom->getFogCoordArray(), _geom->getFogCoordIndices());
if (handleVertexAttributes)
{
for(unsigned int unit=0;unit < _geom->getVertexAttribArrayList().size();++unit)
{
const osg::Geometry::ArrayData& val = _geom->getVertexAttribArrayList()[unit];
arrayDispatchers.activateVertexAttribArray(val.binding, unit, val.array.get(), val.indices.get());
}
}
// dispatch any attributes that are bound overall
arrayDispatchers.dispatch(_geom->BIND_OVERALL, 0);
state.lazyDisablingOfVertexAttributes();
// set up arrays
if( _geom->getVertexArray() )
state.setVertexPointer(_geom->getVertexArray()); //_vertexData.array.get());
if (_geom->getNormalBinding()==_geom->BIND_PER_VERTEX && _geom->getNormalArray())
state.setNormalPointer(_geom->getNormalArray());
if (_geom->getColorBinding()==_geom->BIND_PER_VERTEX && _geom->getColorArray())
state.setColorPointer(_geom->getColorArray());
if (_geom->getSecondaryColorBinding()==_geom->BIND_PER_VERTEX && _geom->getSecondaryColorArray())
state.setSecondaryColorPointer(_geom->getSecondaryColorArray());
if (_geom->getFogCoordBinding()==_geom->BIND_PER_VERTEX && _geom->getFogCoordArray())
state.setFogCoordPointer(_geom->getFogCoordArray());
for(unsigned int unit=0;unit<_geom->getTexCoordArrayList().size();++unit)
{
const Array* array = _geom->getTexCoordArray(unit);
if (array)
{
state.setTexCoordPointer(unit,array);
}
}
if ( handleVertexAttributes )
{
for(unsigned int index = 0; index < _geom->getVertexAttribArrayList().size(); ++index)
{
const osg::Array* array = _geom->getVertexAttribArray(index);
if ( array && _geom->getVertexAttribBinding(index) == _geom->BIND_PER_VERTEX )
{
if (array->getPreserveDataType())
{
GLenum dataType = array->getDataType();
if (dataType==GL_FLOAT) state.setVertexAttribPointer( index, array, GL_FALSE );
else if (dataType==GL_DOUBLE) state.setVertexAttribLPointer( index, array );
else state.setVertexAttribIPointer( index, array );
}
else
{
state.setVertexAttribPointer( index, array, GL_FALSE );
}
}
}
}
state.applyDisablingOfVertexAttributes();
}
示例3:
void
TileDrawable::drawSurface(osg::RenderInfo& renderInfo) const
{
unsigned layersDrawn = 0;
osg::State& state = *renderInfo.getState();
// access the GL extensions interface for the current GC:
const osg::Program::PerContextProgram* pcp = 0L;
#if OSG_MIN_VERSION_REQUIRED(3,3,3)
osg::ref_ptr<osg::GLExtensions> ext;
#else
osg::ref_ptr<osg::GL2Extensions> ext;
#endif
unsigned contextID;
if (_supportsGLSL)
{
contextID = state.getContextID();
#if OSG_MIN_VERSION_REQUIRED(3,3,3)
ext = osg::GLExtensions::Get(contextID, true);
#else
ext = osg::GL2Extensions::Get( contextID, true );
#endif
pcp = state.getLastAppliedProgramObject();
}
// safely latch
if ( _geom->getNumPrimitiveSets() < 1 )
return;
// cannot store these in the object since there could be multiple GCs (and multiple
// PerContextPrograms) at large
GLint opacityLocation = -1;
GLint uidLocation = -1;
GLint orderLocation = -1;
GLint texMatrixLocation = -1;
GLint texMatrixParentLocation = -1;
GLint texParentExistsLocation = -1;
// The PCP can change (especially in a VirtualProgram environment). So we do need to
// requery the uni locations each time unfortunately. TODO: explore optimizations.
if ( pcp )
{
opacityLocation = pcp->getUniformLocation( _opacityUniformNameID );
uidLocation = pcp->getUniformLocation( _uidUniformNameID );
orderLocation = pcp->getUniformLocation( _orderUniformNameID );
texMatrixLocation = pcp->getUniformLocation( _texMatrixUniformNameID );
texMatrixParentLocation = pcp->getUniformLocation( _texMatrixParentUniformNameID );
texParentExistsLocation = pcp->getUniformLocation( _texParentExistsUniformNameID );
}
float prevOpacity = -1.0f;
if ( _mptex.valid() && !_mptex->getPasses().empty() )
{
float prevOpacity = -1.0f;
// in FFP mode, we need to enable the GL mode for texturing:
if ( !pcp )
state.applyMode(GL_TEXTURE_2D, true);
optional<bool> texParentExists_lastValue;
for(MPTexture::Passes::const_iterator p = _mptex->getPasses().begin();
p != _mptex->getPasses().end();
++p)
{
const MPTexture::Pass& pass = *p;
if ( pass._layer->getVisible() && pass._layer->getOpacity() > 0.1 )
{
// Apply the texture.
state.setActiveTextureUnit( _textureImageUnit );
const osg::StateAttribute* lastTex = state.getLastAppliedTextureAttribute(_textureImageUnit, osg::StateAttribute::TEXTURE);
if ( lastTex != pass._texture.get() )
pass._texture->apply( state );
// Apply the texture matrix.
ext->glUniformMatrix4fv( texMatrixLocation, 1, GL_FALSE, pass._textureMatrix.ptr() );
bool texParentExists = pass._parentTexture.valid();
if ( texParentExists )
{
// Apply the parent texture.
state.setActiveTextureUnit( _textureParentImageUnit );
const osg::StateAttribute* lastTex = state.getLastAppliedTextureAttribute(_textureParentImageUnit, osg::StateAttribute::TEXTURE);
if ( lastTex != pass._parentTexture.get() )
pass._parentTexture->apply( state );
// Apply the parent texture matrix.
ext->glUniformMatrix4fv( texMatrixParentLocation, 1, GL_FALSE, pass._parentTextureMatrix.ptr() );
}
if ( !texParentExists_lastValue.isSetTo(texParentExists) )
{
texParentExists_lastValue = texParentExists;
ext->glUniform1f( texParentExistsLocation, texParentExists? 1.0f : 0.0f );
}
//.........这里部分代码省略.........
示例4: operator
void CameraResetCallback::operator()( osg::RenderInfo& renderInfo ) const
{
osg::Camera* cam = renderInfo.getCurrentCamera();
unsigned int contextID = renderInfo.getState()->getContextID();
QueryComputation::setCscrOi( 0., cam, contextID );
}
示例5: drawImplementation
void ScreenTexture::drawImplementation( osg::RenderInfo & renderInfo ) const
{
if (!_isNeededValidation)
return;
_isNeededValidation = false;
osg::State & state = *renderInfo.getState();
const osg::Viewport * viewport = state.getCurrentViewport();
#if defined(_SCREEN_TEXTURE_DEBUG_)
const unsigned texunit = state.getActiveTextureUnit();
state.setActiveTextureUnit(0);
#endif // _SCREEN_TEXTURE_DEBUG_
// instead of doing copyTexImage we would do FBO blit operation to ensure it correctly handles multisampled FBO
// get fbo extension which provides us with the glGenerateMipmapEXT function
#if OSG_MIN_VERSION_REQUIRED(3,3,2)
osg::GLExtensions * fbo_ext = renderInfo.getState()->get<osg::GLExtensions>();
#else
osg::FBOExtensions * fbo_ext = osg::FBOExtensions::instance(state.getContextID(), true);
#endif
// get current draw binding
GLint oldDrawFBO = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &oldDrawFBO);
// recreate FBO, is sizes were changed
if (viewport->width() != _texture->getTextureWidth() || viewport->height() != _texture->getTextureHeight())
{
//_resolveFbo = new osg::FrameBufferObject();
_texture->dirtyTextureObject();
_texture->setTextureSize(viewport->width(), viewport->height());
if (_blitBitMask == GL_DEPTH_BUFFER_BIT)
{
_resolveFbo->setAttachment(osg::Camera::DEPTH_BUFFER, osg::FrameBufferAttachment(_texture));
_resolveFbo->setAttachment(osg::Camera::COLOR_BUFFER, osg::FrameBufferAttachment(new osg::RenderBuffer(viewport->width(), viewport->height(), GL_RGB)));
}
else if (_blitBitMask == GL_COLOR_BUFFER_BIT)
{
_resolveFbo->setAttachment(osg::Camera::COLOR_BUFFER, osg::FrameBufferAttachment(_texture));
}
}
// apply resolve FBO for blit operation
_resolveFbo->apply(state, osg::FrameBufferObject::DRAW_FRAMEBUFFER);
#if defined(_SCREEN_TEXTURE_DEBUG_)
GLenum status = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
OutputDebugString("\nCannot create FBO for texture blitting\n");
#endif // _SCREEN_TEXTURE_DEBUG_
// blit to the resolve framebuffer.
fbo_ext->glBlitFramebuffer(
0, 0, static_cast<GLint>(viewport->width()), static_cast<GLint>(viewport->height()),
0, 0, static_cast<GLint>(viewport->width()), static_cast<GLint>(viewport->height()),
_blitBitMask, GL_NEAREST);
// restore old draw framebuffer
fbo_ext->glBindFramebuffer(osg::FrameBufferObject::DRAW_FRAMEBUFFER, oldDrawFBO);
// get depth settings
if (_settings.valid())
{
const osg::Matrix & projection = state.getProjectionMatrix();
const float
znear = projection(3, 2) / (projection(2, 2) - 1.0),
zfar = projection(3, 2) / (1.0 + projection(2, 2));
//double left, right, bottom, top, znear, zfar;
//state.getProjectionMatrix().getFrustum(left, right, bottom, top, znear, zfar);
const osg::Vec2f settings = osg::Vec2f((zfar - znear) / (zfar * znear), -1.0 / znear);
_settings->set(settings);
}
#if defined(_SCREEN_TEXTURE_DEBUG_)
glPushAttrib(GL_LIGHTING_BIT);
glDisable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_RECTANGLE);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glTexCoord2f(viewport->width(), 0.0f);
glVertex2f(1.0f, 0.0f);
glTexCoord2f(viewport->width(), viewport->height());
glVertex2f(1.0f, 1.0f);
glTexCoord2f(0.0f, viewport->height());
glVertex2f(0.0f, 1.0f);
//.........这里部分代码省略.........
示例6: glClear
//.........这里部分代码省略.........
if(odd)
{
vert = osg::Shader::readShaderFile(osg::Shader::VERTEX,
osgDB::findDataFile(shaderdir + "interlace.vert"));
frag = osg::Shader::readShaderFile(osg::Shader::FRAGMENT,
osgDB::findDataFile(shaderdir + "interlace-odd.frag"));
}
else
{
vert = osg::Shader::readShaderFile(osg::Shader::VERTEX,
osgDB::findDataFile(shaderdir + "interlace.vert"));
frag = osg::Shader::readShaderFile(osg::Shader::FRAGMENT,
osgDB::findDataFile(shaderdir + "interlace-even.frag"));
}
_programMap[context] = new osg::Program;
_programMap[context]->addShader(vert);
_programMap[context]->addShader(frag);
_geometryMap[context] = new osg::Geometry();
osg::DrawArrays * quad = new osg::DrawArrays(
osg::PrimitiveSet::TRIANGLE_STRIP,0,0);
osg::Vec2Array * verts = new osg::Vec2Array(0);
_geometryMap[context]->setVertexArray(verts);
_geometryMap[context]->addPrimitiveSet(quad);
verts->push_back(osg::Vec2(-1.0,1.0));
verts->push_back(osg::Vec2(-1.0,-1.0));
verts->push_back(osg::Vec2(1.0,1.0));
verts->push_back(osg::Vec2(1.0,-1.0));
_geometryMap[context]->setUseDisplayList(false);
quad->setCount(4);
/*glGenBuffers(1,&_arrayMap[context]);
glBindBuffer(GL_ARRAY_BUFFER, arrayMap[context]);
float points[8] = {-1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0};
glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(float), points, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);*/
_initMap[context] = true;
}
glViewport((int)screen->_myInfo->myChannel->left,
(int)screen->_myInfo->myChannel->bottom,
(int)screen->_myInfo->myChannel->width,
(int)screen->_myInfo->myChannel->height);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
//GLint activeTexture,bindtex;
//glGetIntegerv(GL_ACTIVE_TEXTURE,&activeTexture);
unsigned int activeTexture = renderInfo.getState()->getActiveTextureUnit();
osg::Texture::TextureObject * to = _texture->getTextureObject(context);
renderInfo.getState()->setActiveTextureUnit(0);
//glActiveTexture(GL_TEXTURE0);
//glGetIntegerv(GL_TEXTURE_BINDING_2D,&bindtex);
if(to)
{
to->bind();
}
//_texture->apply(*renderInfo.getState());
_programMap[context]->apply(*renderInfo.getState());
_geometryMap[context]->drawImplementation(renderInfo);
//glBindTexture(GL_TEXTURE_2D,bindtex);
extensions->glUseProgram(0);
renderInfo.getState()->setLastAppliedProgramObject(0);
renderInfo.getState()->setActiveTextureUnit(activeTexture);
//glActiveTexture(activeTexture);
/*glBegin(GL_TRIANGLE_STRIP);
glColor3f(1.0,0.0,0.0);
glVertex2f(-1.0,1.0);
glVertex2f(-1.0,-1.0);
glVertex2f(1.0,1.0);
glVertex2f(1.0,-1.0);
glEnd();*/
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
//glPopAttrib();
}
示例7: drawImplementation
void LightPointSpriteDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
osg::State& state = *renderInfo.getState();
if (!state.getModeValidity(GL_POINT_SPRITE_ARB))
{
LightPointDrawable::drawImplementation(renderInfo);
return;
}
state.applyMode(GL_POINT_SMOOTH,true);
state.applyMode(GL_BLEND,true);
state.applyMode(GL_LIGHTING,false);
state.applyTextureMode(0,GL_TEXTURE_2D,true);
state.applyTextureMode(1,GL_TEXTURE_2D,false);
state.applyMode(GL_POINT_SPRITE_ARB,true);
state.applyTextureAttribute(0,_sprite.get());
// Assume the point sprite texture map is already specified
// (typically in the owning LightPointNode StateSet).
glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
state.applyAttribute(_depthOn.get());
state.applyAttribute(_blendOneMinusSrcAlpha.get());
state.applyMode(GL_POINT_SMOOTH,true);
SizedLightPointList::const_iterator sitr;
unsigned int pointsize;
for(pointsize=1,sitr=_sizedOpaqueLightPointList.begin();
sitr!=_sizedOpaqueLightPointList.end();
++sitr,++pointsize)
{
const LightPointList& lpl = *sitr;
if (!lpl.empty())
{
glPointSize(pointsize);
//glInterleavedArrays(GL_C4UB_V3F,0,&lpl.front());
state.setInterleavedArrays(GL_C4UB_V3F,0,&lpl.front());
glDrawArrays(GL_POINTS,0,lpl.size());
}
}
state.applyMode(GL_BLEND,true);
state.applyAttribute(_depthOff.get());
state.applyAttribute(_blendOneMinusSrcAlpha.get());
for(pointsize=1,sitr=_sizedBlendedLightPointList.begin();
sitr!=_sizedBlendedLightPointList.end();
++sitr,++pointsize)
{
const LightPointList& lpl = *sitr;
if (!lpl.empty())
{
glPointSize(pointsize);
//glInterleavedArrays(GL_C4UB_V3F,0,&lpl.front());
state.setInterleavedArrays(GL_C4UB_V3F,0,&lpl.front());
glDrawArrays(GL_POINTS,0,lpl.size());
}
}
state.applyAttribute(_blendOne.get());
for(pointsize=1,sitr=_sizedAdditiveLightPointList.begin();
sitr!=_sizedAdditiveLightPointList.end();
++sitr,++pointsize)
{
const LightPointList& lpl = *sitr;
if (!lpl.empty())
{
//state.applyMode(GL_POINT_SMOOTH,pointsize!=1);
glPointSize(pointsize);
//glInterleavedArrays(GL_C4UB_V3F,0,&lpl.front());
state.setInterleavedArrays(GL_C4UB_V3F,0,&lpl.front());
glDrawArrays(GL_POINTS,0,lpl.size());
}
}
glPointSize(1);
glHint(GL_POINT_SMOOTH_HINT,GL_FASTEST);
state.haveAppliedAttribute(osg::StateAttribute::POINT);
state.dirtyAllVertexArrays();
state.disableAllVertexArrays();
// restore the state afterwards.
state.apply();
#else
OSG_NOTICE<<"Warning: LightPointDrawable not supported."<<std::endl;
//.........这里部分代码省略.........
示例8: defined
void PrecipitationEffect::PrecipitationDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
#if defined(OSG_GL_MATRICES_AVAILABLE)
if (!_geometry) return;
const osg::GLExtensions* extensions = renderInfo.getState()->get<osg::GLExtensions>();
// save OpenGL matrices
glPushMatrix();
if (_requiresPreviousMatrix)
{
renderInfo.getState()->setActiveTextureUnit(0);
glMatrixMode( GL_TEXTURE );
glPushMatrix();
}
typedef std::vector<const CellMatrixMap::value_type*> DepthMatrixStartTimeVector;
DepthMatrixStartTimeVector orderedEntries;
orderedEntries.reserve(_currentCellMatrixMap.size());
for(CellMatrixMap::const_iterator citr = _currentCellMatrixMap.begin();
citr != _currentCellMatrixMap.end();
++citr)
{
orderedEntries.push_back(&(*citr));
}
std::sort(orderedEntries.begin(),orderedEntries.end(),LessFunctor());
for(DepthMatrixStartTimeVector::reverse_iterator itr = orderedEntries.rbegin();
itr != orderedEntries.rend();
++itr)
{
extensions->glMultiTexCoord1f(GL_TEXTURE0+1, (*itr)->second.startTime);
// load cells current modelview matrix
if (_requiresPreviousMatrix)
{
glMatrixMode( GL_MODELVIEW );
glLoadMatrix((*itr)->second.modelview.ptr());
CellMatrixMap::const_iterator pitr = _previousCellMatrixMap.find((*itr)->first);
if (pitr != _previousCellMatrixMap.end())
{
// load previous frame modelview matrix for motion blurr effect
glMatrixMode( GL_TEXTURE );
glLoadMatrix(pitr->second.modelview.ptr());
}
else
{
// use current modelview matrix as "previous" frame value, cancelling motion blurr effect
glMatrixMode( GL_TEXTURE );
glLoadMatrix((*itr)->second.modelview.ptr());
}
}
else
{
glLoadMatrix((*itr)->second.modelview.ptr());
}
_geometry->draw(renderInfo);
unsigned int numVertices = osg::minimum(_geometry->getVertexArray()->getNumElements(), _numberOfVertices);
glDrawArrays(_drawType, 0, numVertices);
}
// restore OpenGL matrices
if (_requiresPreviousMatrix)
{
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
}
glPopMatrix();
#else
OSG_NOTICE<<"Warning: ParticleEffect::drawImplementation(..) not fully implemented."<<std::endl;
#endif
}
示例9: compileGLObjects
void PrecipitationEffect::compileGLObjects(osg::RenderInfo& renderInfo) const
{
if (_quadGeometry.valid())
{
_quadGeometry->compileGLObjects(renderInfo);
if (_quadGeometry->getStateSet()) _quadGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
}
if (_lineGeometry.valid())
{
_lineGeometry->compileGLObjects(renderInfo);
if (_lineGeometry->getStateSet()) _lineGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
}
if (_pointGeometry.valid())
{
_pointGeometry->compileGLObjects(renderInfo);
if (_pointGeometry->getStateSet()) _pointGeometry->getStateSet()->compileGLObjects(*renderInfo.getState());
}
}
示例10: drawInner
void RenderStageEx::drawInner(osg::RenderInfo &renderInfo, osgUtil::RenderLeaf *&previous, bool &doCopyTexture)
{
struct SubFunc
{
static void applyReadFBO(bool& apply_read_fbo,
const FrameBufferObject* read_fbo, osg::State& state)
{
if (read_fbo->isMultisample())
{
OSG_WARN << "Attempting to read from a"
" multisampled framebuffer object. Set a resolve"
" framebuffer on the RenderStage to fix this." << std::endl;
}
if (apply_read_fbo)
{
// Bind the monosampled FBO to read from
read_fbo->apply(state, FrameBufferObject::READ_FRAMEBUFFER);
apply_read_fbo = false;
}
}
};
osg::State& state = *renderInfo.getState();
#if 1
#if OSG_MIN_VERSION_REQUIRED(3,3,7)
osg::GLExtensions* fbo_ext = state.get<osg::GLExtensions>();
bool fbo_supported = fbo_ext && fbo_ext->isFrameBufferObjectSupported;
bool using_multiple_render_targets = fbo_supported && _fbo.valid() && _fbo->hasMultipleRenderingTargets();
#else
osg::FBOExtensions* fbo_ext = osg::FBOExtensions::instance(state.getContextID(), true);
bool fbo_supported = fbo_ext && fbo_ext->isSupported();
bool using_multiple_render_targets = fbo_supported && _fbo.valid() && _fbo->hasMultipleRenderingTargets();
#endif
if (fbo_supported)
{
if(_fbo.valid())
{
if (!_fbo->hasMultipleRenderingTargets())
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
if( getDrawBufferApplyMask() )
glDrawBuffer(_drawBuffer);
if( getReadBufferApplyMask() )
glReadBuffer(_readBuffer);
#endif
}
_fbo->apply(state);
}
else
{
fbo_ext->glBindFramebuffer(osg::FrameBufferObject::READ_DRAW_FRAMEBUFFER, static_cast<StateEx *>(&state)->getDefaultFbo());
}
}
#else
osg::FBOExtensions* fbo_ext = _fbo.valid() ? osg::FBOExtensions::instance(state.getContextID(),true) : 0;
bool fbo_supported = fbo_ext && fbo_ext->isSupported();
bool using_multiple_render_targets = fbo_supported && _fbo->hasMultipleRenderingTargets();
if (!using_multiple_render_targets)
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
if( getDrawBufferApplyMask() )
glDrawBuffer(_drawBuffer);
if( getReadBufferApplyMask() )
glReadBuffer(_readBuffer);
#endif
}
if (fbo_supported)
{
_fbo->apply(state);
}
#endif
// GLint fboId;
// glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &fboId);
// std::cout << fboId << std::endl;
RenderBin::draw(renderInfo,previous);
if(state.getCheckForGLErrors()!=osg::State::NEVER_CHECK_GL_ERRORS)
{
if (state.checkGLErrors("after RenderBin::draw(..)"))
{
if ( fbo_ext )
{
//.........这里部分代码省略.........