Skip to content
Sk. Mohammadul Haque edited this page Nov 24, 2022 · 5 revisions

Welcome to the GLStereo Wiki!

Below is a basic example to get started with:

Setting the window size

int SCREEN_WIDTH = 640;
int SCREEN_HEIGHT = 480;

Creating a GLStereoview structure

GLSTEREOVIEW sv = glstereo_new(0.05f, 2.5f, 45.0f, 0.05f, 10.0f, 
        float(SCREEN_WIDTH)/float(SCREEN_HEIGHT), GLSTEREO_RED_CYAN);

Setting the ModelView matrix

float centerx = 0.0f, centerz = 0.0f, theta = 0.0f;
float c = cosf(theta), s = sinf(theta);
sv->modelview[0] = c;
sv->modelview[1] = 0.0f;
sv->modelview[2] = -s;
sv->modelview[3] = 0.0f;

sv->modelview[4] = 0.0f;
sv->modelview[5] = 1.0f;
sv->modelview[6] = 0.0f;
sv->modelview[7] = 0.0f;

sv->modelview[8] = s;
sv->modelview[9] = 0.0f;
sv->modelview[10] = c;
sv->modelview[11] = 0.0f;

sv->modelview[12] = centerx*(1-c)-centerz*s;
sv->modelview[13] = 0.0f;
sv->modelview[14] = centerz*(1-c)+centerx*s;
sv->modelview[15] = 1.0f;

Compiling a drawing list

GLuint dlist = glGenLists(1);
glNewList(dlist, GL_COMPILE);
// draw in OpenGL context
...
glEndList();

Rendering the graphics

glstereo_left(sv);
glCallList(dlist);
glstereo_right(sv);
glCallList(dlist);

Cleaning up

glstereo_delete(sv);
glDeleteLists(dlist,1);