-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture.h
41 lines (30 loc) · 1.06 KB
/
texture.h
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
#ifndef TEXTURE_H
#define TEXTURE_H
#include "glsupport.h"
class Texture {
public:
// Must return one of GL_SAMPLER_1D, GL_SAMPLER_2D, GL_SAMPLER_3D, GL_SAMPLER_CUBE,
// GL_SAMPLER_1D_SHADOW, or GL_SAMPLER_2D_SHADOW, as its intended usage by GLSL shader
virtual GLenum getSamplerType() const = 0;
// Binds the texture. (The caller is responsible for setting the active texture unit)
virtual void bind() const = 0;
virtual ~Texture() {}
};
//----------------------------------------
// One concrete implementation of Texture
//----------------------------------------
class ImageTexture : public Texture {
GlTexture tex;
public:
// Loades a PPM image files with three channels, and create
// a 2D texture off it. if `srgb' is true, the image is assumed
// to be in SRGB color space
ImageTexture(const char* ppmFileName, bool srgb); // implemented in texture.cpp
virtual GLenum getSamplerType() const {
return GL_SAMPLER_2D;
}
virtual void bind() const {
glBindTexture(GL_TEXTURE_2D, tex);
}
};
#endif