00001
00002
00003
00004
00005
00006
00007
00009
00010 #ifndef _VOLUME_BUFFER_H
00011 #define _VOLUME_BUFFER_H
00012
00013 #include <GL/glew.h>
00014
00015
00016
00017 #include <f3dVector.h>
00018
00019
00020 class VolumeBuffer {
00021 public:
00022 VolumeBuffer(GLenum format, int width, int height, int depth, int banks);
00023 ~VolumeBuffer();
00024
00025 enum BlendMode { BLEND_NONE = 0, BLEND_ADDITIVE };
00026
00027
00028
00029
00030 int setData(unsigned char *data, int bank=0);
00031
00032 void set2DData(unsigned char* data, int bank=0);
00033
00034 void setWrapMode(GLint mode, int bank=0);
00035 void setFiltering(GLint mode, int bank=0);
00036 void setBlendMode(BlendMode mode) { m_blendMode = mode; }
00037
00038
00039
00040
00041 GLuint getTexture(int bank = 0) { return m_tex[bank]; }
00042
00043 int getWidth() { return m_width; }
00044 int getHeight() { return m_height; }
00045 int getDepth() { return m_depth; }
00046
00047 void drawSlice(float z);
00048 void drawOneSlice();
00049 void drawZSlice(int iz);
00050 void drawXSlice(int ix);
00051 void drawYSlice(int iy);
00052
00053 GLuint create2DTextures(GLenum internalformat);
00054 GLuint create2DTexturesZ(GLenum internalformat);
00055 GLuint create2DTexturesX(GLenum internalformat);
00056 GLuint create2DTexturesY(GLenum internalformat);
00057
00058 GLuint create2DTexturesZscale1(GLenum internalformat);
00059 GLuint create2DTexturesZscale2(GLenum internalformat);
00060 GLuint create2DTexturesZscale3(GLenum internalformat);
00061
00062 int readRawFile(char *filename);
00063 int readScale1File(char *filename);
00064 int readScale2File(char *filename);
00065 int readScale3File(char *filename);
00066
00067 unsigned char *m_volume_data_raw;
00068 unsigned char *m_volume_data_rgba;
00069
00070
00071 unsigned char *m_scale1_raw;
00072 unsigned char *m_scale1_rgba;
00073
00074 unsigned char *m_scale2_raw;
00075 unsigned char *m_scale2_rgba;
00076
00077 unsigned char *m_scale3_raw;
00078 unsigned char *m_scale3_rgba;
00079
00080 f3dVectorF vertex[8],normal[6];
00081
00082
00083 GLuint* m_tex_z;
00084 GLuint* m_tex_x;
00085 GLuint* m_tex_y;
00086
00087 GLuint* m_tex_z_s1;
00088 GLuint* m_tex_z_s2;
00089 GLuint* m_tex_z_s3;
00090
00091 private:
00092 GLuint create3dTexture(GLenum internalformat, int w, int h, int d);
00093 GLuint create2dTexture(GLenum internalformat, int w, int h, int d);
00094
00095
00096
00097 int m_width, m_height, m_depth;
00098 int m_volume_size;
00099 int m_max_banks;
00100 int m_banks;
00101
00102
00103 BlendMode m_blendMode;
00104
00105
00106
00107 GLuint *m_tex;
00108 int m_textures_ready;
00109 };
00110
00111 #endif