OK, here's what I have so far:
I have a windows app that works perfectly with Quadbuffering under Windows. And it compiles under Linux with no hassle. So, if I understand it correctly, I only need to patch the GLXGLSupport class to have everything work under Linux, right?
What I did was:
Add the
mHasQuadBuffer member to the class (that's the easy part
).
Test quadbuffering support at the end of the constructor with the following:
Code: Select all
//------ Begin quadbuffer patch
int stereoAttrib[] = { GLX_STEREO, True, None };
fbConfigs = chooseFBConfig( stereoAttrib, &nConfigs );
if( fbConfigs )
{
mHasQuadBuffer = true;
}
//------ End quadbuffer patch
XFree (fbConfigs);
Add the "Stereo Mode" option in the
addConfig method. This part is basically the same as what is done in the Win32SUpport class:
Code: Select all
ConfigOption optStereoMode;
optStereoMode.name = "Stereo Mode";
optStereoMode.possibleValues.push_back("Mono");
if (mHasQuadBuffer)
{
optStereoMode.possibleValues.push_back("QuadBuffer");
optStereoMode.currentValue = optStereoMode.possibleValues[1];
optStereoMode.immutable = false;
}
else
{
optStereoMode.currentValue = optStereoMode.possibleValues[0];
optStereoMode.immutable = true;
}
mOptions[optStereoMode.name] = optStereoMode;
And finally, add the
GLX_STEREO option to the GLX context if quadbuffering is selected.
Ideally, I would have liked to add this in the
createNewContext method, but I could'nt find a way to modify the fbConfig parameter passed as an argument. Instead, what I did, was change the
chooseFBConfig to add the
GLX_STEREO attribute if needed. Here's my code for the method:
Code: Select all
GLXFBConfig* GLXGLSupport::chooseFBConfig(const GLint *attribList, GLint *nElements)
{
GLXFBConfig *fbConfigs;
//------ Begin Stereo Patch
ConfigOptionMap::iterator opt;
if( attribList && (opt = mOptions.find("Stereo Mode")) != mOptions.end() )
{
LogManager::getSingleton().logMessage( "Stereo Mode is " + opt->second.currentValue );
if (opt->second.currentValue == "QuadBuffer")
{
////Add GLX_STEREO
int attribListSize = 0;
//First iterate to get the number of attributes
while( attribList[attribListSize] != None )
++attribListSize;
//Add one more to get the correct size
++attribListSize;
//Now create a copy of the attrib list and add two values to it to activate stereo
GLint* newAttribList = new GLint[ attribListSize + 2];
for( int i = 0; i < attribListSize; ++i )
{
newAttribList[i] = attribList[i];
}
newAttribList[attribListSize] = GLX_STEREO;
newAttribList[attribListSize + 1] = True;
newAttribList[attribListSize + 2] = None;
if (GLXEW_VERSION_1_3)
fbConfigs = glXChooseFBConfig(mGLDisplay, DefaultScreen(mGLDisplay), attribList, nElements);
else
fbConfigs = glXChooseFBConfigSGIX(mGLDisplay, DefaultScreen(mGLDisplay), attribList, nElements);
delete newAttribList;
if( !fbConfigs )
{
OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Stereo not supported with currently selected options.", "GLXGLSupport::chooseFBConfig");
}
else
{
LogManager::getSingleton().logMessage( ">>>>>>>>>>>>>> Adding Stereo succeeded! :-D" );
}
return fbConfigs;
}
}
//------ End Stereo Patch
if (GLXEW_VERSION_1_3)
fbConfigs = glXChooseFBConfig(mGLDisplay, DefaultScreen(mGLDisplay), attribList, nElements);
else
fbConfigs = glXChooseFBConfigSGIX(mGLDisplay, DefaultScreen(mGLDisplay), attribList, nElements);
return fbConfigs;
}
Now what happens is everything works as it should, I do get the
">>>>>>>>>>>>>> Adding Stereo succeeded! " message in the log, but nothing else happens. My app does not run in stereo. WHY? :'(
For the record, my Linux is correctly set up to run stereo apps. I tested it with glxgears -stereo which works fine.
I think that ideally, it would be better to make the modifications in the
createNewContext method so, if anybody has any idea how that can be done, I'd be willing to give it a try and report back here.