From: Steinar H. Gunderson Date: Sat, 6 Oct 2012 12:34:24 +0000 (+0200) Subject: Bind input textures to the right sampler, and do it even if we do not need to update... X-Git-Tag: 1.0~366 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=626dbd2b95fa5e8137ee1326d7f853a367b3bc6f;ds=sidebyside Bind input textures to the right sampler, and do it even if we do not need to update it (just draw from it). --- 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));