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

OpenGLPbufferDisplayDevice.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: OpenGLPbufferDisplayDevice.h,v $
00012  *      $Author: johns $        $Locker:  $             $State: Exp $
00013  *      $Revision: 1.12 $       $Date: 2020/02/26 06:00:57 $
00014  *
00015  ***************************************************************************/
00027 #ifndef OPENGLPBUFFERDISPLAYDEVICE_H
00028 #define OPENGLPBUFFERDISPLAYDEVICE_H
00029 
00030 #include "OpenGLRenderer.h"
00031 
00032 #if defined(VMDEGLPBUFFER) && defined(VMDGLXPBUFFER)
00033 #error Cannot enable both EGL and GLX Pbuffer code at the same time (yet)
00034 #endif
00035 
00036 class VMDApp;
00037 
00038 //
00039 // EGL Pbuffer support
00040 //
00041 #if defined(VMDEGLPBUFFER)
00042 #include <EGL/egl.h>
00043 #include <EGL/eglext.h>
00044 
00046 typedef struct {
00047   EGLDisplay dpy;            
00048   EGLConfig  conf;           
00049   EGLSurface surf;           
00050   EGLContext ctx;            
00051   EGLint numdevices;         
00052   EGLint devindex;           
00053 } eglpbufferdata;
00054 #endif
00055 
00056 
00057 //
00058 // GLX Pbuffer support
00059 //
00060 #if defined(VMDGLXPBUFFER)
00061 #if !defined(_MSC_VER) && !(defined(VMDSDL) && defined(__APPLE__))
00062 #include <GL/glx.h>
00063 
00064 // NOTE: you may have to get copies of the latest OpenGL extension headers
00065 // from the OpenGL web site if your Linux machine lacks them:
00066 //   http://oss.sgi.com/projects/ogl-sample/registry/
00067 #if defined(ARCH_LINUX) && !defined(VMDMESA)
00068 #include <GL/glxext.h>
00069 #endif
00070 #endif
00071 
00073 typedef struct {
00074   Display *dpy;              
00075   int dpyScreen;             
00076   Window rootWindowID;       
00077   Window windowID;           
00078   GLXContext cx;             
00079 } glxpbufferdata;
00080 #endif
00081 
00082 
00086 class OpenGLPbufferDisplayDevice : public OpenGLRenderer {
00087 private:
00088   unsigned int PbufferMaxXsz; 
00089   unsigned int PbufferMaxYsz; 
00090 
00091 public:
00092 #if defined(VMDEGLPBUFFER)
00093   eglpbufferdata eglsrv;
00094 #endif
00095 #if defined(VMDGLXPBUFFER)
00096   glxpbufferdata glxsrv;
00097 #endif
00098 
00099 protected:
00100   // flag for whether a window was successfully created by open_window
00101   int have_window;
00102 
00103   // create a new window and set it's characteristics
00104 #if defined(VMDGLXPBUFFER)
00105   int glx_open_window(char *, int *, int *, int, char **);
00106 #endif
00107 #if defined(VMDEGLPBUFFER)
00108   int egl_open_window(char *, int *, int *, int, char **);
00109 #endif
00110 
00111   virtual void do_resize_window(int, int);
00112   virtual void do_reposition_window(int, int) {};
00113 
00114 public:
00115   // constructor - trivial variable initialization, no window opened yet.
00116   OpenGLPbufferDisplayDevice();
00117 
00118   // real initialization; return TRUE if the window was successfully opened
00119   // or FALSE if it wasn't.  Pass argc/argv from main, and size and location
00120   // for the window, if known.  size must NOT be NULL.
00121   int init(int argc, char **argv, VMDApp *app, int *size, int *loc = NULL);
00122 
00123   virtual ~OpenGLPbufferDisplayDevice(void);
00124 
00125   // All display device subclasses from OpenGLRenderer (except OpenGLPbuffer)
00126   // support GUI's.
00127   virtual int supports_gui() { return FALSE; }
00128 
00129   //
00130   // get the current state of the device's pointer (i.e. cursor if it has one)
00131   //
00132 
00133   virtual int x(void) { return 0; } // abs pos of cursor from lower-left corner
00134   virtual int y(void) { return 0; } // same, for y direction
00135 
00136   // return the shift state (ORed of the enum in DisplayDevice)
00137   virtual int shift_state(void) { return 0; }
00138 
00139   // get the current state of the Spaceball if one is available
00140   // returns rx ry rz, tx ty tz, buttons
00141   virtual int spaceball(int *, int *, int *, int *, int *, int *, int *) {
00142     return 0;
00143   }
00144 
00145   // set the Nth cursor shape as the current one.
00146   virtual void set_cursor(int) {} 
00147 
00148   //
00149   // event handling routines
00150   //
00151 
00152   // queue the standard events (need only be called once ... but this is
00153   // not done automatically by the window because it may not be necessary or
00154   // even wanted)
00155   virtual void queue_events(void) {}
00156 
00157   // read the next event ... returns an event type (one of the above ones),
00158   // and a value.  Returns success, and sets arguments.
00159   virtual int read_event(long &retdev, long &retval) {
00160     retdev = WIN_NOEVENT;
00161     retval = 0;
00162     return (retdev != WIN_NOEVENT);
00163   }
00164 
00165   //
00166   // virtual routines for preparing to draw, drawing, and finishing drawing
00167   //
00168   virtual void update(int do_update = TRUE);    // finish up after drawing
00169   virtual void reshape(void);                   // refresh device after change
00170 
00171   // virtual routine for capturing the screen to a packed RGB array
00172   virtual unsigned char * readpixels_rgb3u(int &x, int &y);
00173   virtual unsigned char * readpixels_rgba4u(int &x, int &y);
00174 };
00175 
00176 #endif
00177 

Generated on Thu Apr 18 02:45:00 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002