aboutsummaryrefslogtreecommitdiff
path: root/src/RenderBackend/OpenGL
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-02-20 04:52:40 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 15:22:10 +0100
commit51e5e742e518be511c2cb3234d01459d1233dc85 (patch)
treef97d08b8fcebd3f253a2142f02740e61fc9065ca /src/RenderBackend/OpenGL
parent8d9b24b1b84107c90a77d94c86a810cc068fe073 (diff)
Add debug output for opengl
Diffstat (limited to 'src/RenderBackend/OpenGL')
-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);