From 626dbd2b95fa5e8137ee1326d7f853a367b3bc6f Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 6 Oct 2012 14:34:24 +0200 Subject: [PATCH] Bind input textures to the right sampler, and do it even if we do not need to update it (just draw from it). --- input.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/input.cpp b/input.cpp index ae59106..1df39c6 100644 --- a/input.cpp +++ b/input.cpp @@ -83,6 +83,11 @@ void Input::finalize() void Input::set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) { + glActiveTexture(GL_TEXTURE0 + *sampler_num); + check_error(); + glBindTexture(GL_TEXTURE_2D, texture_num); + check_error(); + if (needs_update) { // Copy the pixel data into the PBO. glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo); @@ -93,10 +98,6 @@ void Input::set_gl_state(GLuint glsl_program_num, const std::string& prefix, uns check_error(); // Re-upload the texture from the PBO. - glActiveTexture(GL_TEXTURE0); - check_error(); - glBindTexture(GL_TEXTURE_2D, texture_num); - check_error(); glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch); check_error(); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0)); -- 2.39.2