libgls  1.0.1
Stereoscopic Rendering with OpenGL
libgls Reference


The GL stereoscopic library (libgls) allows OpenGL programs to render stereoscopic content in a variety of ways, without depending on OpenGL quad-buffer support. See GLSmode for a list of supported stereoscopic display modes.


All functions need a valid OpenGL context to work properly.

Include the header file:

#include <gls/gls.h>

Create a GLS context:

Render your stereoscopic scene:

// ... clear and render left view ...
// ... clear and render right view ...
// ... swap buffers ...

Or, if you want to manage the views yourself:

GLuint left_texture, right_texture;
// ... render left view into left_texture ...
// ... render right view into right_texture ...
glsDrawViews(ctx, GLS_MODE_RED_CYAN_DUBOIS, GL_FALSE, left_texture, right_texture);


Scene Management

To render left and right view, you need to set up proper projection and modelview matrices to achieve a good stereoscopic effect.

The convenience functions glsFrustum() / glsPerspective() and glsLookAt() can do that for you; they are drop-in replacements for glFrustum() / gluPerspective() and gluLookAt().

See for more information on this topic.