]> git.sesse.net Git - movit/blobdiff - input.cpp
Generate PBOs on-the-fly instead of having hard-coded numbers.
[movit] / input.cpp
index 1e460f09606d89bcb15064ed36b535b869806146..453620c41df023353fc943c920cd117673c0f1b2 100644 (file)
--- a/input.cpp
+++ b/input.cpp
@@ -46,7 +46,9 @@ void Input::finalize()
        }
 
        // Create PBO to hold the texture holding the input image, and then the texture itself.
-       glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 2);
+       glGenBuffers(1, &pbo);
+       check_error();
+       glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
        check_error();
        glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, width * height * bytes_per_pixel, NULL, GL_STREAM_DRAW);
        check_error();
@@ -73,7 +75,7 @@ void Input::set_gl_state(GLuint glsl_program_num, const std::string& prefix, uns
 {
        if (needs_update) {
                // Copy the pixel data into the PBO.
-               glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 2);
+               glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
                check_error();
                void *mapped_pbo = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY);
                memcpy(mapped_pbo, pixel_data, width * height * bytes_per_pixel);