aboutsummaryrefslogtreecommitdiff
path: root/src/RenderBackend
diff options
context:
space:
mode:
Diffstat (limited to 'src/RenderBackend')
-rw-r--r--src/RenderBackend/OpenGL/Texture2D.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/RenderBackend/OpenGL/Texture2D.cpp b/src/RenderBackend/OpenGL/Texture2D.cpp
index f4326a8..7d1b83c 100644
--- a/src/RenderBackend/OpenGL/Texture2D.cpp
+++ b/src/RenderBackend/OpenGL/Texture2D.cpp
@@ -43,6 +43,13 @@ namespace amalgine {
}
+ static void output_gl_error(const char *description) {
+ GLenum error = glGetError();
+ if(error != GL_NO_ERROR) {
+ fprintf(stderr, "Error: failed to %s, reason: %s (%u)\n", description, glewGetErrorString(error), error);
+ }
+ }
+
Texture2D::Texture2D(Image *image)
{
assert(image);
@@ -52,10 +59,16 @@ namespace amalgine {
texture_id = texture_id_allocator->get_free_texture_id();
printf("texture id: %d\n", texture_id);
texture_ref = -1;
+ //output_gl_error("start");
glGenTextures(1, &texture_ref);
+ //output_gl_error("gen textures");
glActiveTexture(GL_TEXTURE0 + texture_id);
+ //output_gl_error("set active texture");
glBindTexture(GL_TEXTURE_2D, texture_ref);
+ //output_gl_error("bind texture");
+
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image->getWidth(), image->getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, image->getData());
+ //output_gl_error("set texture");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);