00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2008 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.27 $ $Date: 2008/04/24 02:55:35 $ 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 // leave everything else up to the freevr_gl_init_fn 00037 } 00038 00040 FreeVRDisplayDevice::~FreeVRDisplayDevice(void) { 00041 // nothing to do 00042 } 00043 00044 00046 00047 // set up the graphics on the seperate FreeVR displays 00048 void FreeVRDisplayDevice::freevr_gl_init_fn(void) { 00049 setup_initial_opengl_state(); // do all OpenGL setup/initialization now 00050 00051 // follow up with mode settings 00052 aaAvailable = TRUE; // enable antialiasing 00053 cueingAvailable = FALSE; // disable depth cueing 00054 cullingAvailable = FALSE; // disable culling 00055 ext->hasstereo = TRUE; // stereo is on initially 00056 ext->stereodrawforced = FALSE; // no need for force stereo draws 00057 00058 glClearColor(0.0, 0.0, 0.0, 0.0); // set clear color to black 00059 00060 aa_on(); // force antialiasing on if possible 00061 cueing_off(); // force depth cueing off 00062 00063 // set default settings 00064 set_sphere_mode(sphereMode); 00065 set_sphere_res(sphereRes); 00066 set_line_width(lineWidth); 00067 set_line_style(lineStyle); 00068 00069 clear(); // clear screen 00070 update(); // swap buffers 00071 00072 // we want the CAVE to be centered at the origin, and in the range -1, +1 00073 (transMat.top()).translate(0.0, 3.0, -2.0); 00074 (transMat.top()).scale(VMD_PI); 00075 00076 doneGLInit = TRUE; // only do this once 00077 } 00078 00079 void FreeVRDisplayDevice::set_stereo_mode(int) { 00080 // cannot change to stereo mode in FreeVR, it is setup at init time 00081 } 00082 00083 void FreeVRDisplayDevice::normal(void) { 00084 // prevent the OpenGLRenderer implementation of this routine 00085 // from overriding the projection matrices provided by the 00086 // FreeVR library. 00087 } 00088 00089 // special render routine to check for graphics initialization 00090 void FreeVRDisplayDevice::render(const VMDDisplayList *cmdlist) { 00091 if(!doneGLInit) { 00092 freevr_gl_init_fn(); 00093 } 00094 00095 // prepare for rendering 00096 glPushMatrix(); 00097 multmatrix((transMat.top())); // add our FreeVR adjustment transformation 00098 00099 // update the cached transformation matrices for use in text display, etc. 00100 // In FreeVR, we have to do this separately for all of the processors. 00101 // Would be nice to do this outside of the render routine however, 00102 // amortized over several Displayables. 00103 glGetFloatv(GL_PROJECTION_MATRIX, ogl_pmatrix); 00104 glGetFloatv(GL_MODELVIEW_MATRIX, ogl_mvmatrix); 00105 ogl_textMat.identity(); 00106 ogl_textMat.multmatrix(ogl_pmatrix); 00107 ogl_textMat.multmatrix(ogl_mvmatrix); 00108 00109 // call OpenGLRenderer to do the rest of the rendering the normal way 00110 OpenGLRenderer::render(cmdlist); 00111 glPopMatrix(); 00112 } 00113 00114 // update after drawing 00115 void FreeVRDisplayDevice::update(int do_update) { 00116 // XXX don't do buffer swaps in FreeVR!!! 00117 // Though not well documented, it is implicitly illegal 00118 // to call glxSwapBuffers() or to call glDrawBuffer() 00119 // in a FreeVR application, since FreeVR does this for you. 00120 } 00121
1.2.14 written by Dimitri van Heesch,
© 1997-2002