]> git.sesse.net Git - movit/commitdiff
Bind input textures to the right sampler, and do it even if we do not need to update...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 6 Oct 2012 12:34:24 +0000 (14:34 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 6 Oct 2012 12:34:24 +0000 (14:34 +0200)
input.cpp

index ae591062862526d127a85586e28cb6e424760a1d..1df39c6d24df201010c020cc98ca43e4a2fa1c4f 100644 (file)
--- 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)
 {
        
 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);
        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.
                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));
                glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch);
                check_error();
                glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));