00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2011 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: FreeVRDisplayDevice.C,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.30 $ $Date: 2011/06/10 05:04:24 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * 00019 * a FreeVR specific display device for VMD 00020 ***************************************************************************/ 00021 00022 #include <freevr.h> // include FreeVR library prototypes 00023 #include "Inform.h" 00024 #include "FreeVRDisplayDevice.h" 00025 00026 // static string storage used for returning stereo modes 00027 static const char *freevrStereoNameStr[1] = {"FreeVR"}; 00028 00030 FreeVRDisplayDevice::FreeVRDisplayDevice(void) : OpenGLRenderer("FreeVR") { 00031 stereoNames = freevrStereoNameStr; 00032 stereoModes = 1; 00033 doneGLInit = FALSE; 00034 num_display_processes = vrContext->config->num_windows; 00035 00036 // XXX migrated some initialization code into the constructor due 00037 // to the order of initialization in CAVE/FreeVR builds 00038 aaAvailable = TRUE; // enable antialiasing 00039 cueingAvailable = FALSE; // disable depth cueing 00040 cullingAvailable = FALSE; // disable culling 00041 ext->hasstereo = TRUE; // stereo is on initially 00042 ext->stereodrawforced = FALSE; // no need for force stereo draws 00043 00044 ogl_useblendedtrans = 0; 00045 ogl_transpass = 0; 00046 ogl_useglslshader = 0; 00047 ogl_acrobat3dcapture = 0; 00048 ogl_lightingenabled = 0; 00049 ogl_rendstateserial = 1; // force GLSL update on 1st pass 00050 ogl_glslserial = 0; // force GLSL update on 1st pass 00051 ogl_glsltoggle = 1; // force GLSL update on 1st pass 00052 ogl_glslmaterialindex = -1; // force GLSL update on 1st pass 00053 ogl_glslprojectionmode = DisplayDevice::PERSPECTIVE; 00054 ogl_glsltexturemode = 0; // initialize GLSL projection to off 00055 00056 00057 // leave everything else up to the freevr_gl_init_fn 00058 } 00059 00061 FreeVRDisplayDevice::~FreeVRDisplayDevice(void) { 00062 // nothing to do 00063 } 00064 00065 00067 00068 // set up the graphics on the seperate FreeVR displays 00069 void FreeVRDisplayDevice::freevr_gl_init_fn(void) { 00070 setup_initial_opengl_state(); // do all OpenGL setup/initialization now 00071 00072 // follow up with mode settings 00073 aaAvailable = TRUE; // enable antialiasing 00074 cueingAvailable = FALSE; // disable depth cueing 00075 cullingAvailable = FALSE; // disable culling 00076 ext->hasstereo = TRUE; // stereo is on initially 00077 ext->stereodrawforced = FALSE; // no need for force stereo draws 00078 00079 glClearColor(0.0, 0.0, 0.0, 0.0); // set clear color to black 00080 00081 aa_on(); // force antialiasing on if possible 00082 cueing_off(); // force depth cueing off 00083 00084 // set default settings 00085 set_sphere_mode(sphereMode); 00086 set_sphere_res(sphereRes); 00087 set_line_width(lineWidth); 00088 set_line_style(lineStyle); 00089 00090 clear(); // clear screen 00091 update(); // swap buffers 00092 00093 // we want the CAVE to be centered at the origin, and in the range -1, +1 00094 (transMat.top()).translate(0.0, 3.0, -2.0); 00095 (transMat.top()).scale(VMD_PI); 00096 00097 doneGLInit = TRUE; // only do this once 00098 } 00099 00100 void FreeVRDisplayDevice::set_stereo_mode(int) { 00101 // cannot change to stereo mode in FreeVR, it is setup at init time 00102 } 00103 00104 void FreeVRDisplayDevice::normal(void) { 00105 // prevent the OpenGLRenderer implementation of this routine 00106 // from overriding the projection matrices provided by the 00107 // FreeVR library. 00108 } 00109 00110 // special render routine to check for graphics initialization 00111 void FreeVRDisplayDevice::render(const VMDDisplayList *cmdlist) { 00112 if(!doneGLInit) { 00113 freevr_gl_init_fn(); 00114 } 00115 00116 // prepare for rendering 00117 glPushMatrix(); 00118 multmatrix((transMat.top())); // add our FreeVR adjustment transformation 00119 00120 // update the cached transformation matrices for use in text display, etc. 00121 // In FreeVR, we have to do this separately for all of the processors. 00122 // Would be nice to do this outside of the render routine however, 00123 // amortized over several Displayables. 00124 glGetFloatv(GL_PROJECTION_MATRIX, ogl_pmatrix); 00125 glGetFloatv(GL_MODELVIEW_MATRIX, ogl_mvmatrix); 00126 ogl_textMat.identity(); 00127 ogl_textMat.multmatrix(ogl_pmatrix); 00128 ogl_textMat.multmatrix(ogl_mvmatrix); 00129 00130 // call OpenGLRenderer to do the rest of the rendering the normal way 00131 OpenGLRenderer::render(cmdlist); 00132 glPopMatrix(); 00133 } 00134 00135 // update after drawing 00136 void FreeVRDisplayDevice::update(int do_update) { 00137 // XXX don't do buffer swaps in FreeVR!!! 00138 // Though not well documented, it is implicitly illegal 00139 // to call glxSwapBuffers() or to call glDrawBuffer() 00140 // in a FreeVR application, since FreeVR does this for you. 00141 } 00142
1.2.14 written by Dimitri van Heesch,
© 1997-2002