X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=input.cpp;h=1df39c6d24df201010c020cc98ca43e4a2fa1c4f;hp=ae591062862526d127a85586e28cb6e424760a1d;hb=626dbd2b95fa5e8137ee1326d7f853a367b3bc6f;hpb=e1d0cc9aecf612f61d048fe0e4941c17d8f8f2f2 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));