Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

OpenGLDisplayDevice.h

Go to the documentation of this file.
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: OpenGLDisplayDevice.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.48 $       $Date: 2008/06/03 20:25:08 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * Subclass of OpenGLRenderer, this object has routines used by all the
00020  * different display devices that are OpenGL-specific.  Will render drawing
00021  * commands into a single X window.
00022  *
00023  ***************************************************************************/
00024 #ifndef OPENGLDISPLAYDEVICE_H
00025 #define OPENGLDISPLAYDEVICE_H
00026 
00027 #include "OpenGLRenderer.h"
00028 
00029 class VMDApp;
00030 
00031 #if !defined(_MSC_VER) && !(defined(VMDSDL) && defined(__APPLE__))
00032 #include <GL/glx.h>
00033 
00034 // NOTE: you may have to get copies of the latest OpenGL extension headers
00035 // from the OpenGL web site if your Linux machine lacks them:
00036 //   http://oss.sgi.com/projects/ogl-sample/registry/
00037 #if defined(ARCH_LINUX) && !defined(VMDMESA)
00038 #include <GL/glxext.h>
00039 #endif
00040 #endif
00041 
00042 #if defined(VMDSPACEWARE) && defined(WIN32)
00043 #define OS_WIN32 1
00044 #include "spwmacro.h"           // Spaceware include files
00045 #include "si.h"                 // Spaceware include files
00046 #endif
00047 
00048 #if defined(VMDSDL) 
00049 
00051 typedef struct {
00052   int windowID;
00053 } sdldata;
00054 
00055 #else
00056 #if defined(_MSC_VER)
00057 
00059 typedef struct {
00060   HWND hWnd;
00061   HDC hDC;
00062   HGLRC hRC;
00063   long scrwidth;
00064   long scrheight;
00065   int width;
00066   int height;
00067 
00068   // internal state variables we need to track
00069   int cursornum;
00070   long MouseX;
00071   long MouseY;
00072   long MouseFlags;
00073   int  WEvents;
00074   char KeyFlag;
00075   int  PFDisStereo;
00076 
00077 #ifdef VMDSPACEWARE
00078   SiHdl sball;             // Spaceware handle
00079   SiSpwEvent spwevent;     // Spaceware event
00080   SiGetEventData spwedata; // Spaceware event data
00081 #endif
00082 
00083 } wgldata;
00084 
00085 #else
00086 
00087 #define SBALL_COMMAND_NONE                0
00088 #define SBALL_COMMAND_APP_WINDOW      27695
00089 #define SBALL_COMMAND_APP_SENSITIVITY 27696
00090 
00091 // Xlib ClientMessage-based Spaceball/Magellan handle data
00092 typedef struct {
00093   Display *dpy;
00094   Window drv_win;
00095   Window app_win;
00096   Atom ev_motion;
00097   Atom ev_button_press;
00098   Atom ev_button_release;
00099   Atom ev_command;
00100 } spaceballhandle;
00101 
00102 // Spaceball event data
00103 typedef struct {
00104   int event;
00105   int rx;
00106   int ry;
00107   int rz;
00108   int tx;
00109   int ty; 
00110   int tz;
00111   int buttons;
00112   int period;
00113 } spaceballevent;
00114 
00116 typedef struct {
00117   Display *dpy;              
00118   int dpyScreen;             
00119   Window rootWindowID;       
00120 
00121   Window windowID;           
00122   XSizeHints sizeHints;      
00123   Cursor cursor[5];          
00124   GLXContext cx;             
00125   int havefocus;             
00126 
00127   void *xinp;                
00128 
00129   spaceballhandle *sball;    
00130   spaceballevent sballevent; 
00131 
00132 } glxdata;
00133 #endif
00134 #endif
00135 
00136 
00140 class OpenGLDisplayDevice : public OpenGLRenderer {
00141 public:
00142   VMDApp *vmdapp; // cached VMDApp pointer for use by drag-and-drop handlers
00143 
00144 #if defined(VMDSDL)
00145   sdldata sdlsrv;
00146 #else
00147 #if defined(_MSC_VER)
00148   wgldata glwsrv;
00149 #else
00150   glxdata glxsrv;
00151 #endif
00152 #endif
00153 
00154 protected:
00155   // flag for whether a window was successfully created by open_window
00156   int have_window;
00157 
00158   // create a new window and set it's characteristics
00159 #if defined(VMDSDL)
00160   int open_window(char *, int *, int *, int, char **);
00161 #else
00162 #if defined(_MSC_VER)
00163   int open_window(char *, int *, int *, int, char **);
00164 #else
00165   Window open_window(char *, int *, int *, int, char **);
00166 #endif
00167 #endif
00168 
00169   virtual void do_resize_window(int, int);
00170   virtual void do_reposition_window(int, int);
00171 
00172 public:
00173   // constructor - trivial variable initialization, no window opened yet.
00174   OpenGLDisplayDevice();
00175 
00176   // real initialization; return TRUE if the window was successfully opened
00177   // or FALSE if it wasn't.  Pass argc/argv from main, and size and location
00178   // for the window, if known.  size must NOT be NULL.
00179   int init(int argc, char **argv, VMDApp *app, int *size, int *loc = NULL);
00180 
00181   virtual ~OpenGLDisplayDevice(void);
00182 
00183   //
00184   // get the current state of the device's pointer (i.e. cursor if it has one)
00185   //
00186 
00187   virtual int x(void);          // abs pos of cursor from lower-left corner
00188   virtual int y(void);          // same, for y direction
00189   virtual int shift_state(void);// return the shift state (ORed of the
00190                                 // enum in DisplayDevice)
00191 
00192   // get the current state of the Spaceball if one is available
00193   // returns rx ry rz, tx ty tz, buttons
00194   virtual int spaceball(int *, int *, int *, int *, int *, int *, int *);
00195 
00196   // set the Nth cursor shape as the current one.
00197   virtual void set_cursor(int);
00198 
00199   //
00200   // event handling routines
00201   //
00202 
00203   // queue the standard events (need only be called once ... but this is
00204   // not done automatically by the window because it may not be necessary or
00205   // even wanted)
00206   virtual void queue_events(void);
00207 
00208   // read the next event ... returns an event type (one of the above ones),
00209   // and a value.  Returns success, and sets arguments.
00210   virtual int read_event(long &, long &);
00211 
00212   //
00213   // virtual routines for preparing to draw, drawing, and finishing drawing
00214   //
00215   virtual void update(int do_update = TRUE);    // finish up after drawing
00216   virtual void reshape(void);                   // refresh device after change
00217 
00218   // virtual routine for capturing the screen to a packed RGB array
00219   virtual unsigned char * readpixels(int &x, int &y);
00220 };
00221 
00222 #endif
00223 

Generated on Mon Oct 6 01:26:23 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002