OpenGLRenderer.h

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.9 $
00022 // $Date: 2004/06/07 23:09:32 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/renderer/OpenGLRenderer.h,v $
00024                                                                         
00025                                                                         
00026 // Written: fmk 
00027 // Created: 10/98
00028 // Revision: A
00029 //
00030 // Description: This file contains the class definition for OpenGLRenderer.
00031 // OpenGLRenderer is an abstract base class. An OpenGLRenderer object is used
00032 // to create an image of the domain.
00033 //
00034 // What: "@(#) OpenGLRenderer.h, revA"
00035 
00036 #ifndef OpenGLRenderer_h
00037 #define OpenGLRenderer_h
00038 
00039 #include <Renderer.h>
00040 #include <fstream>
00041 using std::ofstream;
00042 #include <OpenGlDevice.h>
00043 
00044 #ifdef _GLX
00045 #include <GL/gl.h>
00046 #include <GL/glx.h>
00047 
00048 #else 
00049 #include <windows.h>
00050 #include <gl\gl.h>
00051 #include <gl\glaux.h>
00052 // include open gl stuff for win32
00053 #endif
00054 
00055 #include <db.H>
00056 #include <Matrix.h>
00057 #include <Vector.h>
00058 
00059 class OpenGLRenderer : public Renderer
00060 {
00061  public:
00062     OpenGLRenderer(const char *title, int xLoc, int yLoc, int width, int height,
00063                    ColorMap &theMap);
00064     OpenGLRenderer(const char *title, int xLoc, int yLoc, int width, int height,
00065                    ColorMap &theMap, const char *texFileName, const char *bmpFileName); 
00066 
00067     virtual ~OpenGLRenderer();
00068 
00069     virtual int clearImage(void);    
00070     virtual int saveImage(const char *imageName);    
00071     virtual int startImage(void);
00072     virtual int doneImage(void);
00073 
00074     virtual int drawPoint(const Vector &, float V1, int width = 1);
00075     virtual int drawPoint(const Vector &, const Vector &rgb1, int width = 1);    
00076 
00077     virtual int drawLine(const Vector &, const Vector &, 
00078                          float V1, float V2, int width = 1, int style = 1);
00079     virtual int drawLine(const Vector &end1, const Vector &end2, 
00080                          const Vector &rgb1, const Vector &rgb2,
00081                          int width = 1, int style = 1);
00082    
00083     virtual int drawPolygon(const Matrix &points, const Vector &values);
00084     virtual int drawPolygon(const Matrix &points, const Matrix &rgbValues);
00085 
00086     virtual int drawText(const Vector &posGlobal, char *string, int length, 
00087                          char horizontalJustify = 'l', char verticalJustify = 'b');    
00088 
00089     //
00090     // the following are for setting up the vieing system
00091     //
00092 
00093     // the following are in world coordinates & define view coord system
00094     virtual int setVRP(float x, float y, float z); // point on view plane    
00095     virtual int setVPN(float x, float y, float z); // view plane normal
00096     virtual int setVUP(float x, float y, float z); // view-up vector
00097         
00098     // the following are in view coordinates    
00099     virtual int setViewWindow(float, float, float, float); // view bounds
00100                                // umin, umax, vmin, vmax
00101 
00102     virtual int setPlaneDist(float, float); // location of
00103                                // near and far clipping planes
00104 
00105     virtual int setProjectionMode(const char *mode); // parallel or perspective
00106     virtual int setFillMode(const char *mode);    // wire or  fill
00107     
00108     virtual int setPRP(float u, float v, float n); // eye location if 
00109                                  // perspective, dirn to +ViewPlane if parallel
00110 
00111     // the following are in normalized coordinates
00112     virtual int setPortWindow(float, float, float, float); // view port
00113                               // left, right, bottom, top [-1,1,-1,1]
00114                                   
00115  protected:
00116 
00117  private:
00118     char *windowTitle; // title name of the window
00119     int height;        // current height of window in pixels
00120     int width;         // current width of window in pixels
00121     int xLoc;          // upper xLocation of window
00122     int yLoc;          // upper yLocation of window
00123 
00124     int count;                 // number of times done image has been invoked
00125     ofstream theFile;          // output stream if saving drawing commands
00126     char *theOutputFileName;   // file name for output stream
00127 
00128     OpenGlDevice *theDevice;
00129 
00130     // viewing 
00131     Vector vrp;  // point on the view plane - global coords
00132     Vector vuv;  // vector defining the view up vector, 
00133     Vector vpn;  // vector defining the view plane normal
00134     Vector cop;  // eye location - NOW IN GLOBAL COORDINATES
00135     Matrix ViewMat;
00136 
00137     // projection
00138     int projectionMode;        // flag indicating projection mode
00139     Vector vpWindow;           // view window bounds - local window coordinates (u,v)
00140     double clippingPlanes[2];  // distance to front and back clipping planes FROM THE PLANE (n)
00141     Matrix ProjMat;         
00142 
00143     // viewport
00144     Vector portWindow;  // mapping to window - port window coords [-1,-1] to [1,1]
00145 
00146     int fillMode;        // flag indicating fill mode
00147 
00148     float viewData[16];
00149     float projData[16];
00150 };
00151 
00152 #endif
00153 

Generated on Mon Oct 23 15:05:27 2006 for OpenSees by doxygen 1.5.0