Added support for sample and sampleBuffers to osg::GraphicsContext::Traits and
cleaned up the Traits naming
This commit is contained in:
parent
401f3bcd43
commit
76461b3ab2
@ -39,9 +39,13 @@ int main( int argc, char **argv )
|
||||
viewer.setUpViewAcrossAllScreens();
|
||||
viewer.realize();
|
||||
|
||||
while(!viewer.done())
|
||||
unsigned int numFrames = 0;
|
||||
unsigned int maxFrames = 100;
|
||||
|
||||
while(!viewer.done() && numFrames<maxFrames)
|
||||
{
|
||||
viewer.frame();
|
||||
++numFrames;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -24,83 +24,91 @@ class OSG_EXPORT GraphicsContext : public Referenced
|
||||
{
|
||||
public:
|
||||
|
||||
struct ScreenIdentifier
|
||||
struct OSG_EXPORT ScreenIdentifier
|
||||
{
|
||||
ScreenIdentifier():
|
||||
_displayNum(0),
|
||||
_screenNum(0) {}
|
||||
displayNum(0),
|
||||
screenNum(0) {}
|
||||
|
||||
ScreenIdentifier(unsigned int screenNum):
|
||||
_displayNum(0),
|
||||
_screenNum(screenNum) {}
|
||||
ScreenIdentifier(unsigned int in_screenNum):
|
||||
displayNum(0),
|
||||
screenNum(in_screenNum) {}
|
||||
|
||||
ScreenIdentifier(const std::string& hostName,unsigned int displayNum, unsigned int screenNum):
|
||||
_hostName(hostName),
|
||||
_displayNum(displayNum),
|
||||
_screenNum(screenNum) {}
|
||||
ScreenIdentifier(const std::string& in_hostName,unsigned int in_displayNum, unsigned int in_screenNum):
|
||||
hostName(in_hostName),
|
||||
displayNum(in_displayNum),
|
||||
screenNum(in_screenNum) {}
|
||||
|
||||
std::string _hostName;
|
||||
unsigned int _displayNum;
|
||||
unsigned int _screenNum;
|
||||
std::string displayName() const;
|
||||
|
||||
std::string hostName;
|
||||
unsigned int displayNum;
|
||||
unsigned int screenNum;
|
||||
};
|
||||
|
||||
/** GraphicsContext Traits object provides the specification of what type of graphics context is required.*/
|
||||
struct Traits : public osg::Referenced, public ScreenIdentifier
|
||||
{
|
||||
Traits():
|
||||
_x(0),
|
||||
_y(0),
|
||||
_width(0),
|
||||
_height(0),
|
||||
_windowDecoration(false),
|
||||
_supportsResize(false),
|
||||
_red(8),
|
||||
_blue(8),
|
||||
_green(8),
|
||||
_alpha(0),
|
||||
_depth(24),
|
||||
_stencil(0),
|
||||
_pbuffer(false),
|
||||
_quadBufferStereo(false),
|
||||
_doubleBuffer(false),
|
||||
_target(0),
|
||||
_level(0),
|
||||
_face(0),
|
||||
_mipMapGeneration(false),
|
||||
_sharedContext() {}
|
||||
x(0),
|
||||
y(0),
|
||||
width(0),
|
||||
height(0),
|
||||
windowDecoration(false),
|
||||
supportsResize(false),
|
||||
red(8),
|
||||
blue(8),
|
||||
green(8),
|
||||
alpha(0),
|
||||
depth(24),
|
||||
stencil(0),
|
||||
sampleBuffers(0),
|
||||
samples(0),
|
||||
pbuffer(false),
|
||||
quadBufferStereo(false),
|
||||
doubleBuffer(false),
|
||||
target(0),
|
||||
level(0),
|
||||
face(0),
|
||||
mipMapGeneration(false),
|
||||
sharedContext(0) {}
|
||||
|
||||
// graphics context orginal and size
|
||||
unsigned int _x;
|
||||
unsigned int _y;
|
||||
unsigned int _width;
|
||||
unsigned int _height;
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
// window decoration and baviour
|
||||
std::string _windowName;
|
||||
bool _windowDecoration;
|
||||
bool _supportsResize;
|
||||
std::string windowName;
|
||||
bool windowDecoration;
|
||||
bool supportsResize;
|
||||
|
||||
// buffer depths, 0 equals off.
|
||||
unsigned int _red;
|
||||
unsigned int _blue;
|
||||
unsigned int _green;
|
||||
unsigned int _alpha;
|
||||
unsigned int _depth;
|
||||
unsigned int _stencil;
|
||||
|
||||
unsigned int red;
|
||||
unsigned int blue;
|
||||
unsigned int green;
|
||||
unsigned int alpha;
|
||||
unsigned int depth;
|
||||
unsigned int stencil;
|
||||
|
||||
// multi sample parameters
|
||||
unsigned int sampleBuffers;
|
||||
unsigned int samples;
|
||||
|
||||
// buffer configuration
|
||||
bool _pbuffer;
|
||||
bool _quadBufferStereo;
|
||||
bool _doubleBuffer;
|
||||
bool pbuffer;
|
||||
bool quadBufferStereo;
|
||||
bool doubleBuffer;
|
||||
|
||||
// render to texture
|
||||
GLenum _target;
|
||||
unsigned int _level;
|
||||
unsigned int _face;
|
||||
unsigned int _mipMapGeneration;
|
||||
GLenum target;
|
||||
unsigned int level;
|
||||
unsigned int face;
|
||||
unsigned int mipMapGeneration;
|
||||
|
||||
// shared context
|
||||
GraphicsContext* _sharedContext;
|
||||
GraphicsContext* sharedContext;
|
||||
};
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osg/Notify>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
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;
|
||||
static ContextIDMap s_contextIDMap;
|
||||
static OpenThreads::Mutex s_contextIDMapMutex;
|
||||
|
@ -22,7 +22,7 @@ namespace osgProducer
|
||||
{
|
||||
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();
|
||||
}
|
||||
@ -30,9 +30,9 @@ namespace osgProducer
|
||||
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->setHostName(screenIdentifier.hostName);
|
||||
rs->setDisplayNum(screenIdentifier.displayNum);
|
||||
rs->setScreenNum(screenIdentifier.screenNum);
|
||||
rs->getScreenSize(width, height);
|
||||
}
|
||||
|
||||
@ -66,11 +66,11 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
|
||||
_traits = traits;
|
||||
|
||||
_rs = new Producer::RenderSurface;
|
||||
_rs->setWindowName(traits->_windowName);
|
||||
_rs->setWindowRectangle(traits->_x, traits->_y, traits->_width, traits->_height);
|
||||
_rs->useBorder(traits->_windowDecoration);
|
||||
_rs->setDisplayNum(traits->_displayNum);
|
||||
_rs->setScreenNum(traits->_screenNum);
|
||||
_rs->setWindowName(traits->windowName);
|
||||
_rs->setWindowRectangle(traits->x, traits->y, traits->width, traits->height);
|
||||
_rs->useBorder(traits->windowDecoration);
|
||||
_rs->setDisplayNum(traits->displayNum);
|
||||
_rs->setScreenNum(traits->screenNum);
|
||||
|
||||
|
||||
// set the visual chooser
|
||||
@ -81,35 +81,35 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
|
||||
_rs->setVisualChooser(rs_vc);
|
||||
}
|
||||
|
||||
rs_vc->setRedSize(_traits->_red);
|
||||
rs_vc->setGreenSize(_traits->_green);
|
||||
rs_vc->setBlueSize(_traits->_blue);
|
||||
rs_vc->setAlphaSize(_traits->_alpha);
|
||||
rs_vc->setRedSize(_traits->red);
|
||||
rs_vc->setGreenSize(_traits->green);
|
||||
rs_vc->setBlueSize(_traits->blue);
|
||||
rs_vc->setAlphaSize(_traits->alpha);
|
||||
|
||||
rs_vc->setDepthSize(_traits->_depth);
|
||||
rs_vc->setStencilSize(_traits->_stencil);
|
||||
rs_vc->setDepthSize(_traits->depth);
|
||||
rs_vc->setStencilSize(_traits->stencil);
|
||||
|
||||
if (_traits->_doubleBuffer) rs_vc->useDoubleBuffer();
|
||||
if (_traits->doubleBuffer) rs_vc->useDoubleBuffer();
|
||||
|
||||
rs_vc->addAttribute( Producer::VisualChooser::RGBA );
|
||||
|
||||
// Always use UseGL
|
||||
rs_vc->addAttribute( Producer::VisualChooser::UseGL );
|
||||
|
||||
if (traits->_pbuffer)
|
||||
if (traits->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);
|
||||
_rs->setRenderToTextureMipMapLevel(traits->_level);
|
||||
_rs->setRenderToTextureMode(traits->_alpha>0 ? Producer::RenderSurface::RenderToRGBATexture :
|
||||
_rs->setRenderToTextureMipMapLevel(traits->level);
|
||||
_rs->setRenderToTextureMode(traits->alpha>0 ? Producer::RenderSurface::RenderToRGBATexture :
|
||||
Producer::RenderSurface::RenderToRGBTexture);
|
||||
|
||||
switch(traits->_target)
|
||||
switch(traits->target)
|
||||
{
|
||||
case(GL_TEXTURE_1D) :
|
||||
_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_NEGATIVE_Z) :
|
||||
_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;
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
|
||||
|
||||
}
|
||||
|
||||
GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(traits->_sharedContext);
|
||||
GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(traits->sharedContext);
|
||||
|
||||
if (sharedContext)
|
||||
{
|
||||
@ -184,9 +184,9 @@ GraphicsContextImplementation::GraphicsContextImplementation(Producer::RenderSur
|
||||
_closeOnDestruction = false;
|
||||
|
||||
_traits = new osg::GraphicsContext::Traits;
|
||||
_traits->_windowName = _rs->getWindowName();
|
||||
_traits->_displayNum = _rs->getDisplayNum();
|
||||
_traits->_screenNum = _rs->getScreenNum();
|
||||
_traits->windowName = _rs->getWindowName();
|
||||
_traits->displayNum = _rs->getDisplayNum();
|
||||
_traits->screenNum = _rs->getScreenNum();
|
||||
}
|
||||
|
||||
GraphicsContextImplementation::~GraphicsContextImplementation()
|
||||
@ -198,7 +198,7 @@ bool GraphicsContextImplementation::realizeImplementation()
|
||||
{
|
||||
if (_rs.valid())
|
||||
{
|
||||
GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(_traits->_sharedContext);
|
||||
GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(_traits->sharedContext);
|
||||
|
||||
if (sharedContext)
|
||||
{
|
||||
|
@ -437,14 +437,14 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
// set up the traits of the graphics context that we want
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
|
||||
traits->_width = width;
|
||||
traits->_height = height;
|
||||
traits->width = width;
|
||||
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->_windowDecoration = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW);
|
||||
traits->_doubleBuffer = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW);
|
||||
traits->pbuffer = (renderTargetImplemntation==osg::Camera::PIXEL_BUFFER || renderTargetImplemntation==osg::Camera::PIXEL_BUFFER_RTT);
|
||||
traits->windowDecoration = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW);
|
||||
traits->doubleBuffer = (renderTargetImplemntation==osg::Camera::SEPERATE_WINDOW);
|
||||
|
||||
osg::Texture* pBufferTexture = 0;
|
||||
GLenum bufferFormat = GL_NONE;
|
||||
@ -465,13 +465,13 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
{
|
||||
case(osg::Camera::DEPTH_BUFFER):
|
||||
{
|
||||
traits->_depth = 24;
|
||||
traits->depth = 24;
|
||||
depthAttached = true;
|
||||
break;
|
||||
}
|
||||
case(osg::Camera::STENCIL_BUFFER):
|
||||
{
|
||||
traits->_stencil = 8;
|
||||
traits->stencil = 8;
|
||||
stencilAttached = true;
|
||||
break;
|
||||
}
|
||||
@ -503,10 +503,10 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
|
||||
if (renderTargetImplemntation==osg::Camera::PIXEL_BUFFER_RTT)
|
||||
{
|
||||
traits->_target = bufferFormat;
|
||||
traits->_level = level;
|
||||
traits->_face = face;
|
||||
traits->_mipMapGeneration = attachment._mipMapGeneration;
|
||||
traits->target = bufferFormat;
|
||||
traits->level = level;
|
||||
traits->face = face;
|
||||
traits->mipMapGeneration = attachment._mipMapGeneration;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -526,29 +526,30 @@ void RenderStage::runCameraSetUp(osg::RenderInfo& renderInfo)
|
||||
|
||||
if (!depthAttached)
|
||||
{
|
||||
traits->_depth = 24;
|
||||
traits->depth = 24;
|
||||
}
|
||||
|
||||
if (!colorAttached)
|
||||
{
|
||||
if (bufferFormat == GL_NONE) bufferFormat = GL_RGB;
|
||||
|
||||
traits->_red = 8;
|
||||
traits->_green = 8;
|
||||
traits->_blue = 8;
|
||||
traits->_alpha = (bufferFormat==GL_RGBA) ? 8 : 0;
|
||||
traits->red = 8;
|
||||
traits->green = 8;
|
||||
traits->blue = 8;
|
||||
traits->alpha = (bufferFormat==GL_RGBA) ? 8 : 0;
|
||||
}
|
||||
|
||||
// share OpenGL objects if possible...
|
||||
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)
|
||||
{
|
||||
traits->_displayNum = sharedTraits->_displayNum;
|
||||
traits->_screenNum = sharedTraits->_screenNum;
|
||||
traits->hostName = sharedTraits->hostName;
|
||||
traits->displayNum = sharedTraits->displayNum;
|
||||
traits->screenNum = sharedTraits->screenNum;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,9 @@ SceneView::SceneView(DisplaySettings* ds)
|
||||
_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;
|
||||
|
||||
|
@ -87,19 +87,25 @@ bool GraphicsWindowX11::createVisualInfo()
|
||||
|
||||
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_GREEN_SIZE); attributes.push_back(_traits->_green);
|
||||
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_RED_SIZE); attributes.push_back(_traits->red);
|
||||
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_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
|
||||
// GLX_AUX_BUFFERS
|
||||
// GLX_ACCUM_RED_SIZE
|
||||
@ -109,7 +115,7 @@ bool GraphicsWindowX11::createVisualInfo()
|
||||
|
||||
attributes.push_back(None);
|
||||
|
||||
_visualInfo = glXChooseVisual( _display, _traits->_screenNum, &(attributes.front()) );
|
||||
_visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) );
|
||||
|
||||
return _visualInfo != 0;
|
||||
}
|
||||
@ -173,8 +179,8 @@ void GraphicsWindowX11::setWindowDecoration(bool flag)
|
||||
#if 0
|
||||
// now update the window dimensions to account for any size changes made by the window manager,
|
||||
XGetWindowAttributes( _display, _window, &watt );
|
||||
_traits->_width = watt.width;
|
||||
_traits->_height = watt.height;
|
||||
_traits->width = watt.width;
|
||||
_traits->height = watt.height;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -186,22 +192,20 @@ void GraphicsWindowX11::init()
|
||||
{
|
||||
if (!_traits || _initialized) return;
|
||||
|
||||
const char* displayString = _traits->_hostName.c_str();
|
||||
_display = XOpenDisplay(displayString);
|
||||
_display = XOpenDisplay(_traits->displayName().c_str());
|
||||
|
||||
unsigned int screen = _traits->_screenNum;
|
||||
unsigned int screen = _traits->screenNum;
|
||||
|
||||
if (!_display)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Error: Unable to open display \"" << XDisplayName(displayString) << "\". Is the DISPLAY environmental variable set?"<<std::endl;
|
||||
return;
|
||||
osg::notify(osg::NOTICE)<<"Error: Unable to open display \"" << XDisplayName(_traits->displayName().c_str()) << "\". Is the DISPLAY environmental variable set?"<<std::endl;
|
||||
}
|
||||
|
||||
// Query for GLX extension
|
||||
int errorBase, eventBase;
|
||||
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 );
|
||||
_display = 0;
|
||||
@ -249,9 +253,9 @@ void GraphicsWindowX11::init()
|
||||
}
|
||||
|
||||
_window = XCreateWindow( _display, _parent,
|
||||
_traits->_x,
|
||||
_traits->_y,
|
||||
_traits->_width, _traits->_height, 0,
|
||||
_traits->x,
|
||||
_traits->y,
|
||||
_traits->width, _traits->height, 0,
|
||||
_visualInfo->depth, InputOutput,
|
||||
_visualInfo->visual, mask, &swatt );
|
||||
|
||||
@ -268,14 +272,14 @@ void GraphicsWindowX11::init()
|
||||
sh.flags &= 0x7;
|
||||
sh.flags |= USPosition;
|
||||
sh.flags &= 0xB;
|
||||
sh.x = _traits->_x;
|
||||
sh.y = _traits->_y;
|
||||
sh.width = _traits->_width;
|
||||
sh.height = _traits->_height;
|
||||
XSetStandardProperties( _display, _window, _traits->_windowName.c_str(), _traits->_windowName.c_str(), None, 0, 0, &sh);
|
||||
sh.x = _traits->x;
|
||||
sh.y = _traits->y;
|
||||
sh.width = _traits->width;
|
||||
sh.height = _traits->height;
|
||||
XSetStandardProperties( _display, _window, _traits->windowName.c_str(), _traits->windowName.c_str(), None, 0, 0, &sh);
|
||||
|
||||
#if 1
|
||||
setWindowDecoration(_traits->_windowDecoration);
|
||||
setWindowDecoration(_traits->windowDecoration);
|
||||
#else
|
||||
setWindowDecoration(true);
|
||||
#endif
|
||||
@ -314,8 +318,8 @@ void GraphicsWindowX11::init()
|
||||
|
||||
// now update the window dimensions to account for any size changes made by the window manager,
|
||||
XGetWindowAttributes( _display, _window, &watt );
|
||||
_traits->_width = watt.width;
|
||||
_traits->_height = watt.height;
|
||||
_traits->width = watt.width;
|
||||
_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;
|
||||
|
||||
@ -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;
|
||||
|
||||
_traits->_x = ev.xconfigure.x;
|
||||
_traits->_y = ev.xconfigure.y;
|
||||
_traits->_width = ev.xconfigure.width;
|
||||
_traits->_height = ev.xconfigure.height;
|
||||
_traits->x = ev.xconfigure.x;
|
||||
_traits->y = ev.xconfigure.y;
|
||||
_traits->width = ev.xconfigure.width;
|
||||
_traits->height = ev.xconfigure.height;
|
||||
// need to dispatch resize event.
|
||||
break;
|
||||
}
|
||||
@ -445,8 +449,8 @@ void GraphicsWindowX11::checkEvents()
|
||||
while( watt.map_state != IsViewable );
|
||||
|
||||
osg::notify(osg::INFO)<<"MapNotify x="<<watt.x<<" y="<<watt.y<<" width="<<watt.width<<", height="<<watt.height<<std::endl;
|
||||
_traits->_width = watt.width;
|
||||
_traits->_height = watt.height;
|
||||
_traits->width = watt.width;
|
||||
_traits->height = watt.height;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -484,7 +488,7 @@ void GraphicsWindowX11::checkEvents()
|
||||
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);
|
||||
}
|
||||
@ -603,8 +607,8 @@ void GraphicsWindowX11::transformMouseXY(float& x, float& y)
|
||||
if (getEventQueue()->getUseFixedMouseInputRange())
|
||||
{
|
||||
osgGA::GUIEventAdapter* eventState = getEventQueue()->getCurrentEventState();
|
||||
x = eventState->getXmin() + (eventState->getXmax()-eventState->getXmin())*x/float(_traits->_width);
|
||||
y = eventState->getYmin() + (eventState->getYmax()-eventState->getYmin())*y/float(_traits->_height);
|
||||
x = eventState->getXmin() + (eventState->getXmax()-eventState->getXmin())*x/float(_traits->width);
|
||||
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)
|
||||
{
|
||||
const char* displayString = si._hostName.c_str();
|
||||
Display* display = XOpenDisplay(displayString);
|
||||
Display* display = XOpenDisplay(si.displayName().c_str());
|
||||
if(display)
|
||||
{
|
||||
unsigned int numScreens = ScreenCount(display);
|
||||
@ -676,19 +679,19 @@ struct X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSyste
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if(display)
|
||||
{
|
||||
width = DisplayWidth(display, si._screenNum);
|
||||
height = DisplayHeight(display, si._screenNum);
|
||||
width = DisplayWidth(display, si.screenNum);
|
||||
height = DisplayHeight(display, si.screenNum);
|
||||
XCloseDisplay(display);
|
||||
}
|
||||
else
|
||||
@ -701,7 +704,7 @@ struct X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSyste
|
||||
|
||||
virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)
|
||||
{
|
||||
if (traits->_pbuffer)
|
||||
if (traits->pbuffer)
|
||||
{
|
||||
return new GraphicsContextX11(traits);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
virtual ~ActionAdapter() {}
|
||||
|
||||
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; }
|
||||
|
||||
};
|
||||
@ -84,13 +84,13 @@ void View::setUpViewAcrossAllScreens()
|
||||
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->_x = 0;
|
||||
traits->_y = 0;
|
||||
traits->_width = width;
|
||||
traits->_height = height;
|
||||
traits->_windowDecoration = false;
|
||||
traits->_doubleBuffer = true;
|
||||
traits->_sharedContext = 0;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
|
||||
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);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
traits->_screenNum = i;
|
||||
traits->_x = 0;
|
||||
traits->_y = 0;
|
||||
traits->_width = width;
|
||||
traits->_height = height;
|
||||
traits->_windowDecoration = false;
|
||||
traits->_doubleBuffer = true;
|
||||
traits->_sharedContext = 0;
|
||||
traits->screenNum = i;
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user