00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00061 virtual int GetWidth();
00062
00063
00064 virtual int GetHeight();
00065
00066
00067
00068 virtual void STARTIMAGE();
00069 virtual void ENDIMAGE();
00070
00071
00072 virtual void WINOPEN(const char *title, int xLoc, int yLoc, int width, int height);
00073
00074
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
00081 int saveImage(const char *fileName, int type);
00082
00083 private:
00084 void initWindow(void);
00085
00086
00087 int saveImageAsBMP(const char *fileName);
00088 int saveImageAsPNG(const char *fileName);
00089
00090 #ifdef _GLX
00091
00092
00093 Display *theDisplay;
00094 Window theWindow;
00095 int theScreen;
00096 Colormap cmap;
00097 GC theGC;
00098 GLXContext cx;
00099 XSizeHints hints;
00100
00101 XEvent theEvent;
00102 XVisualInfo *visual;
00103 int swap_flag;
00104
00105
00106 XFontStruct *fontInfo;
00107
00108 #elif _WGL
00109
00110
00111 HDC theHDC;
00112 HGLRC theHRC;
00113 HWND theWND;
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
00126 GLuint FontBase;
00127
00128 static int numWindows;
00129 int winOpen;
00130 int width, height;
00131 char *windowTitle;
00132 };
00133
00134 #endif
00135
00136
00137
00138