00001 #ifndef RENDERER_H 00002 #define RENDERER_H 00003 00004 #include <GL/freeglut.h> 00005 00006 #include "Volume.h" 00007 00008 #include <string> 00009 #include <vector> 00010 00014 class Renderer 00015 { 00016 public: 00020 struct TFPoint 00021 { 00022 unsigned int pos; 00023 unsigned char r; 00024 unsigned char g; 00025 unsigned char b; 00026 unsigned char a; 00027 }; 00028 00032 struct TransferFunction 00033 { 00034 GLuint texID; 00035 unsigned int width; 00036 std::vector<TFPoint> points; 00037 00038 unsigned char* data; 00039 00040 TransferFunction() 00041 { 00042 this->width = 0; 00043 this->texID = 0; 00044 this->data = 0; 00045 //this->points = new std::vector<TFPoint>(); 00046 } 00047 }; 00048 00050 Renderer(); 00051 ~Renderer(); 00052 00054 bool loadVolume(const std::string&); 00055 00057 void setTransferFunction(TransferFunction&); 00058 00060 void setAnimate(bool); 00062 void switchRenderMode(int); 00063 00065 void switchAxis(int); 00067 void setAxisCoord(float); 00068 00070 void initGL(); 00072 void resizeGL(int, int); 00074 void paintGL(); 00075 00077 void animate(); 00078 00080 void setSampleDist(float); 00081 00083 void setUseTf(bool); 00084 00085 private: 00087 Volume* volume; 00088 00090 bool animationFlag; 00092 int renderMode; 00093 00095 float rotationAngles[3]; 00096 00098 int axisIndex; 00100 float axisCoord; 00102 bool increaseSlice; 00103 00105 float sampleDist; 00106 00108 bool useTransferfunction; 00109 00111 double loopFactor; 00112 00114 GLuint width; 00116 GLuint height; 00117 00119 GLuint transferTexture; 00121 GLuint volumeTexture; 00123 GLuint frontTexture; 00125 GLuint backTexture; 00127 GLuint frontFBO; 00129 GLuint backFBO; 00130 00132 GLuint slicingProgram; 00134 GLuint volumeProgram; 00135 00136 GLuint slicingProgramMit; 00137 GLuint volumeProgramMit; 00138 00140 GLint volumeSlicingTextureLocation; 00142 GLint volumeSlicingTransferLocation; 00143 00145 GLint transferTextureLocation; 00147 GLint volumeTextureLocation; 00149 GLint frontTextureLocation; 00151 GLint backTextureLocation; 00153 GLint lightVecLocation; 00155 GLint sampleDistLocation; 00156 00158 GLint volumeSlicingTextureLocationMit; 00160 GLint transferTextureLocationMit; 00161 00163 GLint volumeTextureLocationMit; 00165 GLint frontTextureLocationMit; 00167 GLint backTextureLocationMit; 00169 GLint sampleDistLocationMit; 00170 00172 void createFBO(GLuint*, GLuint*); 00173 00175 void renderVolumeBox(); 00176 00178 void renderSlicing(); 00180 void renderVolume(); 00181 00183 void animateSlicing(); 00185 void animateVolume(); 00186 00188 void checkGLFeatures(); 00189 00191 static GLuint createProgram(const std::string&, const std::string&); 00193 static GLint queryUniformLoc(GLint, const GLchar*); 00195 static bool readShaderSource(const std::string&, std::string&); 00196 00197 }; 00198 00199 #endif