From dbd5a7004e5e1de2c18bf525e1d7315c634e3e42 Mon Sep 17 00:00:00 2001 From: Gilles Marckmann <gilles.marckmann@ec-nantes.fr> Date: Thu, 2 Dec 2010 15:20:50 +0000 Subject: [PATCH] implementation of stereography --- Fltk/graphicWindow.cpp | 4 ++++ Fltk/openglWindow.cpp | 13 +++++++------ Graphics/Camera.cpp | 3 ++- Graphics/drawContext.cpp | 10 +++++----- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp index 70d674588f..ea1676199e 100644 --- a/Fltk/graphicWindow.cpp +++ b/Fltk/graphicWindow.cpp @@ -584,6 +584,10 @@ graphicWindow::graphicWindow(bool main, int numTiles) int mode = FL_RGB | FL_DEPTH | (CTX::instance()->db ? FL_DOUBLE : FL_SINGLE); if(CTX::instance()->antialiasing) mode |= FL_MULTISAMPLE; //mode |= FL_STEREO; + if(CTX::instance()->stereo) { + mode |= FL_DOUBLE; + mode |= FL_STEREO; + } for(unsigned int i = 0; i < gl.size(); i++) gl[i]->mode(mode); tile->end(); diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp index 82a734a0db..9e020b0fc8 100644 --- a/Fltk/openglWindow.cpp +++ b/Fltk/openglWindow.cpp @@ -271,8 +271,7 @@ void openglWindow::draw() glAccum(GL_RETURN,1.0); */ - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - + //right eye XYZ eye =cam->eyesep / 2.0* cam->right; glMatrixMode(GL_PROJECTION); @@ -291,6 +290,8 @@ void openglWindow::draw() cam->up.x, cam->up.y, cam->up.z); _ctx->draw3d(); _ctx->draw2d(); + _drawScreenMessage(); + _drawBorder(); //left eye glMatrixMode(GL_PROJECTION); @@ -310,12 +311,12 @@ void openglWindow::draw() cam->up.x, cam->up.y, cam->up.z); _ctx->draw3d(); _ctx->draw2d(); - - glPushMatrix(); - + _drawScreenMessage(); + _drawBorder(); + } else{ - _ctx->draw3d(); + _ctx->draw3d(); _ctx->draw2d(); _drawScreenMessage(); _drawBorder(); diff --git a/Graphics/Camera.cpp b/Graphics/Camera.cpp index 82504520bf..38463dce72 100644 --- a/Graphics/Camera.cpp +++ b/Graphics/Camera.cpp @@ -25,7 +25,8 @@ void Camera::init(){ on=true; glFnear=0.1 ; glFfar=10000; - eye_sep_ratio=.015; + // eye_sep_ratio=.015; + eye_sep_ratio=.05; // apparent angle of the screen height aperture = 25; focallength = 100.; diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp index 1fb7d4b363..19e5902ba0 100644 --- a/Graphics/drawContext.cpp +++ b/Graphics/drawContext.cpp @@ -455,7 +455,7 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) fabs(CTX::instance()->max[2])); if(zmax < CTX::instance()->lc) zmax = CTX::instance()->lc; - if (CTX::instance()->camera ) { // if we use the new camera mode + if ( (CTX::instance()->camera) && (!CTX::instance()->stereo) ) { // if we use the new camera mode double clip_near, clip_far; clip_near = 0.75 * CTX::instance()->clipFactor * zmax; @@ -472,12 +472,12 @@ void drawContext::initProjection(int xpick, int ypick, int wpick, int hpick) glBegin(GL_QUADS); //glColor4ubv((GLubyte *) & CTX::instance()->color.bg); glColor3d(.8,.8,.95); - glVertex3i(-dx,-dy,dz); - glVertex3i( dx,-dy,dz); + glVertex3i((int)-dx,(int)-dy,(int)dz); + glVertex3i((int) dx,(int)-dy,(int)dz); // glColor4ubv((GLubyte *) & CTX::instance()->color.bgGrad); glColor3d(.1,.1,.3); - glVertex3i( dx, dy,dz); - glVertex3i(-dx, dy,dz); + glVertex3i((int) dx,(int) dy,(int)dz); + glVertex3i((int)-dx,(int) dy,(int)dz); glEnd(); glPopMatrix(); glEnable(GL_DEPTH_TEST); -- GitLab