From 51e5e742e518be511c2cb3234d01459d1233dc85 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 20 Feb 2020 04:52:40 +0100 Subject: Add debug output for opengl --- src/RenderBackend/OpenGL/Texture2D.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/RenderBackend/OpenGL') 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); -- cgit v1.2.3