VolumeDataStruct.h
2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef VOLUME_DATA_STRUCT_H
#define VOLUME_DATA_STRUCT_H
#include "rts_glTextureMap.h"
#include "rtsFilename.h"
#define VOLUME_FILE_AUTO 0
#define VOLUME_FILE_RAW 1
#define VOLUME_FILE_IMAGES 2
#define LOAD_LITTLE_ENDIAN 0
#define LOAD_BIG_ENDIAN 1
struct VolumeData
{
//character name of the texture for the shader
string Name;
//RTS variable for the texture map (takes care of texture management)
rts_glTextureMap Texture;
//file information
int FileType;
vector<rtsFilename> Filenames;
//volume size
vector3D<int> Dim;
int HeaderSize;
//big or little endian
int BitType;
//format of the incoming data
int ExternalComponents;
GLuint ExternalDatatype;
//format of the data on the GPU
int InternalComponents;
GLuint InternalDatatype;
int Normalized;
GLuint getInternalFormat()
{
switch(InternalComponents)
{
case 1:
if(InternalDatatype == GL_FLOAT)
return GL_LUMINANCE32F_ARB;
if(InternalDatatype == GL_UNSIGNED_BYTE && !Normalized)
return GL_R8;
if(InternalDatatype == GL_UNSIGNED_BYTE && Normalized)
return GL_R8_SNORM;
if(InternalDatatype == GL_SHORT && !Normalized)
return GL_R16;
if(InternalDatatype == GL_SHORT && Normalized)
return GL_R16_SNORM;
break;
case 2:
break;
case 3:
if(InternalDatatype == GL_FLOAT)
return GL_RGB32F;
if(InternalDatatype == GL_UNSIGNED_BYTE && !Normalized)
return GL_RGB8;
if(InternalDatatype == GL_UNSIGNED_BYTE && Normalized)
return GL_RGB8_SNORM;
if(InternalDatatype == GL_SHORT && !Normalized)
return GL_RGB16;
if(InternalDatatype == GL_SHORT && Normalized)
return GL_RGB16_SNORM;
break;
case 4:
if(InternalDatatype == GL_FLOAT)
return GL_RGBA32F;
if(InternalDatatype == GL_UNSIGNED_BYTE && !Normalized)
return GL_RGBA8;
if(InternalDatatype == GL_UNSIGNED_BYTE && Normalized)
return GL_RGBA8_SNORM;
if(InternalDatatype == GL_SHORT && !Normalized)
return GL_RGBA16;
if(InternalDatatype == GL_SHORT && Normalized)
return GL_RGBA16_SNORM;
break;
default:
break;
}
cout<<"Error getting internal format."<<endl;
return GL_LUMINANCE;
}
GLuint getExternalFormat()
{
switch(ExternalComponents)
{
case 1:
return GL_LUMINANCE;
break;
case 2:
return GL_LUMINANCE_ALPHA;
break;
case 3:
return GL_RGB;
break;
case 4:
return GL_RGBA;
break;
default:
break;
}
return GL_LUMINANCE;
}
int GetByteSize(GLuint t)
{
switch(t)
{
case GL_UNSIGNED_BYTE:
return 1;
break;
case GL_FLOAT:
return 4;
break;
case GL_UNSIGNED_SHORT:
case GL_SHORT:
return 2;
break;
default:
break;
}
return 0;
}
};
#endif