Added support WindowingSystemInterface for querring the number of screens, the screen size and creating GraphicsContexts.
This commit is contained in:
parent
982a4db9e2
commit
afc77f9b39
@ -148,7 +148,27 @@ int main( int argc, char **argv )
|
|||||||
std::cout<<"Error: failed to loading windowing library: "<<windowingLibrary<<std::endl;
|
std::cout<<"Error: failed to loading windowing library: "<<windowingLibrary<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int numberCameras = 3;
|
osg::GraphicsContext::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||||
|
if (!wsi)
|
||||||
|
{
|
||||||
|
std::cout<<"No WindowSystemInterface available, cannot create windows."<<std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int numScreens = wsi->getNumScreens();
|
||||||
|
for(unsigned int i=0; i<numScreens; ++i)
|
||||||
|
{
|
||||||
|
osg::GraphicsContext::ScreenIdentifier si;
|
||||||
|
si._screenNum = 0;
|
||||||
|
|
||||||
|
unsigned int width, height;
|
||||||
|
wsi->getScreenResolution(si, width, height);
|
||||||
|
|
||||||
|
std::cout<<"screen= "<<i<<" width="<<width<<" height="<<height<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int numberCameras = numScreens;
|
||||||
while (arguments.read("--cameras",numberCameras)) {}
|
while (arguments.read("--cameras",numberCameras)) {}
|
||||||
|
|
||||||
unsigned int xpos = 0;
|
unsigned int xpos = 0;
|
||||||
@ -186,6 +206,8 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
CameraList cameraList;
|
CameraList cameraList;
|
||||||
GraphicsContextSet graphicsContextSet;
|
GraphicsContextSet graphicsContextSet;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create the cameras, graphic contexts and graphic threads.
|
// create the cameras, graphic contexts and graphic threads.
|
||||||
bool shareContexts = false;
|
bool shareContexts = false;
|
||||||
@ -197,6 +219,7 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||||
traits->_windowName = "osgcamera";
|
traits->_windowName = "osgcamera";
|
||||||
|
traits->_screenNum = i % numScreens;
|
||||||
traits->_x = xpos;
|
traits->_x = xpos;
|
||||||
traits->_y = ypos;
|
traits->_y = ypos;
|
||||||
traits->_width = width;
|
traits->_width = width;
|
||||||
|
@ -24,12 +24,21 @@ class OSG_EXPORT GraphicsContext : public Referenced
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
struct ScreenIdentifier
|
||||||
|
{
|
||||||
|
ScreenIdentifier():
|
||||||
|
_displayNum(0),
|
||||||
|
_screenNum(0) {}
|
||||||
|
|
||||||
|
std::string _hostName;
|
||||||
|
unsigned int _displayNum;
|
||||||
|
unsigned int _screenNum;
|
||||||
|
};
|
||||||
|
|
||||||
/** GraphicsContext Traits object provides the specification of what type of graphics context is required.*/
|
/** GraphicsContext Traits object provides the specification of what type of graphics context is required.*/
|
||||||
struct Traits : public osg::Referenced
|
struct Traits : public osg::Referenced, public ScreenIdentifier
|
||||||
{
|
{
|
||||||
Traits():
|
Traits():
|
||||||
_displayNum(0),
|
|
||||||
_screenNum(0),
|
|
||||||
_x(0),
|
_x(0),
|
||||||
_y(0),
|
_y(0),
|
||||||
_width(0),
|
_width(0),
|
||||||
@ -50,12 +59,7 @@ class OSG_EXPORT GraphicsContext : public Referenced
|
|||||||
_face(0),
|
_face(0),
|
||||||
_mipMapGeneration(false),
|
_mipMapGeneration(false),
|
||||||
_sharedContext() {}
|
_sharedContext() {}
|
||||||
|
|
||||||
// where graphic context is be hosted.
|
|
||||||
std::string _hostName;
|
|
||||||
unsigned int _displayNum;
|
|
||||||
unsigned int _screenNum;
|
|
||||||
|
|
||||||
// graphics context orginal and size
|
// graphics context orginal and size
|
||||||
unsigned int _x;
|
unsigned int _x;
|
||||||
unsigned int _y;
|
unsigned int _y;
|
||||||
@ -92,19 +96,23 @@ class OSG_EXPORT GraphicsContext : public Referenced
|
|||||||
|
|
||||||
|
|
||||||
/** Callback to be implemented to provide access to Windowing API's ability to create Windows/pbuffers.*/
|
/** Callback to be implemented to provide access to Windowing API's ability to create Windows/pbuffers.*/
|
||||||
struct CreateGraphicContextCallback : public osg::Referenced
|
struct WindowingSystemInterface : public osg::Referenced
|
||||||
{
|
{
|
||||||
|
virtual unsigned int getNumScreens(const ScreenIdentifier& screenIdentifier = ScreenIdentifier()) = 0;
|
||||||
|
|
||||||
|
virtual void getScreenResolution(const ScreenIdentifier& screenIdentifier, unsigned int& width, unsigned int& height) = 0;
|
||||||
|
|
||||||
virtual GraphicsContext* createGraphicsContext(Traits* traits) = 0;
|
virtual GraphicsContext* createGraphicsContext(Traits* traits) = 0;
|
||||||
|
|
||||||
virtual ~CreateGraphicContextCallback() {};
|
virtual ~WindowingSystemInterface() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Set the create graphics context callback - this callback should be supplied by the windows toolkit. */
|
/** Set the querry the windowing system for screens and create graphics context - this functor should be supplied by the windows toolkit. */
|
||||||
static void setCreateGraphicsContextCallback(CreateGraphicContextCallback* callback);
|
static void setWindowingSystemInterface(WindowingSystemInterface* wsInterface);
|
||||||
|
|
||||||
/** Get the create graphics context callback*/
|
/** Get the WindowingSystemInterface*/
|
||||||
static CreateGraphicContextCallback* getCreateGraphicsContextCallback();
|
static WindowingSystemInterface* getWindowingSystemInterface();
|
||||||
|
|
||||||
/** Create a graphics context for a specified set of traits.*/
|
/** Create a graphics context for a specified set of traits.*/
|
||||||
static GraphicsContext* createGraphicsContext(Traits* traits);
|
static GraphicsContext* createGraphicsContext(Traits* traits);
|
||||||
|
@ -18,22 +18,22 @@
|
|||||||
|
|
||||||
using namespace osg;
|
using namespace osg;
|
||||||
|
|
||||||
static ref_ptr<GraphicsContext::CreateGraphicContextCallback> s_createGraphicsContextCallback;
|
static ref_ptr<GraphicsContext::WindowingSystemInterface> s_WindowingSystemInterface;
|
||||||
|
|
||||||
void GraphicsContext::setCreateGraphicsContextCallback(CreateGraphicContextCallback* callback)
|
void GraphicsContext::setWindowingSystemInterface(WindowingSystemInterface* callback)
|
||||||
{
|
{
|
||||||
s_createGraphicsContextCallback = callback;
|
s_WindowingSystemInterface = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsContext::CreateGraphicContextCallback* GraphicsContext::getCreateGraphicsContextCallback()
|
GraphicsContext::WindowingSystemInterface* GraphicsContext::getWindowingSystemInterface()
|
||||||
{
|
{
|
||||||
return s_createGraphicsContextCallback.get();
|
return s_WindowingSystemInterface.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsContext* GraphicsContext::createGraphicsContext(Traits* traits)
|
GraphicsContext* GraphicsContext::createGraphicsContext(Traits* traits)
|
||||||
{
|
{
|
||||||
if (s_createGraphicsContextCallback.valid())
|
if (s_WindowingSystemInterface.valid())
|
||||||
return s_createGraphicsContextCallback->createGraphicsContext(traits);
|
return s_WindowingSystemInterface->createGraphicsContext(traits);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -20,28 +20,43 @@ using namespace osgProducer;
|
|||||||
|
|
||||||
namespace osgProducer
|
namespace osgProducer
|
||||||
{
|
{
|
||||||
struct MyCreateGraphicContexCallback : public osg::GraphicsContext::CreateGraphicContextCallback
|
struct MyWindowingSystemInterface : public osg::GraphicsContext::WindowingSystemInterface
|
||||||
{
|
{
|
||||||
|
virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier)
|
||||||
|
{
|
||||||
|
return Producer::RenderSurface::getNumberOfScreens();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void getScreenResolution(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, unsigned int& width, unsigned int& height)
|
||||||
|
{
|
||||||
|
osg::ref_ptr<Producer::RenderSurface> rs = new Producer::RenderSurface;
|
||||||
|
rs->setHostName(screenIdentifier._hostName);
|
||||||
|
rs->setDisplayNum(screenIdentifier._displayNum);
|
||||||
|
rs->setScreenNum(screenIdentifier._screenNum);
|
||||||
|
rs->getScreenSize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)
|
virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)
|
||||||
{
|
{
|
||||||
return new GraphicsContextImplementation(traits);
|
return new GraphicsContextImplementation(traits);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RegisterCreateGraphicsContextCallbackProxy
|
struct RegisterWindowingSystemInterfaceProxy
|
||||||
{
|
{
|
||||||
RegisterCreateGraphicsContextCallbackProxy()
|
RegisterWindowingSystemInterfaceProxy()
|
||||||
{
|
{
|
||||||
osg::GraphicsContext::setCreateGraphicsContextCallback(new MyCreateGraphicContexCallback);
|
osg::GraphicsContext::setWindowingSystemInterface(new MyWindowingSystemInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RegisterCreateGraphicsContextCallbackProxy()
|
~RegisterWindowingSystemInterfaceProxy()
|
||||||
{
|
{
|
||||||
osg::GraphicsContext::setCreateGraphicsContextCallback(0);
|
osg::GraphicsContext::setWindowingSystemInterface(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RegisterCreateGraphicsContextCallbackProxy createGraphicsContextCallbackProxy;
|
RegisterWindowingSystemInterfaceProxy createWindowingSystemInterfaceProxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,13 +120,13 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::GraphicsContext)
|
|||||||
__void__swapBuffersImplementation,
|
__void__swapBuffersImplementation,
|
||||||
"Swap the front and back buffers implementation. ",
|
"Swap the front and back buffers implementation. ",
|
||||||
"Pure virtual - must be implemented by Concrate implementations of GraphicsContext. ");
|
"Pure virtual - must be implemented by Concrate implementations of GraphicsContext. ");
|
||||||
I_StaticMethod1(void, setCreateGraphicsContextCallback, IN, osg::GraphicsContext::CreateGraphicContextCallback *, callback,
|
I_StaticMethod1(void, setWindowingSystemInterface, IN, osg::GraphicsContext::WindowingSystemInterface *, wsInterface,
|
||||||
__void__setCreateGraphicsContextCallback__CreateGraphicContextCallback_P1_S,
|
__void__setWindowingSystemInterface__WindowingSystemInterface_P1_S,
|
||||||
"Set the create graphics context callback - this callback should be supplied by the windows toolkit. ",
|
"Set the querry the windowing system for screens and create graphics context - this functor should be supplied by the windows toolkit. ",
|
||||||
"");
|
"");
|
||||||
I_StaticMethod0(osg::GraphicsContext::CreateGraphicContextCallback *, getCreateGraphicsContextCallback,
|
I_StaticMethod0(osg::GraphicsContext::WindowingSystemInterface *, getWindowingSystemInterface,
|
||||||
__CreateGraphicContextCallback_P1__getCreateGraphicsContextCallback_S,
|
__WindowingSystemInterface_P1__getWindowingSystemInterface_S,
|
||||||
"Get the create graphics context callback. ",
|
"Get the WindowingSystemInterface. ",
|
||||||
"");
|
"");
|
||||||
I_StaticMethod1(osg::GraphicsContext *, createGraphicsContext, IN, osg::GraphicsContext::Traits *, traits,
|
I_StaticMethod1(osg::GraphicsContext *, createGraphicsContext, IN, osg::GraphicsContext::Traits *, traits,
|
||||||
__GraphicsContext_P1__createGraphicsContext__Traits_P1_S,
|
__GraphicsContext_P1__createGraphicsContext__Traits_P1_S,
|
||||||
@ -155,25 +155,21 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::GraphicsContext)
|
|||||||
0);
|
0);
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::GraphicsContext::CreateGraphicContextCallback)
|
BEGIN_VALUE_REFLECTOR(osg::GraphicsContext::ScreenIdentifier)
|
||||||
I_BaseType(osg::Referenced);
|
I_Constructor0(____ScreenIdentifier,
|
||||||
I_Constructor0(____CreateGraphicContextCallback,
|
|
||||||
"",
|
|
||||||
"");
|
|
||||||
I_Method1(osg::GraphicsContext *, createGraphicsContext, IN, osg::GraphicsContext::Traits *, traits,
|
|
||||||
__GraphicsContext_P1__createGraphicsContext__Traits_P1,
|
|
||||||
"",
|
|
||||||
"");
|
|
||||||
END_REFLECTOR
|
|
||||||
|
|
||||||
BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext::Traits)
|
|
||||||
I_BaseType(osg::Referenced);
|
|
||||||
I_Constructor0(____Traits,
|
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
I_PublicMemberProperty(std::string, _hostName);
|
I_PublicMemberProperty(std::string, _hostName);
|
||||||
I_PublicMemberProperty(unsigned int, _displayNum);
|
I_PublicMemberProperty(unsigned int, _displayNum);
|
||||||
I_PublicMemberProperty(unsigned int, _screenNum);
|
I_PublicMemberProperty(unsigned int, _screenNum);
|
||||||
|
END_REFLECTOR
|
||||||
|
|
||||||
|
BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext::Traits)
|
||||||
|
I_BaseType(osg::Referenced);
|
||||||
|
I_BaseType(osg::GraphicsContext::ScreenIdentifier);
|
||||||
|
I_Constructor0(____Traits,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
I_PublicMemberProperty(unsigned int, _x);
|
I_PublicMemberProperty(unsigned int, _x);
|
||||||
I_PublicMemberProperty(unsigned int, _y);
|
I_PublicMemberProperty(unsigned int, _y);
|
||||||
I_PublicMemberProperty(unsigned int, _width);
|
I_PublicMemberProperty(unsigned int, _width);
|
||||||
@ -197,3 +193,22 @@ BEGIN_OBJECT_REFLECTOR(osg::GraphicsContext::Traits)
|
|||||||
I_PublicMemberProperty(osg::GraphicsContext *, _sharedContext);
|
I_PublicMemberProperty(osg::GraphicsContext *, _sharedContext);
|
||||||
END_REFLECTOR
|
END_REFLECTOR
|
||||||
|
|
||||||
|
BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::GraphicsContext::WindowingSystemInterface)
|
||||||
|
I_BaseType(osg::Referenced);
|
||||||
|
I_Constructor0(____WindowingSystemInterface,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_MethodWithDefaults1(unsigned int, getNumScreens, IN, const osg::GraphicsContext::ScreenIdentifier &, screenIdentifier, osg::GraphicsContext::ScreenIdentifier(),
|
||||||
|
__unsigned_int__getNumScreens__C5_ScreenIdentifier_R1,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_Method3(void, getScreenResolution, IN, const osg::GraphicsContext::ScreenIdentifier &, screenIdentifier, IN, unsigned int &, width, IN, unsigned int &, height,
|
||||||
|
__void__getScreenResolution__C5_ScreenIdentifier_R1__unsigned_int_R1__unsigned_int_R1,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
I_Method1(osg::GraphicsContext *, createGraphicsContext, IN, osg::GraphicsContext::Traits *, traits,
|
||||||
|
__GraphicsContext_P1__createGraphicsContext__Traits_P1,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
|
END_REFLECTOR
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user