00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00035
00036
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"
00045 #include "si.h"
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
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;
00082 SiSpwEvent spwevent;
00083 SiGetEventData spwedata;
00084 #endif
00085
00086 } wgldata;
00087
00088 #else
00089
00090
00091
00092
00093
00094 #define SBALL_COMMAND_NONE 0
00095 #define SBALL_COMMAND_APP_WINDOW 27695
00096 #define SBALL_COMMAND_APP_SENSITIVITY 27696
00097
00098
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
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
00159 int have_window;
00160
00161
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
00173 OpenGLDisplayDevice();
00174
00175
00176
00177
00178 int init(int argc, char **argv, VMDApp *app, int *size, int *loc = NULL);
00179
00180 virtual ~OpenGLDisplayDevice(void);
00181
00182
00183
00184
00185
00186 virtual int x(void);
00187 virtual int y(void);
00188 virtual int shift_state(void);
00189
00190
00191
00192
00193 virtual int spaceball(int *, int *, int *, int *, int *, int *, int *);
00194
00195
00196 virtual void set_cursor(int);
00197
00198
00199
00200
00201
00202
00203
00204
00205 virtual void queue_events(void);
00206
00207
00208
00209 virtual int read_event(long &, long &);
00210
00211
00212
00213
00214
00215
00216 virtual int prepare3D(int do_clear = TRUE);
00217 virtual void update(int do_update = TRUE);
00218 virtual void reshape(void);
00219
00220
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 *);
00228 };
00229
00230 #endif
00231