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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef OpenGLRenderer_h
00037 #define OpenGLRenderer_h
00038
00039 #include <Renderer.h>
00040 #include <fstream>
00041 using std::ofstream;
00042 #include <OpenGlDevice.h>
00043
00044 #ifdef _GLX
00045 #include <GL/gl.h>
00046 #include <GL/glx.h>
00047
00048 #else
00049 #include <windows.h>
00050 #include <gl\gl.h>
00051 #include <gl\glaux.h>
00052
00053 #endif
00054
00055 #include <db.H>
00056 #include <Matrix.h>
00057 #include <Vector.h>
00058
00059 class OpenGLRenderer : public Renderer
00060 {
00061 public:
00062 OpenGLRenderer(const char *title, int xLoc, int yLoc, int width, int height,
00063 ColorMap &theMap);
00064 OpenGLRenderer(const char *title, int xLoc, int yLoc, int width, int height,
00065 ColorMap &theMap, const char *texFileName, const char *bmpFileName);
00066
00067 virtual ~OpenGLRenderer();
00068
00069 virtual int clearImage(void);
00070 virtual int saveImage(const char *imageName);
00071 virtual int startImage(void);
00072 virtual int doneImage(void);
00073
00074 virtual int drawPoint(const Vector &, float V1, int width = 1);
00075 virtual int drawPoint(const Vector &, const Vector &rgb1, int width = 1);
00076
00077 virtual int drawLine(const Vector &, const Vector &,
00078 float V1, float V2, int width = 1, int style = 1);
00079 virtual int drawLine(const Vector &end1, const Vector &end2,
00080 const Vector &rgb1, const Vector &rgb2,
00081 int width = 1, int style = 1);
00082
00083 virtual int drawPolygon(const Matrix &points, const Vector &values);
00084 virtual int drawPolygon(const Matrix &points, const Matrix &rgbValues);
00085
00086 virtual int drawText(const Vector &posGlobal, char *string, int length,
00087 char horizontalJustify = 'l', char verticalJustify = 'b');
00088
00089
00090
00091
00092
00093
00094 virtual int setVRP(float x, float y, float z);
00095 virtual int setVPN(float x, float y, float z);
00096 virtual int setVUP(float x, float y, float z);
00097
00098
00099 virtual int setViewWindow(float, float, float, float);
00100
00101
00102 virtual int setPlaneDist(float, float);
00103
00104
00105 virtual int setProjectionMode(const char *mode);
00106 virtual int setFillMode(const char *mode);
00107
00108 virtual int setPRP(float u, float v, float n);
00109
00110
00111
00112 virtual int setPortWindow(float, float, float, float);
00113
00114
00115 protected:
00116
00117 private:
00118 char *windowTitle;
00119 int height;
00120 int width;
00121 int xLoc;
00122 int yLoc;
00123
00124 int count;
00125 ofstream theFile;
00126 char *theOutputFileName;
00127
00128 OpenGlDevice *theDevice;
00129
00130
00131 Vector vrp;
00132 Vector vuv;
00133 Vector vpn;
00134 Vector cop;
00135 Matrix ViewMat;
00136
00137
00138 int projectionMode;
00139 Vector vpWindow;
00140 double clippingPlanes[2];
00141 Matrix ProjMat;
00142
00143
00144 Vector portWindow;
00145
00146 int fillMode;
00147
00148 float viewData[16];
00149 float projData[16];
00150 };
00151
00152 #endif
00153