Added catch for handling cases where undefined settings for dislayNum and screenNum are used

This commit is contained in:
Robert Osfield
2008-01-04 13:57:36 +00:00
parent 1bfb630137
commit 35d9107d81
2 changed files with 20 additions and 2 deletions

View File

@@ -38,12 +38,25 @@ class OSG_EXPORT GraphicsContext : public Object
/** Return the display name in the form hostName::displayNum:screenNum. */
std::string displayName() const;
/** Read the DISPLAY environmental variable, and set the ScreenIdentifier accordingly.*/
/** Read the DISPLAY environmental variable, and set the ScreenIdentifier accordingly.
* Note, if either of displayNum or screenNum are not defined then -1 is set respectively to
* signify the this parameter has not been set. When parameters are undefined one can call
* call setUndefinedScreenDetalstoDefaultScreen() method after readDISPLAY() to ensure valid values. */
void readDISPLAY();
/** Set the screenIndentifier from the displayName string.*/
/** Set the screenIndentifier from the displayName string.
* Note, if either of displayNum or screenNum are not defined then -1 is set respectively to
* signify the this parameter has not been set. When parameters are undefined one can call
* call setUndefinedScreenDetalstoDefaultScreen() method after readDISPLAY() to ensure valid values. */
void setScreenIdentifier(const std::string& displayName);
/** Set any undefined displayNum or screenNum values (i.e. -1) to the default display & screen of 0 respectively.*/
void setUndefinedScreenDetailsToDefaultScreen()
{
if (displayNum<0) displayNum = 0;
if (screenNum<0) screenNum = 0;
}
std::string hostName;
int displayNum;
int screenNum;

View File

@@ -55,7 +55,12 @@ GraphicsContext::WindowingSystemInterface* GraphicsContext::getWindowingSystemIn
GraphicsContext* GraphicsContext::createGraphicsContext(Traits* traits)
{
if (s_WindowingSystemInterface.valid())
{
// catch any undefined values.
if (traits) traits->setUndefinedScreenDetailsToDefaultScreen();
return s_WindowingSystemInterface->createGraphicsContext(traits);
}
else
return 0;
}