OpenGlDevice.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.7 $
00022 // $Date: 2004/06/07 23:09:32 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/renderer/OpenGlDevice.h,v $
00024                                                                         
00025                                                                         
00026 #ifndef OpenGlDevice_H
00027 #define OpenGlDevice_H
00028 
00029 #include <Device.h>
00030 
00031 #ifdef _GLX
00032 
00033 #include <GL/gl.h>
00034 #include <GL/glx.h>
00035 
00036 #include <X11/Xlib.h>
00037 #include <X11/X.h>
00038 #include <X11/Xutil.h>
00039 #include <X11/X.h>
00040 #include <X11/Xatom.h>
00041 
00042 #define X11_MAX_COLORS 256
00043 
00044 #elif _WGL
00045 
00046 #include <windows.h>
00047 #include <gl\gl.h>
00048 #include <gl\glaux.h>
00049 
00050 #else
00051 
00052 #endif
00053 
00054 class OpenGlDevice
00055 {
00056  public:
00057   OpenGlDevice();
00058   virtual ~OpenGlDevice();  
00059 
00060   // Gets the width of the current window
00061   virtual int GetWidth();
00062 
00063   // Gets the height of the current window
00064   virtual int GetHeight();
00065 
00066   // Necessary when operating since the drawn
00067   // image is buffered until this call is made.
00068   virtual void STARTIMAGE();
00069   virtual void ENDIMAGE();
00070 
00071   // Opens a window of the specified width & height.
00072   virtual void WINOPEN(const char *title, int xLoc, int yLoc, int width, int height);
00073 
00074   // Clears the currently opened window
00075   virtual void CLEAR();
00076 
00077   virtual void drawText(float x, float y, float z, char *text, int length, 
00078                         char horizontalJustify, char verticalJustify); 
00079 
00080   // to save the current image to a file of a specific type
00081   int saveImage(const char *fileName, int type);  
00082 
00083  private:
00084   void initWindow(void); // procedure called on construction of 1st Window
00085   
00086   // save image methods for specific file formats
00087   int saveImageAsBMP(const char *fileName);  
00088   int saveImageAsPNG(const char *fileName);  
00089 
00090 #ifdef _GLX
00091 
00092   // glx utility toolkit
00093   Display *theDisplay;  // the display all Window objecs display on
00094   Window theWindow;
00095   int theScreen;        // the screen 
00096   Colormap cmap;        // the colormap all X11 Window objects share   
00097   GC theGC;
00098   GLXContext cx;    
00099   XSizeHints hints; // conatins the infor about where window is and its size
00100                     //  static unsigned long foreground, background;
00101   XEvent theEvent;
00102   XVisualInfo *visual;
00103   int swap_flag;
00104 
00105   //  static XFontStruct *fontInfo;
00106   XFontStruct *fontInfo;
00107 
00108 #elif _WGL
00109 
00110   // win32 stuff using wgl toolkit
00111   HDC         theHDC;        // device context
00112   HGLRC       theHRC;        // openGL context
00113   HWND        theWND;        // the window
00114   BITMAPINFO  info;
00115   HBITMAP     theBitmap;
00116   GLint       viewport[4];
00117   GLubyte     *bits;
00118   long        currentBitSize;
00119   int xLoc;
00120   int yLoc;
00121 #else
00122 
00123 #endif
00124 
00125   //  static GLuint FontBase;
00126   GLuint FontBase;
00127 
00128   static int numWindows;
00129   int winOpen;
00130   int width, height;            // Width and height of our window
00131   char *windowTitle;
00132 };
00133 
00134 #endif
00135 
00136 
00137 
00138   

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