00001
00008 #ifndef VOLUMETEXTURE_H
00009 #define VOLUMETEXTURE_H
00010
00011 #include <gl/glew.h>
00012 #include <string>
00013 #include "MathCommon.h"
00014
00019 struct VTInfo
00020 {
00021 int width;
00022 int height;
00023 int depth;
00024 int components;
00026 int size;
00027 };
00028
00034 class VolumeTexture
00035 {
00036 public:
00040 VolumeTexture();
00041
00045 ~VolumeTexture();
00046
00055 bool Load(const char *file, const char *path, VTInfo *info = NULL);
00056
00062 VTInfo GetInfo() const { return loadedVTinfo; }
00063
00072 void Bind(int unit = 0);
00073
00082 int CopyHistogram(unsigned int *data, int n);
00083
00087 void UnBind();
00088
00092 GLuint GetTextureID() const { return tex; }
00093
00094 protected:
00095
00109 bool LoadRAW(const char *filename, int w, int h, int d, int components);
00110
00120 void Precompute(const unsigned char *data, int w, int h, int d, unsigned char *res);
00121
00135 Vector3f ComputeNormal(const unsigned char *data, int x, int y, int z, int w, int h, int d);
00136
00137 GLuint tex;
00138
00139 int boundUnit;
00140
00141 unsigned int histogram[256];
00142
00143 VTInfo loadedVTinfo;
00144 };
00145
00146 #endif