forked from tharvik/COG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Texture.cpp
37 lines (29 loc) · 838 Bytes
/
Texture.cpp
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
#include "Texture.h"
using namespace std;
Texture::Texture() : imageId(0)
{}
Texture::Texture(Texture&& texture) : imageId(texture.imageId)
{
texture.imageId = 0;
}
Texture::Texture(const unsigned short width, const unsigned short height,
const GLenum format, unsigned char *buffer) : imageId(0)
{
glGenTextures(1, &this->imageId);
glBindTexture(GL_TEXTURE_2D, this->imageId);
glTexImage2D (GL_TEXTURE_2D, 0, 4, width, height, 0, format,
GL_UNSIGNED_BYTE, buffer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
void Texture::bindTexture() const
{
glBindTexture(GL_TEXTURE_2D, this->imageId);
}
bool Texture::operator<(const Texture &b) const
{
return this->imageId < b.imageId;
}
Texture::~Texture()
{
glDeleteBuffers(1, &this->imageId);
}