fix examples context creation for X11

(when display not :0.0)
This commit is contained in:
mp3butcher
2018-09-08 18:18:33 +02:00
committed by Robert Osfield
parent 960f4d1ef2
commit 385cfa0cbf
18 changed files with 144 additions and 64 deletions

View File

@@ -45,6 +45,8 @@ class MyGraphicsContext {
traits->doubleBuffer = false; traits->doubleBuffer = false;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->pbuffer = true; traits->pbuffer = true;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
_gc = osg::GraphicsContext::createGraphicsContext(traits.get()); _gc = osg::GraphicsContext::createGraphicsContext(traits.get());

View File

@@ -249,6 +249,8 @@ int main( int argc, char **argv )
traits->width = 1 << 12; traits->width = 1 << 12;
traits->height = 1 << 12; traits->height = 1 << 12;
traits->pbuffer = true; traits->pbuffer = true;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
} }
osg::ref_ptr<osg::GraphicsContext> pbuffer = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> pbuffer = osg::GraphicsContext::createGraphicsContext(traits.get());
if (pbuffer.valid()) if (pbuffer.valid())

View File

@@ -209,6 +209,8 @@ osgViewer::View* createView(osg::ref_ptr<osg::Node> scenegraph, osg::ref_ptr<osg
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
gc = osg::GraphicsContext::createGraphicsContext(traits.get()); gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc) if (!gc)
@@ -267,7 +269,11 @@ int main(int argc, char** argv)
} }
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
unsigned int x=0, y=0; unsigned int x=0, y=0;
while(arguments.read("--window", x, y, width, height)) {} while(arguments.read("--window", x, y, width, height)) {}
@@ -283,6 +289,8 @@ int main(int argc, char** argv)
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
gc = osg::GraphicsContext::createGraphicsContext(traits.get()); gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc) if (!gc)

View File

@@ -83,7 +83,11 @@ void singleWindowMultipleCameras(osgViewer::Viewer& viewer)
} }
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0; traits->x = 0;
@@ -93,6 +97,8 @@ void singleWindowMultipleCameras(osgViewer::Viewer& viewer)
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid()) if (gc.valid())
@@ -134,7 +140,11 @@ void multipleWindowMultipleCameras(osgViewer::Viewer& viewer, bool multipleScree
} }
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
unsigned int numCameras = 6; unsigned int numCameras = 6;
@@ -151,6 +161,8 @@ void multipleWindowMultipleCameras(osgViewer::Viewer& viewer, bool multipleScree
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid()) if (gc.valid())

View File

@@ -289,7 +289,11 @@ int main( int argc, char **argv )
} }
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 100; traits->x = 100;
@@ -299,6 +303,8 @@ int main( int argc, char **argv )
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid()) if (gc.valid())

View File

@@ -79,7 +79,11 @@ struct CommandLineOptions
return; return;
} }
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius); distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
} }
@@ -274,6 +278,8 @@ void setDomeFaces(osgViewer::Viewer& viewer, CommandLineOptions& options)
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc) if (!gc)
@@ -502,6 +508,8 @@ void setDomeCorrection(osgViewer::Viewer& viewer, CommandLineOptions& options)
traits->windowDecoration = false; traits->windowDecoration = false;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc) if (!gc)

View File

@@ -722,6 +722,8 @@ GraphicsContext* setupGC(osgViewer::Viewer& viewer, ArgumentParser& arguments)
traits->windowDecoration = decoration; traits->windowDecoration = decoration;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
ref_ptr<GraphicsContext> gc = GraphicsContext::createGraphicsContext(traits.get()); ref_ptr<GraphicsContext> gc = GraphicsContext::createGraphicsContext(traits.get());
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get()); osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());

View File

@@ -48,7 +48,7 @@ class MoveEarthySkyWithEyePointTransform : public osg::Transform
{ {
public: public:
/** Get the transformation matrix which moves from local coords to world coords.*/ /** Get the transformation matrix which moves from local coords to world coords.*/
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{ {
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv); osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv) if (cv)
@@ -63,7 +63,7 @@ public:
virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{ {
std::cout<<"computing transform"<<std::endl; std::cout<<"computing transform"<<std::endl;
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv); osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv) if (cv)
{ {
@@ -99,7 +99,7 @@ osg::Group* createModel()
// add the sky and base layer. // add the sky and base layer.
transform->addChild(makeSky()); // bin number -2 so drawn first. transform->addChild(makeSky()); // bin number -2 so drawn first.
transform->addChild(makeBase()); // bin number -1 so draw second. transform->addChild(makeBase()); // bin number -1 so draw second.
// add the transform to the earth sky. // add the transform to the earth sky.
clearNode->addChild(transform); clearNode->addChild(transform);
@@ -138,14 +138,14 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->write(std::cout); arguments.getApplicationUsage()->write(std::cout);
return 1; return 1;
} }
bool customWindows = false; bool customWindows = false;
while(arguments.read("-2")) customWindows = true; while(arguments.read("-2")) customWindows = true;
if (customWindows) if (customWindows)
{ {
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi) if (!wsi)
{ {
osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<<std::endl; osg::notify(osg::NOTICE)<<"View::setUpViewAcrossAllScreens() : Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return 0; return 0;
@@ -159,6 +159,8 @@ int main( int argc, char **argv )
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid()) if (gc.valid())
@@ -186,17 +188,17 @@ int main( int argc, char **argv )
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::scale(aspectRatioScale,1.0,1.0)); viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd::scale(aspectRatioScale,1.0,1.0));
} }
} }
else else
{ {
viewer.setUpViewAcrossAllScreens(); viewer.setUpViewAcrossAllScreens();
} }
// set up the camera manipulation with our custom manipultor // set up the camera manipulation with our custom manipultor
viewer.setCameraManipulator(new GliderManipulator()); viewer.setCameraManipulator(new GliderManipulator());
// pass the scene graph to the viewer // pass the scene graph to the viewer
viewer.setSceneData( createModel() ); viewer.setSceneData( createModel() );
return viewer.run(); return viewer.run();

View File

@@ -57,7 +57,7 @@ class ContextTest : public MemoryTest
_width(width), _width(width),
_height(height), _height(height),
_pbuffer(pbuffer) {} _pbuffer(pbuffer) {}
virtual osg::GraphicsContext* allocate() virtual osg::GraphicsContext* allocate()
{ {
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
@@ -65,9 +65,11 @@ class ContextTest : public MemoryTest
traits->height = _height; traits->height = _height;
traits->windowDecoration = true; traits->windowDecoration = true;
traits->pbuffer = _pbuffer; traits->pbuffer = _pbuffer;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> window = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> window = osg::GraphicsContext::createGraphicsContext(traits.get());
if (window.valid()) if (window.valid())
{ {
if (window->realize()) if (window->realize())
{ {
@@ -82,15 +84,15 @@ class ContextTest : public MemoryTest
else else
{ {
std::cerr<<"Error: Unable to create graphics context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot create windows/pbuffers."<<std::endl; std::cerr<<"Error: Unable to create graphics context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot create windows/pbuffers."<<std::endl;
if (_pbuffer) throw "Failed to create PixelBuffer"; if (_pbuffer) throw "Failed to create PixelBuffer";
else throw "Failed to create GraphicsWindow"; else throw "Failed to create GraphicsWindow";
} }
} }
protected: protected:
int _width; int _width;
int _height; int _height;
bool _pbuffer; bool _pbuffer;
@@ -102,19 +104,19 @@ class ContextTest : public MemoryTest
class StateAttributeObject : public GLObject class StateAttributeObject : public GLObject
{ {
public: public:
StateAttributeObject(osg::StateAttribute* sa): _attribute(sa) {} StateAttributeObject(osg::StateAttribute* sa): _attribute(sa) {}
void apply(osg::RenderInfo& renderInfo) void apply(osg::RenderInfo& renderInfo)
{ {
_attribute->apply(*renderInfo.getState()); _attribute->apply(*renderInfo.getState());
if (renderInfo.getState()->checkGLErrors(_attribute.get())) if (renderInfo.getState()->checkGLErrors(_attribute.get()))
{ {
throw "OpenGL error"; throw "OpenGL error";
} }
} }
osg::ref_ptr<osg::StateAttribute> _attribute; osg::ref_ptr<osg::StateAttribute> _attribute;
}; };
@@ -129,40 +131,40 @@ class TextureTest : public GLMemoryTest
_width(width), _width(width),
_height(height), _height(height),
_depth(depth) {} _depth(depth) {}
virtual GLObject* allocate() virtual GLObject* allocate()
{ {
if (_depth>1) if (_depth>1)
{ {
osg::ref_ptr<osg::Image> image = new osg::Image; osg::ref_ptr<osg::Image> image = new osg::Image;
image->allocateImage(_width, _height, _depth, GL_RGBA, GL_UNSIGNED_BYTE); image->allocateImage(_width, _height, _depth, GL_RGBA, GL_UNSIGNED_BYTE);
osg::ref_ptr<osg::Texture3D> texture = new osg::Texture3D; osg::ref_ptr<osg::Texture3D> texture = new osg::Texture3D;
texture->setImage(image.get()); texture->setImage(image.get());
texture->setResizeNonPowerOfTwoHint(false); texture->setResizeNonPowerOfTwoHint(false);
return new StateAttributeObject(texture.get()); return new StateAttributeObject(texture.get());
} }
if (_height>1) if (_height>1)
{ {
osg::ref_ptr<osg::Image> image = new osg::Image; osg::ref_ptr<osg::Image> image = new osg::Image;
image->allocateImage(_width, _height, 1, GL_RGBA, GL_UNSIGNED_BYTE); image->allocateImage(_width, _height, 1, GL_RGBA, GL_UNSIGNED_BYTE);
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D; osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setImage(image.get()); texture->setImage(image.get());
texture->setResizeNonPowerOfTwoHint(false); texture->setResizeNonPowerOfTwoHint(false);
return new StateAttributeObject(texture.get()); return new StateAttributeObject(texture.get());
} }
if (_width>1) if (_width>1)
{ {
osg::ref_ptr<osg::Image> image = new osg::Image; osg::ref_ptr<osg::Image> image = new osg::Image;
image->allocateImage(_width, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE); image->allocateImage(_width, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE);
osg::ref_ptr<osg::Texture1D> texture = new osg::Texture1D; osg::ref_ptr<osg::Texture1D> texture = new osg::Texture1D;
texture->setImage(image.get()); texture->setImage(image.get());
texture->setResizeNonPowerOfTwoHint(false); texture->setResizeNonPowerOfTwoHint(false);
return new StateAttributeObject(texture.get()); return new StateAttributeObject(texture.get());
} }
else else
@@ -170,10 +172,10 @@ class TextureTest : public GLMemoryTest
throw "Invalid texture size of 0,0,0"; throw "Invalid texture size of 0,0,0";
} }
} }
protected: protected:
int _width; int _width;
int _height; int _height;
int _depth; int _depth;
@@ -191,7 +193,7 @@ class FboTest : public GLMemoryTest
_width(width), _width(width),
_height(height), _height(height),
_depth(depth) {} _depth(depth) {}
virtual GLObject* allocate() virtual GLObject* allocate()
{ {
osg::ref_ptr<osg::FrameBufferObject> fbo = new osg::FrameBufferObject; osg::ref_ptr<osg::FrameBufferObject> fbo = new osg::FrameBufferObject;
@@ -201,10 +203,10 @@ class FboTest : public GLMemoryTest
return new StateAttributeObject(fbo.get()); return new StateAttributeObject(fbo.get());
} }
protected: protected:
int _width; int _width;
int _height; int _height;
int _depth; int _depth;
@@ -218,19 +220,19 @@ class FboTest : public GLMemoryTest
class DrawableObject : public GLObject class DrawableObject : public GLObject
{ {
public: public:
DrawableObject(osg::Drawable* drawable): _drawable(drawable) {} DrawableObject(osg::Drawable* drawable): _drawable(drawable) {}
void apply(osg::RenderInfo& renderInfo) void apply(osg::RenderInfo& renderInfo)
{ {
_drawable->draw(renderInfo); _drawable->draw(renderInfo);
if (renderInfo.getState()->checkGLErrors("Drawable")) if (renderInfo.getState()->checkGLErrors("Drawable"))
{ {
throw "OpenGL error"; throw "OpenGL error";
} }
} }
osg::ref_ptr<osg::Drawable> _drawable; osg::ref_ptr<osg::Drawable> _drawable;
}; };
@@ -240,20 +242,20 @@ class DrawableObject : public GLObject
class GeometryTest : public GLMemoryTest class GeometryTest : public GLMemoryTest
{ {
public: public:
enum GLObjectType enum GLObjectType
{ {
VERTEX_ARRAY, VERTEX_ARRAY,
DISPLAY_LIST, DISPLAY_LIST,
VERTEX_BUFFER_OBJECT VERTEX_BUFFER_OBJECT
}; };
GeometryTest(GLObjectType type, int width=64, int height=64): GeometryTest(GLObjectType type, int width=64, int height=64):
_glObjectType(type), _glObjectType(type),
_width(width), _width(width),
_height(height) {} _height(height) {}
virtual GLObject* allocate() virtual GLObject* allocate()
{ {
unsigned int numVertices = _width * _height; unsigned int numVertices = _width * _height;
@@ -279,11 +281,11 @@ class GeometryTest : public GLMemoryTest
quads->push_back(i + (j+1)*_width); quads->push_back(i + (j+1)*_width);
} }
} }
osg::Geometry* geometry = new osg::Geometry; osg::Geometry* geometry = new osg::Geometry;
geometry->setVertexArray(vertices); geometry->setVertexArray(vertices);
geometry->addPrimitiveSet(quads); geometry->addPrimitiveSet(quads);
switch(_glObjectType) switch(_glObjectType)
{ {
case(VERTEX_ARRAY): case(VERTEX_ARRAY):
@@ -302,10 +304,10 @@ class GeometryTest : public GLMemoryTest
return new DrawableObject(geometry); return new DrawableObject(geometry);
} }
protected: protected:
GLObjectType _glObjectType; GLObjectType _glObjectType;
int _width; int _width;
int _height; int _height;
@@ -314,7 +316,7 @@ class GeometryTest : public GLMemoryTest
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
osg::ArgumentParser arguments(&argc,argv); osg::ArgumentParser arguments(&argc,argv);
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" tests OpenGL and Windowing memory scalability.."); arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" tests OpenGL and Windowing memory scalability..");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","List command line options."); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","List command line options.");
@@ -351,7 +353,7 @@ int main( int argc, char **argv )
ContextTests contextTests; ContextTests contextTests;
GLMemoryTests glMemoryTests; GLMemoryTests glMemoryTests;
int width, height, depth; int width, height, depth;
while(arguments.read("--pbuffer",width,height)) { contextTests.push_back(new ContextTest(width, height, true)); } while(arguments.read("--pbuffer",width,height)) { contextTests.push_back(new ContextTest(width, height, true)); }
while(arguments.read("--pbuffer")) { contextTests.push_back(new ContextTest(512, 512, true)); } while(arguments.read("--pbuffer")) { contextTests.push_back(new ContextTest(512, 512, true)); }
@@ -396,20 +398,20 @@ int main( int argc, char **argv )
return 1; return 1;
} }
#endif #endif
typedef std::list< osg::ref_ptr<osg::GraphicsContext> > Contexts; typedef std::list< osg::ref_ptr<osg::GraphicsContext> > Contexts;
typedef std::list< osg::ref_ptr<GLObject> > GLObjects; typedef std::list< osg::ref_ptr<GLObject> > GLObjects;
Contexts allocatedContexts; Contexts allocatedContexts;
GLObjects glObjects; GLObjects glObjects;
if (contextTests.empty()) if (contextTests.empty())
{ {
if (glMemoryTests.empty()) if (glMemoryTests.empty())
{ {
std::cout<<"No tests specified, please specify test using the command line options below."<<std::endl<<std::endl; std::cout<<"No tests specified, please specify test using the command line options below."<<std::endl<<std::endl;
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1; return 1;
} }
else else
{ {
@@ -421,14 +423,14 @@ int main( int argc, char **argv )
// use printf's below as C++'s ostream classes use more memory and are more likely to fail when everything // use printf's below as C++'s ostream classes use more memory and are more likely to fail when everything
// goes wrong with memory allocations. // goes wrong with memory allocations.
int numContextIterations = 0; int numContextIterations = 0;
int numGLObjectIterations = 0; int numGLObjectIterations = 0;
int numGLObjectsApplied = 0; int numGLObjectsApplied = 0;
try try
{ {
for(; numGLObjectIterations<maxNumGLIterations; ++numGLObjectIterations) for(; numGLObjectIterations<maxNumGLIterations; ++numGLObjectIterations)
{ {
for(GLMemoryTests::iterator itr = glMemoryTests.begin(); for(GLMemoryTests::iterator itr = glMemoryTests.begin();
itr != glMemoryTests.end(); itr != glMemoryTests.end();
++itr) ++itr)
@@ -437,7 +439,7 @@ int main( int argc, char **argv )
if (glObject.valid()) glObjects.push_back(glObject.get()); if (glObject.valid()) glObjects.push_back(glObject.get());
} }
} }
for(;numContextIterations<maxNumContextIterations; ++numContextIterations) for(;numContextIterations<maxNumContextIterations; ++numContextIterations)
{ {
printf("GraphicsContext %i\n",numContextIterations); printf("GraphicsContext %i\n",numContextIterations);
@@ -451,10 +453,10 @@ int main( int argc, char **argv )
allocatedContexts.push_back(context); allocatedContexts.push_back(context);
context->makeCurrent(); context->makeCurrent();
osg::RenderInfo renderInfo; osg::RenderInfo renderInfo;
renderInfo.setState(context->getState()); renderInfo.setState(context->getState());
for(GLObjects::iterator gitr = glObjects.begin(); for(GLObjects::iterator gitr = glObjects.begin();
gitr != glObjects.end(); gitr != glObjects.end();
++gitr) ++gitr)
@@ -466,9 +468,9 @@ int main( int argc, char **argv )
(*gitr)->apply(renderInfo); (*gitr)->apply(renderInfo);
++numGLObjectsApplied; ++numGLObjectsApplied;
} }
context->releaseContext(); context->releaseContext();
printf("\n\n"); fflush(stdout); printf("\n\n"); fflush(stdout);
} }
} }
@@ -489,7 +491,7 @@ int main( int argc, char **argv )
printf("\nSuccessful completion, contexts created = %i, gl objects applied = %i\n",numContextIterations, numGLObjectsApplied); printf("\nSuccessful completion, contexts created = %i, gl objects applied = %i\n",numContextIterations, numGLObjectsApplied);
printf("Duration = %f seconds.\n\n",osg::Timer::instance()->delta_s(startTick, endTick)); printf("Duration = %f seconds.\n\n",osg::Timer::instance()->delta_s(startTick, endTick));
return 0; return 0;
} }

View File

@@ -641,7 +641,11 @@ int main(int argc, char** argv)
if (wsi) if (wsi)
{ {
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
screenAspectRatio = float(width) / float(height); screenAspectRatio = float(width) / float(height);
} }

View File

@@ -91,7 +91,11 @@ int main( int argc, char **argv )
} }
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 100; traits->x = 100;
@@ -101,6 +105,8 @@ int main( int argc, char **argv )
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid()) if (gc.valid())

View File

@@ -443,6 +443,8 @@ int main( int argc, char **argv )
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->windowName = "Receiver / view two"; traits->windowName = "Receiver / view two";
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
@@ -509,6 +511,8 @@ int main( int argc, char **argv )
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->windowName = "Sender / view one"; traits->windowName = "Sender / view one";
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());

View File

@@ -712,6 +712,8 @@ int main(int argc, char** argv)
traits->pbuffer = true; traits->pbuffer = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
pbuffer = osg::GraphicsContext::createGraphicsContext(traits.get()); pbuffer = osg::GraphicsContext::createGraphicsContext(traits.get());
if (pbuffer.valid()) if (pbuffer.valid())

View File

@@ -182,7 +182,11 @@ void singleWindowSideBySideCameras(osgViewer::Viewer& viewer)
} }
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
@@ -198,6 +202,8 @@ void singleWindowSideBySideCameras(osgViewer::Viewer& viewer)
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (gc.valid()) if (gc.valid())

View File

@@ -87,6 +87,8 @@ int main( int argc, char** argv )
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->glContextVersion = version; traits->glContextVersion = version;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr< osg::GraphicsContext > gc = osg::GraphicsContext::createGraphicsContext( traits.get() ); osg::ref_ptr< osg::GraphicsContext > gc = osg::GraphicsContext::createGraphicsContext( traits.get() );
if( !gc.valid() ) if( !gc.valid() )
{ {

View File

@@ -142,6 +142,8 @@ int main( int argc, char **argv )
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->pbuffer = false; traits->pbuffer = false;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc || !gc->valid()) if (!gc || !gc->valid())

View File

@@ -146,7 +146,11 @@ int main(int argc, char** argv)
unsigned int width, height; unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); osg::GraphicsContext::ScreenIdentifier main_screen_id;
main_screen_id.readDISPLAY();
main_screen_id.setUndefinedScreenDetailsToDefaultScreen();
wsi->getScreenResolution(main_screen_id, width, height);
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0; traits->x = 0;
@@ -155,6 +159,8 @@ int main(int argc, char** argv)
traits->height = height; traits->height = height;
traits->windowDecoration = false; traits->windowDecoration = false;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc) if (!gc)

View File

@@ -58,6 +58,8 @@ int main( int argc, char **argv )
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
@@ -82,6 +84,8 @@ int main( int argc, char **argv )
traits->windowDecoration = true; traits->windowDecoration = true;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = 0; traits->sharedContext = 0;
traits->readDISPLAY();
traits->setUndefinedScreenDetailsToDefaultScreen();
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());