summaryrefslogtreecommitdiff
path: root/texture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'texture.cpp')
-rw-r--r--texture.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/texture.cpp b/texture.cpp
index c3575f2..c8c5541 100644
--- a/texture.cpp
+++ b/texture.cpp
@@ -3,14 +3,30 @@
#include "texture.h"
#include <stdio.h>
-unsigned int Texture::tex() {
+void Texture::bind() const {
+ glBindTexture(GL_TEXTURE_2D, texture);
+}
+
+unsigned int Texture::tex() const {
return texture;
}
-void Texture::build() {
+unsigned int Texture::w() const {
+ return width;
+}
+
+unsigned int Texture::h() const {
+ return height;
+}
+
+void Texture::build(void* data, unsigned int format, unsigned int w, unsigned int h) {
if(!data) {
throw(std::runtime_error("No texture data"));
}
+
+ width = w;
+ height = h;
+
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);