Added support for sample and sampleBuffers to osg::GraphicsContext::Traits and

cleaned up the Traits naming
This commit is contained in:
Robert Osfield 2006-12-22 21:53:44 +00:00
parent 401f3bcd43
commit 76461b3ab2
8 changed files with 193 additions and 166 deletions

View File

@ -39,9 +39,13 @@ int main( int argc, char **argv )
viewer.setUpViewAcrossAllScreens(); viewer.setUpViewAcrossAllScreens();
viewer.realize(); viewer.realize();
while(!viewer.done()) unsigned int numFrames = 0;
unsigned int maxFrames = 100;
while(!viewer.done() && numFrames<maxFrames)
{ {
viewer.frame(); viewer.frame();
++numFrames;
} }
return 0; return 0;

View File

@ -24,83 +24,91 @@ class OSG_EXPORT GraphicsContext : public Referenced
{ {
public: public:
struct ScreenIdentifier struct OSG_EXPORT ScreenIdentifier
{ {
ScreenIdentifier(): ScreenIdentifier():
_displayNum(0), displayNum(0),
_screenNum(0) {} screenNum(0) {}
ScreenIdentifier(unsigned int screenNum): ScreenIdentifier(unsigned int in_screenNum):
_displayNum(0), displayNum(0),
_screenNum(screenNum) {} screenNum(in_screenNum) {}
ScreenIdentifier(const std::string& hostName,unsigned int displayNum, unsigned int screenNum): ScreenIdentifier(const std::string& in_hostName,unsigned int in_displayNum, unsigned int in_screenNum):
_hostName(hostName), hostName(in_hostName),
_displayNum(displayNum), displayNum(in_displayNum),
_screenNum(screenNum) {} screenNum(in_screenNum) {}
std::string _hostName; std::string displayName() const;
unsigned int _displayNum;
unsigned int _screenNum; 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, public ScreenIdentifier struct Traits : public osg::Referenced, public ScreenIdentifier
{ {
Traits(): Traits():
_x(0), x(0),
_y(0), y(0),
_width(0), width(0),
_height(0), height(0),
_windowDecoration(false), windowDecoration(false),
_supportsResize(false), supportsResize(false),
_red(8), red(8),
_blue(8), blue(8),
_green(8), green(8),
_alpha(0), alpha(0),
_depth(24), depth(24),
_stencil(0), stencil(0),
_pbuffer(false), sampleBuffers(0),
_quadBufferStereo(false), samples(0),
_doubleBuffer(false), pbuffer(false),
_target(0), quadBufferStereo(false),
_level(0), doubleBuffer(false),
_face(0), target(0),
_mipMapGeneration(false), level(0),
_sharedContext() {} face(0),
mipMapGeneration(false),
sharedContext(0) {}
// graphics context orginal and size // graphics context orginal and size
unsigned int _x; unsigned int x;
unsigned int _y; unsigned int y;
unsigned int _width; unsigned int width;
unsigned int _height; unsigned int height;
// window decoration and baviour // window decoration and baviour
std::string _windowName; std::string windowName;
bool _windowDecoration; bool windowDecoration;
bool _supportsResize; bool supportsResize;
// buffer depths, 0 equals off. // buffer depths, 0 equals off.
unsigned int _red; unsigned int red;
unsigned int _blue; unsigned int blue;
unsigned int _green; unsigned int green;
unsigned int _alpha; unsigned int alpha;
unsigned int _depth; unsigned int depth;
unsigned int _stencil; unsigned int stencil;
// multi sample parameters
unsigned int sampleBuffers;
unsigned int samples;
// buffer configuration // buffer configuration
bool _pbuffer; bool pbuffer;
bool _quadBufferStereo; bool quadBufferStereo;
bool _doubleBuffer; bool doubleBuffer;
// render to texture // render to texture
GLenum _target; GLenum target;
unsigned int _level; unsigned int level;
unsigned int _face; unsigned int face;
unsigned int _mipMapGeneration; unsigned int mipMapGeneration;
// shared context // shared context
GraphicsContext* _sharedContext; GraphicsContext* sharedContext;
}; };

View File

@ -15,6 +15,7 @@
#include <osg/GraphicsContext> #include <osg/GraphicsContext>
#include <osg/Notify> #include <osg/Notify>
#include <map> #include <map>
#include <sstream>
using namespace osg; using namespace osg;
@ -39,6 +40,14 @@ GraphicsContext* GraphicsContext::createGraphicsContext(Traits* traits)
} }
std::string GraphicsContext::ScreenIdentifier::displayName() const
{
std::stringstream ostr;
ostr<<hostName<<":"<<displayNum<<"."<<screenNum;
return ostr.str();
}
typedef std::map<unsigned int, unsigned int> ContextIDMap; typedef std::map<unsigned int, unsigned int> ContextIDMap;
static ContextIDMap s_contextIDMap; static ContextIDMap s_contextIDMap;
static OpenThreads::Mutex s_contextIDMapMutex; static OpenThreads::Mutex s_contextIDMapMutex;

View File

@ -22,7 +22,7 @@ namespace osgProducer
{ {
struct MyWindowingSystemInterface : public osg::GraphicsContext::WindowingSystemInterface struct MyWindowingSystemInterface : public osg::GraphicsContext::WindowingSystemInterface
{ {
virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier) virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& /*screenIdentifier*/)
{ {
return Producer::RenderSurface::getNumberOfScreens(); return Producer::RenderSurface::getNumberOfScreens();
} }
@ -30,9 +30,9 @@ namespace osgProducer
virtual void getScreenResolution(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, unsigned int& width, unsigned int& height) virtual void getScreenResolution(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, unsigned int& width, unsigned int& height)
{ {
osg::ref_ptr<Producer::RenderSurface> rs = new Producer::RenderSurface; osg::ref_ptr<Producer::RenderSurface> rs = new Producer::RenderSurface;
rs->setHostName(screenIdentifier._hostName); rs->setHostName(screenIdentifier.hostName);
rs->setDisplayNum(screenIdentifier._displayNum); rs->setDisplayNum(screenIdentifier.displayNum);
rs->setScreenNum(screenIdentifier._screenNum); rs->setScreenNum(screenIdentifier.screenNum);
rs->getScreenSize(width, height); rs->getScreenSize(width, height);
} }
@ -66,11 +66,11 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
_traits = traits; _traits = traits;
_rs = new Producer::RenderSurface; _rs = new Producer::RenderSurface;
_rs->setWindowName(traits->_windowName); _rs->setWindowName(traits->windowName);
_rs->setWindowRectangle(traits->_x, traits->_y, traits->_width, traits->_height); _rs->setWindowRectangle(traits->x, traits->y, traits->width, traits->height);
_rs->useBorder(traits->_windowDecoration); _rs->useBorder(traits->windowDecoration);
_rs->setDisplayNum(traits->_displayNum); _rs->setDisplayNum(traits->displayNum);
_rs->setScreenNum(traits->_screenNum); _rs->setScreenNum(traits->screenNum);
// set the visual chooser // set the visual chooser
@ -81,35 +81,35 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
_rs->setVisualChooser(rs_vc); _rs->setVisualChooser(rs_vc);
} }
rs_vc->setRedSize(_traits->_red); rs_vc->setRedSize(_traits->red);
rs_vc->setGreenSize(_traits->_green); rs_vc->setGreenSize(_traits->green);
rs_vc->setBlueSize(_traits->_blue); rs_vc->setBlueSize(_traits->blue);
rs_vc->setAlphaSize(_traits->_alpha); rs_vc->setAlphaSize(_traits->alpha);
rs_vc->setDepthSize(_traits->_depth); rs_vc->setDepthSize(_traits->depth);
rs_vc->setStencilSize(_traits->_stencil); rs_vc->setStencilSize(_traits->stencil);
if (_traits->_doubleBuffer) rs_vc->useDoubleBuffer(); if (_traits->doubleBuffer) rs_vc->useDoubleBuffer();
rs_vc->addAttribute( Producer::VisualChooser::RGBA ); rs_vc->addAttribute( Producer::VisualChooser::RGBA );
// Always use UseGL // Always use UseGL
rs_vc->addAttribute( Producer::VisualChooser::UseGL ); rs_vc->addAttribute( Producer::VisualChooser::UseGL );
if (traits->_pbuffer) if (traits->pbuffer)
{ {
_rs->setDrawableType(Producer::RenderSurface::DrawableType_PBuffer); _rs->setDrawableType(Producer::RenderSurface::DrawableType_PBuffer);
if (traits->_target) if (traits->target)
{ {
_rs->setRenderToTextureOptions(traits->_mipMapGeneration ? Producer::RenderSurface::RequestSpaceForMipMaps : _rs->setRenderToTextureOptions(traits->mipMapGeneration ? Producer::RenderSurface::RequestSpaceForMipMaps :
Producer::RenderSurface::RenderToTextureOptions_Default); Producer::RenderSurface::RenderToTextureOptions_Default);
_rs->setRenderToTextureMipMapLevel(traits->_level); _rs->setRenderToTextureMipMapLevel(traits->level);
_rs->setRenderToTextureMode(traits->_alpha>0 ? Producer::RenderSurface::RenderToRGBATexture : _rs->setRenderToTextureMode(traits->alpha>0 ? Producer::RenderSurface::RenderToRGBATexture :
Producer::RenderSurface::RenderToRGBTexture); Producer::RenderSurface::RenderToRGBTexture);
switch(traits->_target) switch(traits->target)
{ {
case(GL_TEXTURE_1D) : case(GL_TEXTURE_1D) :
_rs->setRenderToTextureTarget(Producer::RenderSurface::Texture1D); _rs->setRenderToTextureTarget(Producer::RenderSurface::Texture1D);
@ -134,7 +134,7 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
case(GL_TEXTURE_CUBE_MAP_POSITIVE_Z) : case(GL_TEXTURE_CUBE_MAP_POSITIVE_Z) :
case(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) : case(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) :
_rs->setRenderToTextureTarget(Producer::RenderSurface::TextureCUBE); _rs->setRenderToTextureTarget(Producer::RenderSurface::TextureCUBE);
_rs->setRenderToTextureFace( Producer::RenderSurface::CubeMapFace(traits->_target - GL_TEXTURE_CUBE_MAP_POSITIVE_X)); _rs->setRenderToTextureFace( Producer::RenderSurface::CubeMapFace(traits->target - GL_TEXTURE_CUBE_MAP_POSITIVE_X));
break; break;
} }
@ -142,7 +142,7 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
} }
GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(traits->_sharedContext); GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(traits->sharedContext);
if (sharedContext) if (sharedContext)
{ {
@ -184,9 +184,9 @@ GraphicsContextImplementation::GraphicsContextImplementation(Producer::RenderSur
_closeOnDestruction = false; _closeOnDestruction = false;
_traits = new osg::GraphicsContext::Traits; _traits = new osg::GraphicsContext::Traits;
_traits->_windowName = _rs->getWindowName(); _traits->windowName = _rs->getWindowName();
_traits->_displayNum = _rs->getDisplayNum(); _traits->displayNum = _rs->getDisplayNum();
_traits->_screenNum = _rs->getScreenNum(); _traits->screenNum = _rs->getScreenNum();
} }
GraphicsContextImplementation::~GraphicsContextImplementation() GraphicsContextImplementation::~GraphicsContextImplementation()
@ -198,7 +198,7 @@ bool GraphicsContextImplementation::realizeImplementation()
{ {
if (_rs.valid()) if (_rs.valid())
{ {
GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(_traits->_sharedContext); GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(_traits->sharedContext);
if (sharedContext) if (sharedContext)
{ {

View File

@ -437,14 +437,14 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
// set up the traits of the graphics context that we want // set up the traits of the graphics context that we want
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->_width = width; traits->width = width;
traits->_height = height; traits->height = height;
// osg::notify(osg::NOTICE)<<"traits = "<<traits->_width<<" "<<traits->_height<<std::endl; // osg::notify(osg::NOTICE)<<"traits = "<<traits->width<<" "<<traits->height<<std::endl;
traits->_pbuffer = (renderTargetImplemntation==osg::Camera::PIXEL_BUFFER || renderTargetImplemntation==osg::Camera::PIXEL_BUFFER_RTT); traits->pbuffer = (renderTargetImplemntation==osg::Camera::PIXEL_BUFFER || renderTargetImplemntation==osg::Camera::PIXEL_BUFFER_RTT);
traits->_windowDecoration = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW); traits->windowDecoration = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW);
traits->_doubleBuffer = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW); traits->doubleBuffer = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW);
osg::Texture* pBufferTexture = 0; osg::Texture* pBufferTexture = 0;
GLenum bufferFormat = GL_NONE; GLenum bufferFormat = GL_NONE;
@ -465,13 +465,13 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
{ {
case(osg::Camera::DEPTH_BUFFER): case(osg::Camera::DEPTH_BUFFER):
{ {
traits->_depth = 24; traits->depth = 24;
depthAttached = true; depthAttached = true;
break; break;
} }
case(osg::Camera::STENCIL_BUFFER): case(osg::Camera::STENCIL_BUFFER):
{ {
traits->_stencil = 8; traits->stencil = 8;
stencilAttached = true; stencilAttached = true;
break; break;
} }
@ -503,10 +503,10 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
if (renderTargetImplemntation==osg::Camera::PIXEL_BUFFER_RTT) if (renderTargetImplemntation==osg::Camera::PIXEL_BUFFER_RTT)
{ {
traits->_target = bufferFormat; traits->target = bufferFormat;
traits->_level = level; traits->level = level;
traits->_face = face; traits->face = face;
traits->_mipMapGeneration = attachment._mipMapGeneration; traits->mipMapGeneration = attachment._mipMapGeneration;
} }
break; break;
} }
@ -526,29 +526,30 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
if (!depthAttached) if (!depthAttached)
{ {
traits->_depth = 24; traits->depth = 24;
} }
if (!colorAttached) if (!colorAttached)
{ {
if (bufferFormat == GL_NONE) bufferFormat = GL_RGB; if (bufferFormat == GL_NONE) bufferFormat = GL_RGB;
traits->_red = 8; traits->red = 8;
traits->_green = 8; traits->green = 8;
traits->_blue = 8; traits->blue = 8;
traits->_alpha = (bufferFormat==GL_RGBA) ? 8 : 0; traits->alpha = (bufferFormat==GL_RGBA) ? 8 : 0;
} }
// share OpenGL objects if possible... // share OpenGL objects if possible...
if (state.getGraphicsContext()) if (state.getGraphicsContext())
{ {
traits->_sharedContext = state.getGraphicsContext(); traits->sharedContext = state.getGraphicsContext();
const osg::GraphicsContext::Traits* sharedTraits = traits->_sharedContext->getTraits(); const osg::GraphicsContext::Traits* sharedTraits = traits->sharedContext->getTraits();
if (sharedTraits) if (sharedTraits)
{ {
traits->_displayNum = sharedTraits->_displayNum; traits->hostName = sharedTraits->hostName;
traits->_screenNum = sharedTraits->_screenNum; traits->displayNum = sharedTraits->displayNum;
traits->screenNum = sharedTraits->screenNum;
} }
} }

View File

@ -117,7 +117,9 @@ SceneView::SceneView(DisplaySettings* ds)
_interlacedStereoStencilHeight = 0; _interlacedStereoStencilHeight = 0;
} }
SceneView::SceneView(const SceneView& rhs, const osg::CopyOp&) SceneView::SceneView(const SceneView& rhs, const osg::CopyOp& copyop):
osg::Object(rhs,copyop),
osg::CullSettings(rhs)
{ {
_displaySettings = rhs._displaySettings; _displaySettings = rhs._displaySettings;

View File

@ -87,19 +87,25 @@ bool GraphicsWindowX11::createVisualInfo()
attributes.push_back(GLX_RGBA); attributes.push_back(GLX_RGBA);
if (_traits->_doubleBuffer) attributes.push_back(GLX_DOUBLEBUFFER); if (_traits->doubleBuffer) attributes.push_back(GLX_DOUBLEBUFFER);
if (_traits->_quadBufferStereo) attributes.push_back(GLX_STEREO); if (_traits->quadBufferStereo) attributes.push_back(GLX_STEREO);
attributes.push_back(GLX_RED_SIZE); attributes.push_back(_traits->_red); attributes.push_back(GLX_RED_SIZE); attributes.push_back(_traits->red);
attributes.push_back(GLX_GREEN_SIZE); attributes.push_back(_traits->_green); attributes.push_back(GLX_GREEN_SIZE); attributes.push_back(_traits->green);
attributes.push_back(GLX_BLUE_SIZE); attributes.push_back(_traits->_blue); attributes.push_back(GLX_BLUE_SIZE); attributes.push_back(_traits->blue);
attributes.push_back(GLX_DEPTH_SIZE); attributes.push_back(_traits->_depth); attributes.push_back(GLX_DEPTH_SIZE); attributes.push_back(_traits->depth);
if (_traits->_alpha) { attributes.push_back(GLX_ALPHA_SIZE); attributes.push_back(_traits->_alpha); } if (_traits->alpha) { attributes.push_back(GLX_ALPHA_SIZE); attributes.push_back(_traits->alpha); }
if (_traits->_stencil) { attributes.push_back(GLX_STENCIL_SIZE); attributes.push_back(_traits->_stencil); } if (_traits->stencil) { attributes.push_back(GLX_STENCIL_SIZE); attributes.push_back(_traits->stencil); }
#if defined(GLX_SAMPLE_BUFFERS) && defined (GLX_SAMPLES)
if (_traits->sampleBuffers) { attributes.push_back(GLX_SAMPLE_BUFFERS); attributes.push_back(_traits->sampleBuffers); }
if (_traits->sampleBuffers) { attributes.push_back(GLX_SAMPLES); attributes.push_back(_traits->samples); }
#endif
// TODO // TODO
// GLX_AUX_BUFFERS // GLX_AUX_BUFFERS
// GLX_ACCUM_RED_SIZE // GLX_ACCUM_RED_SIZE
@ -109,7 +115,7 @@ bool GraphicsWindowX11::createVisualInfo()
attributes.push_back(None); attributes.push_back(None);
_visualInfo = glXChooseVisual( _display, _traits->_screenNum, &(attributes.front()) ); _visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) );
return _visualInfo != 0; return _visualInfo != 0;
} }
@ -173,8 +179,8 @@ void GraphicsWindowX11::setWindowDecoration(bool flag)
#if 0 #if 0
// now update the window dimensions to account for any size changes made by the window manager, // now update the window dimensions to account for any size changes made by the window manager,
XGetWindowAttributes( _display, _window, &watt ); XGetWindowAttributes( _display, _window, &watt );
_traits->_width = watt.width; _traits->width = watt.width;
_traits->_height = watt.height; _traits->height = watt.height;
#endif #endif
} }
@ -186,22 +192,20 @@ void GraphicsWindowX11::init()
{ {
if (!_traits || _initialized) return; if (!_traits || _initialized) return;
const char* displayString = _traits->_hostName.c_str(); _display = XOpenDisplay(_traits->displayName().c_str());
_display = XOpenDisplay(displayString);
unsigned int screen = _traits->_screenNum; unsigned int screen = _traits->screenNum;
if (!_display) if (!_display)
{ {
osg::notify(osg::NOTICE)<<"Error: Unable to open display \"" << XDisplayName(displayString) << "\". Is the DISPLAY environmental variable set?"<<std::endl; osg::notify(osg::NOTICE)<<"Error: Unable to open display \"" << XDisplayName(_traits->displayName().c_str()) << "\". Is the DISPLAY environmental variable set?"<<std::endl;
return;
} }
// Query for GLX extension // Query for GLX extension
int errorBase, eventBase; int errorBase, eventBase;
if( glXQueryExtension( _display, &errorBase, &eventBase) == False ) if( glXQueryExtension( _display, &errorBase, &eventBase) == False )
{ {
osg::notify(osg::NOTICE)<<"Error: " << XDisplayName(displayString) <<" has no GLX extension." << std::endl; osg::notify(osg::NOTICE)<<"Error: " << XDisplayName(_traits->displayName().c_str()) <<" has no GLX extension." << std::endl;
XCloseDisplay( _display ); XCloseDisplay( _display );
_display = 0; _display = 0;
@ -249,9 +253,9 @@ void GraphicsWindowX11::init()
} }
_window = XCreateWindow( _display, _parent, _window = XCreateWindow( _display, _parent,
_traits->_x, _traits->x,
_traits->_y, _traits->y,
_traits->_width, _traits->_height, 0, _traits->width, _traits->height, 0,
_visualInfo->depth, InputOutput, _visualInfo->depth, InputOutput,
_visualInfo->visual, mask, &swatt ); _visualInfo->visual, mask, &swatt );
@ -268,14 +272,14 @@ void GraphicsWindowX11::init()
sh.flags &= 0x7; sh.flags &= 0x7;
sh.flags |= USPosition; sh.flags |= USPosition;
sh.flags &= 0xB; sh.flags &= 0xB;
sh.x = _traits->_x; sh.x = _traits->x;
sh.y = _traits->_y; sh.y = _traits->y;
sh.width = _traits->_width; sh.width = _traits->width;
sh.height = _traits->_height; sh.height = _traits->height;
XSetStandardProperties( _display, _window, _traits->_windowName.c_str(), _traits->_windowName.c_str(), None, 0, 0, &sh); XSetStandardProperties( _display, _window, _traits->windowName.c_str(), _traits->windowName.c_str(), None, 0, 0, &sh);
#if 1 #if 1
setWindowDecoration(_traits->_windowDecoration); setWindowDecoration(_traits->windowDecoration);
#else #else
setWindowDecoration(true); setWindowDecoration(true);
#endif #endif
@ -314,8 +318,8 @@ void GraphicsWindowX11::init()
// now update the window dimensions to account for any size changes made by the window manager, // now update the window dimensions to account for any size changes made by the window manager,
XGetWindowAttributes( _display, _window, &watt ); XGetWindowAttributes( _display, _window, &watt );
_traits->_width = watt.width; _traits->width = watt.width;
_traits->_height = watt.height; _traits->height = watt.height;
//osg::notify(osg::NOTICE)<<"After sync apply.x = "<<watt.x<<" watt.y="<<watt.y<<" width="<<watt.width<<" height="<<watt.height<<std::endl; //osg::notify(osg::NOTICE)<<"After sync apply.x = "<<watt.x<<" watt.y="<<watt.y<<" width="<<watt.width<<" height="<<watt.height<<std::endl;
@ -428,10 +432,10 @@ void GraphicsWindowX11::checkEvents()
{ {
osg::notify(osg::INFO)<<"ConfigureNotify x="<<ev.xconfigure.x<<" y="<<ev.xconfigure.y<<" width="<<ev.xconfigure.width<<", height="<<ev.xconfigure.height<<std::endl; osg::notify(osg::INFO)<<"ConfigureNotify x="<<ev.xconfigure.x<<" y="<<ev.xconfigure.y<<" width="<<ev.xconfigure.width<<", height="<<ev.xconfigure.height<<std::endl;
_traits->_x = ev.xconfigure.x; _traits->x = ev.xconfigure.x;
_traits->_y = ev.xconfigure.y; _traits->y = ev.xconfigure.y;
_traits->_width = ev.xconfigure.width; _traits->width = ev.xconfigure.width;
_traits->_height = ev.xconfigure.height; _traits->height = ev.xconfigure.height;
// need to dispatch resize event. // need to dispatch resize event.
break; break;
} }
@ -445,8 +449,8 @@ void GraphicsWindowX11::checkEvents()
while( watt.map_state != IsViewable ); while( watt.map_state != IsViewable );
osg::notify(osg::INFO)<<"MapNotify x="<<watt.x<<" y="<<watt.y<<" width="<<watt.width<<", height="<<watt.height<<std::endl; osg::notify(osg::INFO)<<"MapNotify x="<<watt.x<<" y="<<watt.y<<" width="<<watt.width<<", height="<<watt.height<<std::endl;
_traits->_width = watt.width; _traits->width = watt.width;
_traits->_height = watt.height; _traits->height = watt.height;
break; break;
} }
@ -484,7 +488,7 @@ void GraphicsWindowX11::checkEvents()
screenOrigin_x += DisplayWidth(_display, i); screenOrigin_x += DisplayWidth(_display, i);
} }
for(i= 0; i < static_cast<int>(_traits->_screenNum); i++ ) for(i= 0; i < static_cast<int>(_traits->screenNum); i++ )
{ {
screenOrigin_x -= DisplayWidth(_display, i); screenOrigin_x -= DisplayWidth(_display, i);
} }
@ -603,8 +607,8 @@ void GraphicsWindowX11::transformMouseXY(float& x, float& y)
if (getEventQueue()->getUseFixedMouseInputRange()) if (getEventQueue()->getUseFixedMouseInputRange())
{ {
osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState(); osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState();
x = eventState->getXmin() + (eventState->getXmax()-eventState->getXmin())*x/float(_traits->_width); x = eventState->getXmin() + (eventState->getXmax()-eventState->getXmin())*x/float(_traits->width);
y = eventState->getYmin() + (eventState->getYmax()-eventState->getYmin())*y/float(_traits->_height); y = eventState->getYmin() + (eventState->getYmax()-eventState->getYmin())*y/float(_traits->height);
} }
} }
@ -665,8 +669,7 @@ struct X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSyste
virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& si) virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& si)
{ {
const char* displayString = si._hostName.c_str(); Display* display = XOpenDisplay(si.displayName().c_str());
Display* display = XOpenDisplay(displayString);
if(display) if(display)
{ {
unsigned int numScreens = ScreenCount(display); unsigned int numScreens = ScreenCount(display);
@ -676,19 +679,19 @@ struct X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSyste
} }
else else
{ {
osg::notify(osg::NOTICE) << "Unable to open display \"" << XDisplayName(displayString) << "\". Is the DISPLAY environmental variable set?"<<std::endl; osg::notify(osg::NOTICE) << "Unable to open display \"" << XDisplayName(si.displayName().c_str()) << "\". Is the DISPLAY environmental variable set?"<<std::endl;
return 0; return 0;
} }
} }
virtual void getScreenResolution(const osg::GraphicsContext::ScreenIdentifier& si, unsigned int& width, unsigned int& height) virtual void getScreenResolution(const osg::GraphicsContext::ScreenIdentifier& si, unsigned int& width, unsigned int& height)
{ {
const char* displayString = si._hostName.c_str(); const char* displayString = si.displayName().c_str();
Display* display = XOpenDisplay(displayString); Display* display = XOpenDisplay(displayString);
if(display) if(display)
{ {
width = DisplayWidth(display, si._screenNum); width = DisplayWidth(display, si.screenNum);
height = DisplayHeight(display, si._screenNum); height = DisplayHeight(display, si.screenNum);
XCloseDisplay(display); XCloseDisplay(display);
} }
else else
@ -701,7 +704,7 @@ struct X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSyste
virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits) virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)
{ {
if (traits->_pbuffer) if (traits->pbuffer)
{ {
return new GraphicsContextX11(traits); return new GraphicsContextX11(traits);
} }

View File

@ -24,7 +24,7 @@ public:
virtual ~ActionAdapter() {} virtual ~ActionAdapter() {}
virtual void requestRedraw() { /*osg::notify(osg::NOTICE)<<"requestRedraw()"<<std::endl;*/ } virtual void requestRedraw() { /*osg::notify(osg::NOTICE)<<"requestRedraw()"<<std::endl;*/ }
virtual void requestContinuousUpdate(bool needed=true) { /*osg::notify(osg::NOTICE)<<"requestContinuousUpdate("<<needed<<")"<<std::endl;*/ } virtual void requestContinuousUpdate(bool /*needed*/=true) { /*osg::notify(osg::NOTICE)<<"requestContinuousUpdate("<<needed<<")"<<std::endl;*/ }
virtual void requestWarpPointer(float x,float y) { osg::notify(osg::NOTICE)<<"requestWarpPointer("<<x<<","<<y<<")"<<std::endl; } virtual void requestWarpPointer(float x,float y) { osg::notify(osg::NOTICE)<<"requestWarpPointer("<<x<<","<<y<<")"<<std::endl; }
}; };
@ -84,13 +84,13 @@ void View::setUpViewAcrossAllScreens()
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), 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;
traits->_y = 0; traits->y = 0;
traits->_width = width; traits->width = width;
traits->_height = height; traits->height = height;
traits->_windowDecoration = false; traits->windowDecoration = false;
traits->_doubleBuffer = true; traits->doubleBuffer = true;
traits->_sharedContext = 0; traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
@ -123,14 +123,14 @@ void View::setUpViewAcrossAllScreens()
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(i), width, height); wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(i), 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->_screenNum = i; traits->screenNum = i;
traits->_x = 0; traits->x = 0;
traits->_y = 0; traits->y = 0;
traits->_width = width; traits->width = width;
traits->_height = height; traits->height = height;
traits->_windowDecoration = false; traits->windowDecoration = false;
traits->_doubleBuffer = true; traits->doubleBuffer = true;
traits->_sharedContext = 0; traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get()); osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());