本文整理汇总了C++中osg::RenderInfo类的典型用法代码示例。如果您正苦于以下问题:C++ RenderInfo类的具体用法?C++ RenderInfo怎么用?C++ RenderInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
CloudsDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
renderInfo.getState()->disableAllVertexArrays();
_SL->getAtmosphere()->DrawObjects( true, true, true );
renderInfo.getState()->dirtyAllVertexArrays();
}
示例2:
void SilverLiningNode::SkyDrawable::drawImplementation( osg::RenderInfo& renderInfo ) const
{
renderInfo.getState()->disableAllVertexArrays();
_silverLining->initializeSilverLining( renderInfo );
_silverLining->atmosphere()->DrawSky( true, false, 0.0, true, false );
renderInfo.getState()->dirtyAllVertexArrays();
}
示例3: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
if (!_frameCapture)
{
OSG_NOTICE<<"No FrameCamera assigned"<<std::endl;
return;
}
unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber();
CameraNumMap::const_iterator itr = _cameraNumMap.find(renderInfo.getCurrentCamera());
std::string outputFileName = (itr!=_cameraNumMap.end()) ?
_frameCapture->getOutputFileName(itr->second, frameNumber) :
_frameCapture->getOutputFileName(frameNumber);
OSG_NOTICE<<"outputFileName="<<outputFileName<<std::endl;
osg::Camera* camera = renderInfo.getCurrentCamera();
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (viewport)
{
OSG_NOTICE<<"Doing read of ="<<viewport->x()<<", "<<viewport->y()<<", "<<viewport->width()<<", "<<viewport->height()<<" with pixelFormat=0x"<<std::hex<<_pixelFormat<<std::dec<<std::endl;
glReadBuffer(camera->getDrawBuffer());
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(),
_pixelFormat, GL_UNSIGNED_BYTE, 1);
if (_flip) image->flipVertical();
osgDB::writeImageFile(*image, outputFileName);
}
}
示例4: drawImplementation
void SomePointsGenerator::drawImplementation( osg::RenderInfo& renderInfo ) const
{
//get output buffer
unsigned int contextID = renderInfo.getState()->getContextID();
GLuint ubuff= genbuffer->getOrCreateGLBufferObject(contextID)->getGLObjectID();
osg::GLExtensions* ext = renderInfo.getState()->get<osg::GLExtensions>();
ext->glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0,ubuff);
glEnable(GL_RASTERIZER_DISCARD);
ext->glBeginTransformFeedback(GL_POINTS);
osg::Geometry::drawImplementation( renderInfo );
ext->glEndTransformFeedback();
glDisable(GL_RASTERIZER_DISCARD);
ext->glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
}
示例5: drawImplementation
void dustDrawable::drawImplementation(osg::RenderInfo &renderInfo) const
{
if (renderer != NULL)
{
osg::ref_ptr<osg::StateSet> currentState = new osg::StateSet;
renderInfo.getState()->captureCurrentState(*currentState);
renderInfo.getState()->pushStateSet(currentState.get());
// Save the current state
glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
glPushAttrib(GL_ALL_ATTRIB_BITS);
/* enum DisplayMode
{
PARTICLE_POINTS,
PARTICLE_SPRITES,
PARTICLE_SPRITES_COLOR,
PARTICLE_NUM_MODES
*/
if (starDust::instance()->tuiRender->getState())
{
renderer->setSpriteSize(starDust::instance()->particleSize);
renderer->display(ParticleRenderer::PARTICLE_SPRITES, cudaParticles->getNumActiveParticles());
//renderer->display(ParticleRenderer::PARTICLE_POINTS);
}
// Restore the current state
glPopAttrib();
glPopClientAttrib();
renderInfo.getState()->popStateSet();
}
}
示例6: drawImplementation
virtual void drawImplementation( osg::RenderInfo& renderInfo ) const
{
unsigned int contextID = renderInfo.getContextID();
if ( !_initialized )
{
NanoVGDrawable* constMe = const_cast<NanoVGDrawable*>(this);
glewInit();
constMe->_vg = nvgCreateGL2( NVG_ANTIALIAS|NVG_STENCIL_STROKES|NVG_DEBUG );
if ( !constMe->_vg )
{
OSG_NOTICE << "[NanoVGDrawable] Failed to create VG context" << std::endl;
return;
}
constMe->initializeGL( renderInfo.getState() );
constMe->_activeContextID = contextID;
constMe->_initialized = true;
}
else if ( _vg && contextID==_activeContextID )
{
osg::State* state = renderInfo.getState();
state->disableAllVertexArrays();
state->disableTexCoordPointer( 0 );
nvgBeginFrame( _vg, _width, _height, 1.0f );
updateGL( state );
nvgEndFrame( _vg );
}
}
示例7:
void
LayerDrawable::drawImplementation(osg::RenderInfo& ri) const
{
DrawState& ds = *_drawState;
// Make sure the draw state is up to date:
ds.refresh(ri);
if (ds._layerOrderUL >= 0)
{
ds._ext->glUniform1i(ds._layerOrderUL, (GLint)_order);
}
if (_layer)
{
if (ds._layerUidUL >= 0)
ds._ext->glUniform1i(ds._layerUidUL, (GLint)_layer->getUID());
if (ds._layerOpacityUL >= 0 && _imageLayer)
ds._ext->glUniform1f(ds._layerOpacityUL, (GLfloat)_imageLayer->getOpacity());
if (ds._layerMinRangeUL >= 0 && _imageLayer)
ds._ext->glUniform1f(ds._layerMinRangeUL, (GLfloat)_imageLayer->getMinVisibleRange());
if (ds._layerMaxRangeUL >= 0 && _imageLayer)
ds._ext->glUniform1f(ds._layerMaxRangeUL, (GLfloat)_imageLayer->getMaxVisibleRange());
}
else
{
if (ds._layerUidUL >= 0)
ds._ext->glUniform1i(ds._layerUidUL, (GLint)-1);
if (ds._layerOpacityUL >= 0)
ds._ext->glUniform1f(ds._layerOpacityUL, (GLfloat)1.0f);
if (ds._layerMinRangeUL >= 0)
ds._ext->glUniform1f(ds._layerMinRangeUL, (GLfloat)0.0f);
if (ds._layerMaxRangeUL >= 0)
ds._ext->glUniform1f(ds._layerMaxRangeUL, (GLfloat)FLT_MAX);
}
for (DrawTileCommands::const_iterator tile = _tiles.begin(); tile != _tiles.end(); ++tile)
{
tile->draw(ri, ds, 0L);
}
// If set, dirty all OSG state to prevent any leakage - this is sometimes
// necessary when doing custom OpenGL within a Drawable.
if (_clearOsgState)
{
ri.getState()->dirtyAllAttributes();
ri.getState()->dirtyAllModes();
ri.getState()->dirtyAllVertexArrays();
// unbind local buffers when finished.
ds._ext->glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
ds._ext->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);
// gw: no need to do this, in fact it will cause positional attributes
// (light clip planes and lights) to immediately be reapplied under the
// current MVM, which will by definition be wrong!)
//ri.getState()->apply();
}
}
示例8: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, mWidth, mHeight);
// Callback removes itself when done
if (renderInfo.getCurrentCamera())
renderInfo.getCurrentCamera()->setInitialDrawCallback(NULL);
}
示例9: drawImplementation
void Skybox::drawImplementation(osg::RenderInfo& renderInfo) const{
int positionCote=mSize/2;
Vec3Array* boxVertices = new osg::Vec3Array;
boxVertices->push_back(Vec3f(-positionCote,-positionCote,-positionCote)); //back bottom left 0
boxVertices->push_back(Vec3f(positionCote,-positionCote,-positionCote)); //back bottom right 1
boxVertices->push_back(Vec3f(positionCote,positionCote,-positionCote)); //back up right 2
boxVertices->push_back(Vec3f(-positionCote,positionCote,-positionCote)); //back up left 3
boxVertices->push_back(Vec3f(-positionCote,-positionCote,positionCote)); //front bottom left 4
boxVertices->push_back(Vec3f(positionCote,-positionCote,positionCote)); //front bottom right 5
boxVertices->push_back(Vec3f(positionCote,positionCote,positionCote)); //front up right 6
boxVertices->push_back(Vec3f(-positionCote,positionCote,positionCote)); //front up left 7
osg::ref_ptr<osg::Texture2D> texture (new osg::Texture2D(image.get()));
osg::ref_ptr<osg::StateSet> texSS (new osg::StateSet);
texture->setInternalFormat(GL_RGBA);
texture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
texture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
texSS->setTextureAttributeAndModes (0, texture.get(), osg::StateAttribute::ON);
texSS->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
renderInfo.getState()->apply(texSS.get());
boxVertices->at(0)._v;
glBegin(GL_QUADS);
glTexCoord2f(1.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(0)._v);
glTexCoord2f(2.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(1)._v);
glTexCoord2f(2.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(2)._v);
glTexCoord2f(1.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(3)._v);
glTexCoord2f(1.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(0)._v);
glTexCoord2f(0, 1.01/3.0);glVertex3fv(boxVertices->at(4)._v);
glTexCoord2f(0, 1.99/3.0);glVertex3fv(boxVertices->at(7)._v);
glTexCoord2f(1.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(3)._v);
glTexCoord2f(1, 1.01/3.0);glVertex3fv(boxVertices->at(4)._v);
glTexCoord2f(3.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(5)._v);
glTexCoord2f(3.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(6)._v);
glTexCoord2f(1, 1.99/3.0);glVertex3fv(boxVertices->at(7)._v);
glTexCoord2f(2.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(1)._v);
glTexCoord2f(3.0/4.0, 1.01/3.0);glVertex3fv(boxVertices->at(5)._v);
glTexCoord2f(3.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(6)._v);
glTexCoord2f(2.0/4.0, 1.99/3.0);glVertex3fv(boxVertices->at(2)._v);
glTexCoord2f(1.01/4.0, 0);glVertex3fv(boxVertices->at(0)._v);
glTexCoord2f(1.99/4.0, 0);glVertex3fv(boxVertices->at(1)._v);
glTexCoord2f(1.99/4.0, 1.0/3.0);glVertex3fv(boxVertices->at(5)._v);
glTexCoord2f(1.01/4.0, 1.0/3.0);glVertex3fv(boxVertices->at(4)._v);
glTexCoord2f(1.99/4.0, 2.0/3.0);glVertex3fv(boxVertices->at(2)._v);
glTexCoord2f(1.01/4.0, 2.0/3.0);glVertex3fv(boxVertices->at(3)._v);
glTexCoord2f(1.01/4.0, 1);glVertex3fv(boxVertices->at(7)._v);
glTexCoord2f(1.99/4.0, 1);glVertex3fv(boxVertices->at(6)._v);
glEnd();
renderInfo.getState()->apply();
}
示例10: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
int w = renderInfo.getCurrentCamera()->getViewport()->width();
int h = renderInfo.getCurrentCamera()->getViewport()->height();
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
// Callback removes itself when done
if (renderInfo.getCurrentCamera())
renderInfo.getCurrentCamera()->setInitialDrawCallback(NULL);
}
示例11: operator
void Camera::DrawCallback::operator () (osg::RenderInfo& renderInfo) const
{
if (renderInfo.getCurrentCamera())
{
operator()(*(renderInfo.getCurrentCamera()));
}
else
{
OSG_WARN<<"Error: Camera::DrawCallback called without valid camera."<<std::endl;
}
}
示例12:
void ossimPlanetViewer::DrawCallback::operator () (osg::RenderInfo& renderInfo) const
{
if(!theViewer) return;
if(theViewer->terrainLayer()&&renderInfo.getState())
{
//double delta = osg::Timer::instance()->delta_s(theViewer->theFrameStartTimeStamp,
// osg::Timer::instance()->tick());
theViewer->terrainLayer()->compileGLObjects(*renderInfo.getState(),
theViewer->terrainLayer()->minimumTimeToCompilePerFrame());
}
}
示例13: draw
void RenderBin::draw(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
{
renderInfo.pushRenderBin(this);
if (_drawCallback.valid())
{
_drawCallback->drawImplementation(this,renderInfo,previous);
}
else drawImplementation(renderInfo,previous);
renderInfo.popRenderBin();
}
示例14: drawImplementation
void drawImplementation(osg::RenderInfo& renderInfo, const osg::Drawable* drawable) const
{
unsigned contextID = renderInfo.getState()->getContextID();
osg::GLBufferObject* bo = _vbo->getOrCreateGLBufferObject(contextID);
if ( bo->isDirty() )
bo->compileBuffer();
GLuint objID = bo->getGLObjectID();
osg::GLExtensions* ext = renderInfo.getState()->get<osg::GLExtensions>();
GLuint numPrims = 0;
GLuint& query = _queries[contextID];
if ( query == INT_MAX )
{
ext->glGenQueries(1, &query);
}
else
{
ext->glGetQueryObjectuiv(query, GL_QUERY_RESULT, &numPrims);
s_numInstancesToDraw = numPrims;
}
ext->glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, objID, _offset, _size);
//if ( renderInfo.getState()->checkGLErrors("PRE:glBindBufferBase") ) exit(0);
glEnable(GL_RASTERIZER_DISCARD);
//if ( renderInfo.getState()->checkGLErrors("PRE:glEnable(GL_RASTERIZER_DISCARD)") ) exit(0);
ext->glBeginQuery(TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query);
ext->glBeginTransformFeedback(GL_POINTS); // get from input geom?
//if ( renderInfo.getState()->checkGLErrors("PRE:glBeginTransformFeedback(GL_POINTS)") ) exit(0);
drawable->drawImplementation(renderInfo);
ext->glEndTransformFeedback();
//if ( renderInfo.getState()->checkGLErrors("POST:glEndTransformFeedback") ) exit(0);
ext->glEndQuery(TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
glDisable(GL_RASTERIZER_DISCARD);
//if ( renderInfo.getState()->checkGLErrors("POST:glDisable(GL_RASTERIZER_DISCARD)") ) exit(0);
ext->glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
//if ( renderInfo.getState()->checkGLErrors("POST:glBindBufferBase") ) exit(0);
}
示例15: newThread
void
ScreenCapture::operator()( osg::RenderInfo& ri ) const
{
if( captureOn_ )
{
bool newThread( false );
if( wit_ == NULL )
{
wit_ = new WriteImageThread();
newThread = true;
}
osg::Image* image = new osg::Image;
image->setFileName(
getFileName( useFrameNum_ ? ri.getState()->getFrameStamp() : NULL ) );
osg::notify( osg::INFO ) << "ScreenCapture: Reading image for file " << image->getFileName() << " ... " << std::endl;
const osg::Viewport* vp( ( vp_ == NULL ) ?
ri.getState()->getCurrentViewport() : vp_.get() );
image->readPixels( vp->x(), vp->y(), vp->width(), vp->height(), GL_RGBA, GL_UNSIGNED_BYTE );
{
OpenThreads::ScopedLock< OpenThreads::Mutex > lock( wit_->lock_ );
wit_->imageList_.push_back( image );
}
if( numFrames_ > 0 )
{
if( --numFrames_ == 0 )
captureOn_ = false;
}
if( newThread )
wit_->start();
}
else
{
if( ( wit_ != NULL ) )
{
osg::notify( osg::INFO ) << "ScreenCapture: Thread cleanup" << std::endl;
if( wit_->isRunning() )
{
wit_->cancel();
wit_->join();
}
if( wit_->isRunning() )
osg::notify( osg::ALWAYS ) << "Thread is running after join() call." << std::endl;
delete wit_;
wit_ = NULL;
}
}
}