-
Notifications
You must be signed in to change notification settings - Fork 0
/
Texture3D.tpp
51 lines (41 loc) · 2.1 KB
/
Texture3D.tpp
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
#ifndef TEXTURE3D_TEMPLATE
#define TEXTURE3D_TEMPLATE
#ifdef GL_API_GLAD_OPENGL_3
template <typename type>
Texture3D::Texture3D(type* pixels, GLsizei width, GLsizei height, GLsizei length, GLenum slot, GLint internalFormat, GLenum format, GLenum pixelType) {
Init<type>(pixels, width, height, length, slot, internalFormat, format, pixelType);
}
template <typename type>
void Texture3D::Init(type* pixels, GLint width, GLsizei height, GLsizei length, GLenum slot, GLint internalFormat, GLenum format, GLenum pixelType) {
Init<type>(&ID, pixels, width, height, length, slot, internalFormat, format, pixelType, &this->width, &this->height, &this->length);
}
template <typename type>
void Texture3D::Init(GLuint* ID, type* pixels, GLsizei width, GLsizei height, GLsizei length, GLenum slot, GLint internalFormat, GLenum format, GLenum pixelType, GLsizei* widthVar, GLsizei* heightVar, GLsizei* lengthVar) {
*widthVar = width;
*heightVar = height;
*lengthVar = length;
glGenTextures(1, ID);
glActiveTexture(slot);
Bind(*ID);
Data<type>(width, height, length, 0, internalFormat, format, pixelType, pixels);
}
template <typename type>
void Texture3D::Data(GLint level, GLint internalFormat, GLenum format, GLenum pixelType, type* pixels) {
Data<type>(width, height, length, level, internalFormat, format, pixelType, pixels);
}
template <typename type>
void Texture3D::Data(GLsizei width, GLsizei height, GLsizei length, GLint level, GLint internalFormat, GLenum format, GLenum pixelType, type* pixels) {
if (level) {
GLint detail = 2 * level;
glTexImage3D(bufferType, level, internalFormat, width / detail, height / detail, length / detail, 0, format, pixelType, pixels);
}
else {
glTexImage3D(bufferType, level, internalFormat, width, height, length, 0, format, pixelType, pixels);
}
}
template <typename type>
void Texture3D::SubData(GLint xOffset, GLint yOffset, GLint zOffset, GLsizei width, GLsizei height, GLsizei length, GLint level, GLenum format, GLenum pixelType, type* pixels) {
glTexSubImage3D(bufferType, level, xOffset, yOffset, zOffset, width, height, length, 0, format, pixelType, pixels);
}
#endif
#endif