Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Stereo Anaglyph using glColorMask

  1. #1

    Stereo Anaglyph using glColorMask

    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...

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007

    Re: Stereo Anaglyph using glColorMask

    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.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog:

  3. #3

    Re: Stereo Anaglyph using glColorMask

    Might I be able to change the eye position using glTranslate?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Grenoble - France

    Re: Stereo Anaglyph using glColorMask

    Read "Asymmetric frustum parallel axis projection stereo" section here, at the bottom :

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts