00001 00008 #ifndef TRANSFERTEXTURE_H 00009 #define TRANSFERTEXTURE_H 00010 00011 #include <gl/glew.h> 00012 #include <string> 00013 #include <vector> 00014 #include "Color4.h" 00015 00020 struct PlotPoint 00021 { 00022 float value; 00023 unsigned char dataValue; 00024 }; 00025 00031 class TransferTexture 00032 { 00033 public: 00034 00038 TransferTexture(); 00039 00043 ~TransferTexture(); 00044 00052 bool Load(const char *name); 00053 00058 struct ControlPoint 00059 { 00060 Color4f color; 00061 int value; 00062 }; 00063 00078 bool CreateFunction(const std::vector<PlotPoint> &red, 00079 const std::vector<PlotPoint> &green, 00080 const std::vector<PlotPoint> &blue, 00081 const std::vector<PlotPoint> &alpha); 00082 00091 void Bind(int unit = 0); 00092 00096 void UnBind(); 00097 00101 GLuint GetTextureID() const { return tex; } 00102 00103 protected: 00104 00118 bool Interpolate(const std::vector<PlotPoint> &plot, float *color, int stride); 00119 00120 GLuint tex; 00121 int boundUnit; 00122 }; 00123 00124 #endif