-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTexture1D.tpp
More file actions
49 lines (39 loc) · 1.65 KB
/
Copy pathTexture1D.tpp
File metadata and controls
49 lines (39 loc) · 1.65 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
#ifndef TEXTURE1D_TEMPLATE
#define TEXTURE1D_TEMPLATE
#ifdef GL_API_GLAD_OPENGL_3
template <typename type>
Texture1D::Texture1D(type* pixels, GLsizei width, GLenum slot, GLint internalFormat, GLenum format, GLenum pixelType) {
Init<type>(pixels, width, slot, internalFormat, format, pixelType);
}
template <typename type>
void Texture1D::Init(type* pixels, GLint width, GLenum slot, GLint internalFormat, GLenum format, GLenum pixelType) {
Init<type>(&ID, pixels, width, slot, internalFormat, format, pixelType, &this->width);
}
template <typename type>
void Texture1D::Init(GLuint* ID, type* pixels, GLsizei width, GLenum slot, GLint internalFormat, GLenum format, GLenum pixelType, GLsizei* widthVar) {
*widthVar = width;
glGenTextures(1, ID);
glActiveTexture(slot);
Bind(*ID);
Data<type>(width, 0, internalFormat, format, pixelType, pixels);
}
template <typename type>
void Texture1D::Data(GLint level, GLint internalFormat, GLenum format, GLenum pixelType, type* pixels) {
Data<type>(width, level, internalFormat, format, pixelType, pixels);
}
template <typename type>
void Texture1D::Data(GLsizei width, GLint level, GLint internalFormat, GLenum format, GLenum pixelType, type* pixels) {
if (level) {
GLint detail = 2 * level;
glTexImage1D(bufferType, level, internalFormat, width / detail, 0, format, pixelType, pixels);
}
else {
glTexImage1D(bufferType, level, internalFormat, width, 0, format, pixelType, pixels);
}
}
template <typename type>
void Texture1D::SubData(GLint xOffset, GLsizei width, GLint level, GLenum format, GLenum pixelType, type* pixels) {
glTexSubImage1D(bufferType, level, xOffset, width, 0, format, pixelType, pixels);
}
#endif
#endif