Hi,
I have made a stereo application with two different algorithms: toe-in and off-axis.
I can also cycle through Toe-in, Off-axis and
no stereo.
However in non stereo mode the app slows down
(it looks like the same view of the scene is rendered 2 times)…
Here is a bit of my code:
render() :
m_hudManager.update(elapsedMilliseconds);
m_scene3D.animate(elapsedMilliseconds);ViewClipper::getInstance()->unapply();
s_3D->clearAllBuffers();
// s_3D is a just an abstraction layer
ViewClipper::getInstance()->apply();// the following line is a bit complex but basically it is the same as if ‘(stereoActive)’
if (((SimpleSetting *) Settings::getInstance()->getSetting(Settings::STEREO))->getValue())
{
// LEFT EYE
s_Stereolizer.lookWithLeftEye();
// Render the scene
_renderScene();
// I had to add following line because left and right buffers are shared (Nvidia quadro, before we had a 3DLabs oxygen which worked fine without).
glClear(GL_DEPTH_BUFFER_BIT);
glClear(GL_STENCIL_BUFFER_BIT);// RIGHT EYE
s_Stereolizer.lookWithRightEye();
// Render the scene
_renderScene();
}
else
{
s_3D->modelViewMode();
s_3D->loadIdentity();
s_3D->initBackBuffer();
getStudio().action(); // place the camera which is between LEFT_EYE and RIGHT_EYE positions
// render the scene
_renderScene();
}s_WAbs->swapBuffers();
}
The clearAllBuffers is :
clearAllBuffers()
{
// We select back buffer so that nicely written opengl drivers should clear
// right and left buffer when in stereo mode at the same time.
glDrawBuffer(GL_BACK);if (((SimpleSetting *) Settings::getInstance()->getSetting(Settings::SHADOWS))->getValue()
| | ((SimpleSetting *) Settings::getInstance()->getSetting(Settings::REFLECTIONS))->getValue()
| | ((SimpleSetting *) Settings::getInstance()->getSetting(Settings::HALOS))->getValue())
{
glClearStencil(0);
glStencilMask(0xff);
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
else
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
}
initBackbuffer is :
initBackBuffer()
{
glDrawBuffer( GL_BACK );
}
I feel like it might be because of initBackBuffer ?! If stereo mode is enable maybe I should select either left or right back buffer and not GL_BACK ???
Anyone ?
Thanks.
Lekeno