From 0356a7b9c8b66bbbc4e83c4b31cd787cffc33042 Mon Sep 17 00:00:00 2001
From: Gilles Marckmann <gilles.marckmann@ec-nantes.fr>
Date: Fri, 22 Oct 2010 11:08:34 +0000
Subject: [PATCH] introduction of two new option :

GmshSetOption("General", "Stereo", 1.);
GmshSetOption("General", "Camera", 1.);

Camera : to use camera instead of rotation matrix

Stereo : to turn on/off the stereo rendering (for device with left and
right views in the two buffers (left and right) of OpenGL : Works in utils/api_demos/mainGlut
---
 Common/Context.h        |  2 +-
 Common/DefaultOptions.h | 10 +++++++++-
 Common/Options.cpp      | 26 ++++++++++++++++++++++++++
 Common/Options.h        |  3 +++
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/Common/Context.h b/Common/Context.h
index be32ec637b..780417d272 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -128,7 +128,7 @@ class CTX {
   // generation ->only for geo/post)
   double lc;
   // double buffer/antialias/stereo graphics?
-  int db, antialiasing, stereo;
+  int db, antialiasing, stereo , camera;
   // orthogonal projection? 
   int ortho;
   // draw the bounding boxes and the rot center?
diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 297bcc2246..c3eaea4551 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -592,7 +592,13 @@ StringXNumber GeneralOptions_Number[] = {
     "Enable expert mode (to disable all the messages meant for inexperienced "
     "users)" },
 
-  { F|O, "FastRedraw" , opt_general_fast_redraw, 0. ,
+   { F|O, "Stereo" , opt_general_stereo_mode, 0. ,
+    "Enable stereo mode" },
+
+   { F|O, "Camera" , opt_general_camera_mode, 0. ,
+    "Enable camera view mode" },
+
+ { F|O, "FastRedraw" , opt_general_fast_redraw, 0. ,
     "Draw simplified model while rotating, panning and zooming" },
   { F|S, "FieldPositionX" , opt_general_field_position0 , 650. , 
     "Horizontal position (in pixels) of the upper left corner of the field window" }, 
@@ -834,6 +840,8 @@ StringXNumber GeneralOptions_Number[] = {
     " window" }, 
   { F|O, "Stereo" , opt_general_stereo , 0. ,
     "Use stereo rendering" },
+  { F|O, "Camera" , opt_general_camera , 0. ,
+    "Use a camera" },
   { F|S, "SystemMenuBar" , opt_general_system_menu_bar , 1. , 
     "Use the system menu bar on Mac OS X?" }, 
 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index d7ee48ee72..f9ab7f8362 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -3513,6 +3513,14 @@ double opt_general_stereo(OPT_ARGS_NUM)
   return CTX::instance()->stereo;
 }
 
+double opt_general_camera(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET) {
+    CTX::instance()->camera = (int)val;
+  }
+  return CTX::instance()->camera;
+}
+
 double opt_general_alpha_blending(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
@@ -3684,6 +3692,24 @@ double opt_general_expert_mode(OPT_ARGS_NUM)
   return CTX::instance()->expertMode;
 }
 
+
+double opt_general_stereo_mode(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET)
+    CTX::instance()->stereo = (int)val;
+
+  return CTX::instance()->stereo ;
+}
+
+double opt_general_camera_mode(OPT_ARGS_NUM)
+{
+  if(action & GMSH_SET)
+    CTX::instance()->camera = (int)val;
+
+  return CTX::instance()->camera ;
+}
+
+
 double opt_general_clip0a(OPT_ARGS_NUM)
 {
   if(action & GMSH_SET)
diff --git a/Common/Options.h b/Common/Options.h
index db1d7616f8..538953fbd5 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -340,6 +340,7 @@ double opt_general_quadric_subdivisions(OPT_ARGS_NUM);
 double opt_general_double_buffer(OPT_ARGS_NUM);
 double opt_general_antialiasing(OPT_ARGS_NUM);
 double opt_general_stereo(OPT_ARGS_NUM);
+double opt_general_camera(OPT_ARGS_NUM);
 double opt_general_alpha_blending(OPT_ARGS_NUM);
 double opt_general_vector_type(OPT_ARGS_NUM);
 double opt_general_arrow_head_radius(OPT_ARGS_NUM);
@@ -349,6 +350,8 @@ double opt_general_trackball(OPT_ARGS_NUM);
 double opt_general_rotation_center_cg(OPT_ARGS_NUM);
 double opt_general_zoom_factor(OPT_ARGS_NUM);
 double opt_general_expert_mode(OPT_ARGS_NUM);
+double opt_general_stereo_mode(OPT_ARGS_NUM);
+double opt_general_camera_mode(OPT_ARGS_NUM);
 double opt_general_clip0a(OPT_ARGS_NUM);
 double opt_general_clip0b(OPT_ARGS_NUM);
 double opt_general_clip0c(OPT_ARGS_NUM);
-- 
GitLab