According to
http://www.gali-3d.com/archive/articles/StereoOpenGL/StereoscopicOpenGLTutorial.phpI have to do the following steps to achieve stereoscopic rendering:
Quote:
1) Set the geometry for the view from left human eye
2) Set the left eye rendering buffers
3) Render the left eye image
4) Clear Z-buffer (if the same Z-buffer for left and right image is used)
5) Set the geometry for the view from right human eye
6) Set the right eye rendering buffers
7) Render the right eye image
Swap buffers
To transfer this to Horde3D I will enable quad-buffering by setting the appropriate
flag for GLFW/SDL (e.g. SDL_GL_SetAttribute(SDL_GL_Stereo, 1); ) and then render my scene
from two different eye-positions as follows:
1. - 3.) This should be easy as I can render as usual:
Code:
// left eye
Horde3D::setNodeTransform( _cam, 0, 0, 0, 0 ,0, 0, 1, 1, 1 ); // fixed view only
Horde3D::setNodeParami(_cam, CameraNodeParams::OutputBufferIndex, 0);
Horde3D::render( _cam );
4.) Do I have to clear the Z-buffer manually? If yes, how do I do that? I think this would require
some native OpenGL calls.
5. - 8.) To render the scene for the right eye's position I think that I have to translate my
camera's position by my eye-distance to the right and then set the OutputBufferIndex to my
right eye's buffer. Do I have to translate the camera manually or does Horde3D automatically
adjust the eye-position when I set the buffer to the right eye?
Finally I would call Horde3D::render(_cam); again to get my right eye's view rendered
to the appropriate buffer and then swap buffers.
Code:
/*
clear Z-buffer here....
*/
// right eye
Horde3D::setNodeTransform( _cam, eyeDistance, 0, 0, 0 ,0, 0, 1, 1, 1 ); // fixed view only
Horde3D::setNodeParami(_cam, CameraNodeParams::OutputBufferIndex, 1);
Horde3D::render( _cam );
SDL_GL_SwapBuffers();
Is anything wrong or missing in this approach? I am not quite sure about how to perform
the eye-offset and how to clear the Z-buffer.