Added glContexVersion, glContextFlags and glContextProfileMask members to osg::GraphicsContext::Traits to support GL3 graphics context creation.
Moved the handling of DisplaySettings into Traits constructor. Added support for s/getGLContextVersion(), s/getGLContextFlags() and s/getGLContextProfileMask() to osg::DisplaySettings. Added command line and env var support for setting the GLContextVersion, GLContextFlags and GLContextProfileMask to osg::DisplaySettings.
This commit is contained in:
@@ -206,6 +206,24 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
void setMaxBufferObjectPoolSize(unsigned int size) { _maxBufferObjectPoolSize = size; }
|
||||
unsigned int getMaxBufferObjectPoolSize() const { return _maxBufferObjectPoolSize; }
|
||||
|
||||
/** Set the hint of which OpenGL version to attempt to create a graphics context for.*/
|
||||
void setGLContextVersion(const std::string& version) { _glContextVersion = version; }
|
||||
|
||||
/** Get the hint of which OpenGL version to attempt to create a graphics context for.*/
|
||||
const std::string getGLContextVersion() const { return _glContextVersion; }
|
||||
|
||||
/** Set the hint of the flags to use in when creating graphic contexts.*/
|
||||
void setGLContextFlags(unsigned int flags) { _glContextFlags = flags; }
|
||||
|
||||
/** Get the hint of the flags to use in when creating graphic contexts.*/
|
||||
unsigned int getGLContextFlags() const { return _glContextFlags; }
|
||||
|
||||
/** Set the hint of the profile mask to use in when creating graphic contexts.*/
|
||||
void setGLContextProfileMask(unsigned int mask) { _glContextProfileMask = mask; }
|
||||
|
||||
/** Get the hint of the profile mask to use in when creating graphic contexts.*/
|
||||
unsigned int getGLContextProfileMask() const { return _glContextProfileMask; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~DisplaySettings();
|
||||
@@ -249,6 +267,10 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
|
||||
unsigned int _maxTexturePoolSize;
|
||||
unsigned int _maxBufferObjectPoolSize;
|
||||
|
||||
std::string _glContextVersion;
|
||||
unsigned int _glContextFlags;
|
||||
unsigned int _glContextProfileMask;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -68,35 +68,7 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
/** 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(true),
|
||||
red(8),
|
||||
blue(8),
|
||||
green(8),
|
||||
alpha(0),
|
||||
depth(24),
|
||||
stencil(0),
|
||||
sampleBuffers(0),
|
||||
samples(0),
|
||||
pbuffer(false),
|
||||
quadBufferStereo(false),
|
||||
doubleBuffer(false),
|
||||
target(0),
|
||||
format(0),
|
||||
level(0),
|
||||
face(0),
|
||||
mipMapGeneration(false),
|
||||
vsync(true),
|
||||
useMultiThreadedOpenGLEngine(false),
|
||||
useCursor(true),
|
||||
sharedContext(0),
|
||||
setInheritedWindowPixelFormat(false),
|
||||
overrideRedirect(false) {}
|
||||
Traits(DisplaySettings* ds=0);
|
||||
|
||||
// graphics context original and size
|
||||
int x;
|
||||
@@ -141,6 +113,12 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
|
||||
// enable cursor
|
||||
bool useCursor;
|
||||
|
||||
// settings used in set up of graphics context, only presently used by GL3 build of OSG.
|
||||
std::string glContextVersion;
|
||||
unsigned int glContextFlags;
|
||||
unsigned int glContextProfileMask;
|
||||
|
||||
|
||||
// shared context
|
||||
GraphicsContext* sharedContext;
|
||||
|
||||
@@ -83,6 +83,10 @@ void DisplaySettings::setDisplaySettings(const DisplaySettings& vs)
|
||||
|
||||
_maxTexturePoolSize = vs._maxTexturePoolSize;
|
||||
_maxBufferObjectPoolSize = vs._maxBufferObjectPoolSize;
|
||||
|
||||
_glContextVersion = vs._glContextVersion;
|
||||
_glContextFlags = vs._glContextFlags;
|
||||
_glContextProfileMask = vs._glContextProfileMask;
|
||||
}
|
||||
|
||||
void DisplaySettings::merge(const DisplaySettings& vs)
|
||||
@@ -156,6 +160,10 @@ void DisplaySettings::setDefaults()
|
||||
|
||||
_maxTexturePoolSize = 0;
|
||||
_maxBufferObjectPoolSize = 0;
|
||||
|
||||
_glContextVersion = "1.0";
|
||||
_glContextFlags = 0;
|
||||
_glContextProfileMask = 0;
|
||||
}
|
||||
|
||||
void DisplaySettings::setMaxNumberOfGraphicsContexts(unsigned int num)
|
||||
@@ -198,6 +206,9 @@ static ApplicationUsageProxy DisplaySetting_e17(ApplicationUsage::ENVIRONMENTAL_
|
||||
static ApplicationUsageProxy DisplaySetting_e18(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_TEXTURE_POOL_SIZE <int>","Set the hint size of texture pool to manage.");
|
||||
static ApplicationUsageProxy DisplaySetting_e19(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_BUFFER_OBJECT_POOL_SIZE <int>","Set the hint size of vertex buffer object pool to manage.");
|
||||
static ApplicationUsageProxy DisplaySetting_e20(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_FBO_POOL_SIZE <int>","Set the hint size of frame buffer object pool to manage.");
|
||||
static ApplicationUsageProxy DisplaySetting_e21(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_VERSION <major.minor>","Set the hint for the GL version to create contexts for.");
|
||||
static ApplicationUsageProxy DisplaySetting_e22(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_FLAGS <uint>","Set the hint for the GL context flags to use when creating contexts.");
|
||||
static ApplicationUsageProxy DisplaySetting_e23(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_GL_CONTEXT_PROFILE_MASK <uint>","Set the hint for the GL context profile mask to use when creating contexts.");
|
||||
|
||||
void DisplaySettings::readEnvironmentalVariables()
|
||||
{
|
||||
@@ -404,6 +415,21 @@ void DisplaySettings::readEnvironmentalVariables()
|
||||
{
|
||||
_maxBufferObjectPoolSize = atoi(ptr);
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_GL_VERSION")) != 0 || (ptr = getenv("OSG_GL_CONTEXT_VERSION")) != 0)
|
||||
{
|
||||
_glContextVersion = ptr;
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_GL_CONTEXT_FLAGS")) != 0)
|
||||
{
|
||||
_glContextFlags = atoi(ptr);
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_GL_CONTEXT_PROFILE_MASK")) != 0)
|
||||
{
|
||||
_glContextProfileMask = atoi(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
@@ -423,6 +449,9 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--samples <num>","Request a multisample visual");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--cc","Request use of compile contexts and threads");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--serialize-draw <mode>","OFF | ON - set the serialization of draw dispatch");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--gl-version <major.minor>","Set the hint of which GL version to use when creating graphics contexts.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--gl-flags <mask>","Set the hint of which GL flags projfile mask to use when creating graphics contexts.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--gl-profile-mask <mask>","Set the hint of which GL context profile mask to use when creating graphics contexts.");
|
||||
}
|
||||
|
||||
std::string str;
|
||||
@@ -494,6 +523,10 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
while(arguments.read("--texture-pool-size",_maxTexturePoolSize)) {}
|
||||
while(arguments.read("--buffer-object-pool-size",_maxBufferObjectPoolSize)) {}
|
||||
|
||||
while (arguments.read("--gl-version", _glContextVersion)) {}
|
||||
while (arguments.read("--gl-flags", _glContextFlags)) {}
|
||||
while (arguments.read("--gl-profile-mask", _glContextProfileMask)) {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +153,63 @@ void GraphicsContext::ScreenIdentifier::setScreenIdentifier(const std::string& d
|
||||
#endif
|
||||
}
|
||||
|
||||
GraphicsContext::Traits::Traits(DisplaySettings* ds):
|
||||
x(0),
|
||||
y(0),
|
||||
width(0),
|
||||
height(0),
|
||||
windowDecoration(false),
|
||||
supportsResize(true),
|
||||
red(8),
|
||||
blue(8),
|
||||
green(8),
|
||||
alpha(0),
|
||||
depth(24),
|
||||
stencil(0),
|
||||
sampleBuffers(0),
|
||||
samples(0),
|
||||
pbuffer(false),
|
||||
quadBufferStereo(false),
|
||||
doubleBuffer(false),
|
||||
target(0),
|
||||
format(0),
|
||||
level(0),
|
||||
face(0),
|
||||
mipMapGeneration(false),
|
||||
vsync(true),
|
||||
useMultiThreadedOpenGLEngine(false),
|
||||
useCursor(true),
|
||||
glContextVersion("1.0"),
|
||||
glContextFlags(0),
|
||||
glContextProfileMask(0),
|
||||
sharedContext(0),
|
||||
setInheritedWindowPixelFormat(false),
|
||||
overrideRedirect(false)
|
||||
{
|
||||
if (ds)
|
||||
{
|
||||
alpha = ds->getMinimumNumAlphaBits();
|
||||
stencil = ds->getMinimumNumStencilBits();
|
||||
sampleBuffers = ds->getMultiSamples();
|
||||
samples = ds->getNumMultiSamples();
|
||||
if (ds->getStereo())
|
||||
{
|
||||
switch(ds->getStereoMode())
|
||||
{
|
||||
case(osg::DisplaySettings::QUAD_BUFFER): quadBufferStereo = true; break;
|
||||
case(osg::DisplaySettings::VERTICAL_INTERLACE):
|
||||
case(osg::DisplaySettings::CHECKERBOARD):
|
||||
case(osg::DisplaySettings::HORIZONTAL_INTERLACE): stencil = 8; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
glContextVersion = ds->getGLContextVersion();
|
||||
glContextFlags = ds->getGLContextFlags();
|
||||
glContextProfileMask = ds->getGLContextProfileMask();
|
||||
}
|
||||
}
|
||||
|
||||
class ContextData
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -449,7 +449,7 @@ void View::setUpViewAcrossAllScreens()
|
||||
unsigned int width, height;
|
||||
wsi->getScreenResolution(si, width, height);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds);
|
||||
traits->hostName = si.hostName;
|
||||
traits->displayNum = si.displayNum;
|
||||
traits->screenNum = si.screenNum;
|
||||
@@ -457,24 +457,9 @@ void View::setUpViewAcrossAllScreens()
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->alpha = ds->getMinimumNumAlphaBits();
|
||||
traits->stencil = ds->getMinimumNumStencilBits();
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
traits->sampleBuffers = ds->getMultiSamples();
|
||||
traits->samples = ds->getNumMultiSamples();
|
||||
if (ds->getStereo())
|
||||
{
|
||||
switch(ds->getStereoMode())
|
||||
{
|
||||
case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;
|
||||
case(osg::DisplaySettings::VERTICAL_INTERLACE):
|
||||
case(osg::DisplaySettings::CHECKERBOARD):
|
||||
case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
@@ -531,7 +516,7 @@ void View::setUpViewAcrossAllScreens()
|
||||
unsigned int width, height;
|
||||
wsi->getScreenResolution(si, width, height);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds);
|
||||
traits->hostName = si.hostName;
|
||||
traits->displayNum = si.displayNum;
|
||||
traits->screenNum = si.screenNum;
|
||||
@@ -540,24 +525,9 @@ void View::setUpViewAcrossAllScreens()
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->alpha = ds->getMinimumNumAlphaBits();
|
||||
traits->stencil = ds->getMinimumNumStencilBits();
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
traits->sampleBuffers = ds->getMultiSamples();
|
||||
traits->samples = ds->getNumMultiSamples();
|
||||
if (ds->getStereo())
|
||||
{
|
||||
switch(ds->getStereoMode())
|
||||
{
|
||||
case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;
|
||||
case(osg::DisplaySettings::VERTICAL_INTERLACE):
|
||||
case(osg::DisplaySettings::CHECKERBOARD):
|
||||
case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
@@ -610,7 +580,7 @@ void View::setUpViewInWindow(int x, int y, int width, int height, unsigned int s
|
||||
{
|
||||
osg::DisplaySettings* ds = _displaySettings.valid() ? _displaySettings.get() : osg::DisplaySettings::instance();
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds);
|
||||
|
||||
traits->readDISPLAY();
|
||||
if (traits->displayNum<0) traits->displayNum = 0;
|
||||
@@ -620,24 +590,9 @@ void View::setUpViewInWindow(int x, int y, int width, int height, unsigned int s
|
||||
traits->y = y;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->alpha = ds->getMinimumNumAlphaBits();
|
||||
traits->stencil = ds->getMinimumNumStencilBits();
|
||||
traits->windowDecoration = true;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
traits->sampleBuffers = ds->getMultiSamples();
|
||||
traits->samples = ds->getNumMultiSamples();
|
||||
if (ds->getStereo())
|
||||
{
|
||||
switch(ds->getStereoMode())
|
||||
{
|
||||
case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;
|
||||
case(osg::DisplaySettings::VERTICAL_INTERLACE):
|
||||
case(osg::DisplaySettings::CHECKERBOARD):
|
||||
case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
@@ -694,7 +649,7 @@ void View::setUpViewOnSingleScreen(unsigned int screenNum)
|
||||
unsigned int width, height;
|
||||
wsi->getScreenResolution(si, width, height);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds);
|
||||
traits->hostName = si.hostName;
|
||||
traits->displayNum = si.displayNum;
|
||||
traits->screenNum = si.screenNum;
|
||||
@@ -702,24 +657,9 @@ void View::setUpViewOnSingleScreen(unsigned int screenNum)
|
||||
traits->y = 0;
|
||||
traits->width = width;
|
||||
traits->height = height;
|
||||
traits->alpha = ds->getMinimumNumAlphaBits();
|
||||
traits->stencil = ds->getMinimumNumStencilBits();
|
||||
traits->windowDecoration = false;
|
||||
traits->doubleBuffer = true;
|
||||
traits->sharedContext = 0;
|
||||
traits->sampleBuffers = ds->getMultiSamples();
|
||||
traits->samples = ds->getNumMultiSamples();
|
||||
if (ds->getStereo())
|
||||
{
|
||||
switch(ds->getStereoMode())
|
||||
{
|
||||
case(osg::DisplaySettings::QUAD_BUFFER): traits->quadBufferStereo = true; break;
|
||||
case(osg::DisplaySettings::VERTICAL_INTERLACE):
|
||||
case(osg::DisplaySettings::CHECKERBOARD):
|
||||
case(osg::DisplaySettings::HORIZONTAL_INTERLACE): traits->stencil = 8; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user