Ported osgbluemarble to osgViewer

This commit is contained in:
Robert Osfield
2007-01-05 16:13:43 +00:00
parent 0dd473007a
commit 3d0b511a00
5 changed files with 49 additions and 21 deletions

View File

@@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgbluemarble.cpp\
LIBS += -losgProducer -lProducer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgText -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
INSTFILES = \
$(CXXFILES)\

View File

@@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgbluemarble.cpp\
LIBS += -losgProducer -lProducer -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgViewer -losgDB -losgText -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgbluemarble

View File

@@ -23,26 +23,48 @@
#include <osgUtil/Optimizer>
#include <osgUtil/TriStripVisitor>
#include <osgProducer/Viewer>
#include <osgViewer/Viewer>
class GraphicsContext {
#include <iostream>
class MyGraphicsContext {
public:
GraphicsContext()
MyGraphicsContext()
{
rs = new Producer::RenderSurface;
rs->setWindowRectangle(0,0,1,1);
rs->useBorder(false);
rs->useConfigEventThread(false);
rs->realize();
std::cout<<"Realized window"<<std::endl;
}
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = 1;
traits->height = 1;
traits->windowDecoration = false;
traits->doubleBuffer = false;
traits->sharedContext = 0;
traits->pbuffer = true;
virtual ~GraphicsContext()
{
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!_gc)
{
osg::notify(osg::NOTICE)<<"Failed to create pbuffer, failing back to normal graphics window."<<std::endl;
traits->pbuffer = false;
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
}
if (_gc.valid())
{
_gc->realize();
_gc->makeCurrent();
std::cout<<"Realized window"<<std::endl;
}
}
bool valid() const { return _gc.valid() && _gc->isRealized(); }
private:
Producer::ref_ptr<Producer::RenderSurface> rs;
osg::ref_ptr<osg::GraphicsContext> _gc;
};
@@ -419,7 +441,13 @@ int main( int argc, char **argv )
// create a graphics context to allow us to use OpenGL to compress textures.
GraphicsContext gfx;
MyGraphicsContext gfx;
if (!gfx.valid() && useCompressedTextures)
{
osg::notify(osg::NOTICE)<<"Disabling texture compression due to inability to create OpenGL graphics context."<<std::endl;
useCompressedTextures = false;
}
createWorld(west_hemisphere,east_hemisphere,basename,(unsigned int)numLevels);