View Full Version : Stereo Anaglyph using glColorMask

10-19-2010, 12:51 PM
Wondering if someone could verify that my cam panning is correct for the proper color or if I'm doing this completely wrong. Thanks

for(int x3d = 0; x3d < 2; x3d++) {

//3d View - Set up Color Masking
if (anaglyph) {
if(x3d == 0) {
gl.glColorMask(true, false, false, true);
else {
gl.glColorMask(false, true, true, true);
else {
Draw a bunch of stuff...

10-20-2010, 05:57 AM
When you set the two cameras for anaglyph rendering you should set the two eye position to an appropriate distance from each other. This fully depends on your application.
Besides that, you also want to use a different view direction for the two eyes based on where is the focus distance for the "eyes".
Actually the simplest way to do it is to use gluLookAt.

gluLookAt(-1,0,0, 0,0,-3, 0,1,0);
... draw left eye image ...
gluLookAt( 1,0,0, 0,0,-3, 0,1,0);
... draw right eye image ...

Of course you don't have to use gluLookAt but whatever view matrix you like but the math behind it should be something similar.
So set the eye positions but don't forget to set their direction as well so the view directions intersect at the focus plane.

10-20-2010, 07:20 AM
Might I be able to change the eye position using glTranslate?

10-20-2010, 08:14 AM
Read "Asymmetric frustum parallel axis projection stereo" section here, at the bottom :

The drawing is better here, read "Off-axis (Correct)" :