00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2019 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: CaveDisplayDevice.C,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.49 $ $Date: 2019/01/17 21:20:58 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * 00019 * a CAVE specific display device for VMD 00020 ***************************************************************************/ 00021 00022 #include "CaveDisplayDevice.h" 00023 #include "Inform.h" 00024 #include <cave_ogl.h> // include cave library access 00025 00026 // static string storage used for returning stereo modes 00027 static const char *caveStereoNameStr[1] = {"Cave"}; 00028 00030 CaveDisplayDevice::CaveDisplayDevice(void) : OpenGLRenderer("Cave") { 00031 stereoNames = caveStereoNameStr; 00032 stereoModes = 1; 00033 doneGLInit = FALSE; 00034 num_display_processes = CAVEConfig->ActiveWalls; 00035 // XXX need to test this still 00036 // ext->hasstereo = CAVEInStereo(); // stereo available 00037 00038 // leave everything else up to the cave_gl_init_fn 00039 } 00040 00042 CaveDisplayDevice::~CaveDisplayDevice(void) { 00043 // nothing to do 00044 } 00045 00046 00048 00049 // set up the graphics on the seperate CAVE displays 00050 void CaveDisplayDevice::cave_gl_init_fn(void) { 00051 setup_initial_opengl_state(); // do all OpenGL setup/initialization now 00052 00053 // follow up with mode settings 00054 aaAvailable = TRUE; // enable antialiasing 00055 cueingAvailable = FALSE; // disable depth cueing 00056 cullingAvailable = FALSE; // disable culling 00057 // XXX need to test this still 00058 // ext->hasstereo = CAVEInStereo(); // stereo availability test 00059 ext->hasstereo = TRUE; // stereo is on initially 00060 ext->stereodrawforced = FALSE; // no need for forced stereo draws 00061 00062 glClearColor(0.0, 0.0, 0.0, 0.0); // set clear color to black 00063 00064 aa_on(); // force antialiasing on if possible 00065 cueing_off(); // force depth cueing off 00066 00067 // set default settings 00068 set_sphere_mode(sphereMode); 00069 set_sphere_res(sphereRes); 00070 set_line_width(lineWidth); 00071 set_line_style(lineStyle); 00072 00073 clear(); // clear screen 00074 update(); // swap buffers 00075 00076 // we want the CAVE to be centered at the origin, and in the range -1, +1 00077 (transMat.top()).translate(0.0, 3.0, -2.0); 00078 (transMat.top()).scale(VMD_PI); 00079 00080 doneGLInit = TRUE; // only do this once 00081 } 00082 00083 void CaveDisplayDevice::set_stereo_mode(int) { 00084 // cannot change to stereo mode in the CAVE, it is setup at init time 00085 } 00086 00087 void CaveDisplayDevice::normal(void) { 00088 // prevent the OpenGLRenderer implementation of this routine 00089 // from overriding the projection matrices provided by the 00090 // CAVE library. 00091 } 00092 00093 // special render routine to check for graphics initialization 00094 void CaveDisplayDevice::render(const VMDDisplayList *cmdlist) { 00095 if(!doneGLInit) { 00096 cave_gl_init_fn(); 00097 } 00098 00099 // prepare for rendering 00100 glPushMatrix(); 00101 multmatrix((transMat.top())); // add our CAVE adjustment transformation 00102 00103 // update the cached transformation matrices for use in text display, etc. 00104 // In the CAVE, we have to do this separately for all of the processors. 00105 // Would be nice to do this outside of the render routine however, 00106 // amortized over several Displayables. 00107 glGetFloatv(GL_PROJECTION_MATRIX, ogl_pmatrix); 00108 glGetFloatv(GL_MODELVIEW_MATRIX, ogl_mvmatrix); 00109 ogl_textMat.identity(); 00110 ogl_textMat.multmatrix(ogl_pmatrix); 00111 ogl_textMat.multmatrix(ogl_mvmatrix); 00112 00113 // call OpenGLRenderer to do the rest of the rendering the normal way 00114 OpenGLRenderer::render(cmdlist); 00115 glPopMatrix(); 00116 } 00117 00118 // update after drawing 00119 void CaveDisplayDevice::update(int do_update) { 00120 // XXX don't do buffer swaps in the CAVE!!! 00121 // Though not well documented, it is implicitly illegal 00122 // to call glxSwapBuffers() or to call glDrawBuffer() 00123 // in a CAVE application, since CAVElib does this for you. 00124 } 00125