forked from kidanger/vpv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Texture.cpp
34 lines (25 loc) · 819 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
#include <SFML/OpenGL.hpp>
#include "Texture.hpp"
#ifndef GL_RGB32F
#define GL_RGB32F 0x8815
#endif
void Texture::create(int w, int h, unsigned int type, unsigned int format)
{
if (id == -1) {
glGenTextures(1, &id);
}
glBindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, w, h, 0, format, type, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
size.x = w;
size.y = h;
this->type = type;
this->format = format;
}
Texture::~Texture() {
glDeleteTextures(1, &id);
}