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

OpenGLDisplayDevice.h

Go to the documentation of this file.
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  * RCS INFORMATION:
00010  *
00011  *      $RCSfile: OpenGLDisplayDevice.h,v $
00012  *      $Author: johns $        $Locker:  $             $State: Exp $
00013  *      $Revision: 1.61 $       $Date: 2021/05/14 22:27:22 $
00014  *
00015  ***************************************************************************/
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 
00053 typedef struct {
00054   int windowID;
00055 } sdldata;
00056 
00057 #elif defined(_MSC_VER)
00058 
00062 typedef struct {
00063   HWND hWnd;
00064   HDC hDC;
00065   HGLRC hRC;
00066   long scrwidth;
00067   long scrheight;
00068   int width;
00069   int height;
00070 
00071   // internal state variables we need to track
00072   int cursornum;
00073   long MouseX;
00074   long MouseY;
00075   long MouseFlags;
00076   int  WEvents;
00077   char KeyFlag;
00078   int  PFDisStereo;
00079 
00080 #ifdef VMDSPACEWARE
00081   SiHdl sball;             // Spaceware handle
00082   SiSpwEvent spwevent;     // Spaceware event
00083   SiGetEventData spwedata; // Spaceware event data
00084 #endif
00085 
00086 } wgldata;
00087 
00088 #else
00089 
00090 //
00091 // X-windows 
00092 //
00093 
00094 #define SBALL_COMMAND_NONE                0
00095 #define SBALL_COMMAND_APP_WINDOW      27695
00096 #define SBALL_COMMAND_APP_SENSITIVITY 27696
00097 
00098 // Xlib ClientMessage-based Spaceball/Magellan handle data
00099 typedef struct {
00100   Display *dpy;
00101   Window drv_win;
00102   Window app_win;
00103   Atom ev_motion;
00104   Atom ev_button_press;
00105   Atom ev_button_release;
00106   Atom ev_command;
00107 } spaceballhandle;
00108 
00109 // Spaceball event data
00110 typedef struct {
00111   int event;
00112   int rx;
00113   int ry;
00114   int rz;
00115   int tx;
00116   int ty; 
00117   int tz;
00118   int buttons;
00119   int period;
00120 } spaceballevent;
00121 
00123 typedef struct {
00124   Display *dpy;              
00125   int dpyScreen;             
00126   Window rootWindowID;       
00127 
00128   Window windowID;           
00129   XSizeHints sizeHints;      
00130   Cursor cursor[5];          
00131   GLXContext cx;             
00132   int havefocus;             
00133 
00134   void *xinp;                
00135 
00136   spaceballhandle *sball;    
00137   spaceballevent sballevent; 
00138 
00139 } glxdata;
00140 
00141 #endif
00142 
00143 
00147 class OpenGLDisplayDevice : public OpenGLRenderer {
00148 public:
00149 #if defined(VMDSDL)
00150   sdldata sdlsrv;
00151 #elif defined(_MSC_VER)
00152   wgldata glwsrv;
00153 #else
00154   glxdata glxsrv;
00155 #endif
00156 
00157 protected:
00158   // flag for whether a window was successfully created by open_window
00159   int have_window;
00160 
00161   // create a new window and set it's characteristics
00162 #if defined(VMDSDL) || 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 
00168   virtual void do_resize_window(int, int);
00169   virtual void do_reposition_window(int, int);
00170 
00171 public:
00172   // constructor - trivial variable initialization, no window opened yet.
00173   OpenGLDisplayDevice();
00174 
00175   // real initialization; return TRUE if the window was successfully opened
00176   // or FALSE if it wasn't.  Pass argc/argv from main, and size and location
00177   // for the window, if known.  size must NOT be NULL.
00178   int init(int argc, char **argv, VMDApp *app, int *size, int *loc = NULL);
00179 
00180   virtual ~OpenGLDisplayDevice(void);
00181 
00182   //
00183   // get the current state of the device's pointer (i.e. cursor if it has one)
00184   //
00185 
00186   virtual int x(void);           // abs pos of cursor from lower-left corner
00187   virtual int y(void);           // same, for y direction
00188   virtual int shift_state(void); // return the shift state (ORed of the
00189                                  // enum in DisplayDevice)
00190 
00191   // get the current state of the Spaceball if one is available
00192   // returns rx ry rz, tx ty tz, buttons
00193   virtual int spaceball(int *, int *, int *, int *, int *, int *, int *);
00194 
00195   // set the Nth cursor shape as the current one.
00196   virtual void set_cursor(int);
00197 
00198   //
00199   // event handling routines
00200   //
00201 
00202   // queue the standard events (need only be called once ... but this is
00203   // not done automatically by the window because it may not be necessary or
00204   // even wanted)
00205   virtual void queue_events(void);
00206 
00207   // read the next event ... returns an event type (one of the above ones),
00208   // and a value.  Returns success, and sets arguments.
00209   virtual int read_event(long &, long &);
00210 
00211   //
00212   // virtual routines for preparing to draw, drawing, and finishing drawing
00213   //
00214 
00215   // process draw cmd list but force-restore our GLX context first
00216   virtual int prepare3D(int do_clear = TRUE); 
00217   virtual void update(int do_update = TRUE);  // finish up after drawing
00218   virtual void reshape(void);                 // refresh device after change
00219 
00220   // virtual routine for capturing the screen to a packed RGB array
00221   virtual unsigned char * readpixels_rgb3u(int &x, int &y);
00222   virtual unsigned char * readpixels_rgba4u(int &x, int &y);
00223 
00225   virtual int drawpixels_rgba4u(unsigned char *rgba, int &x, int &y);
00226 
00227   virtual void set_window_title(char *);           // set window title bar str
00228 };
00229 
00230 #endif
00231 

Generated on Fri Oct 4 02:44:24 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002