X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=input.cpp;h=cf0210c8fcfca822ff1d5b8d463ed9069dabf369;hp=1e460f09606d89bcb15064ed36b535b869806146;hb=ad0e48a8b82a679f1d2836254ef33320e7162733;hpb=d3cf1194740dbecde06f5e721a7e1910437a7666 diff --git a/input.cpp b/input.cpp index 1e460f0..cf0210c 100644 --- a/input.cpp +++ b/input.cpp @@ -41,12 +41,17 @@ void Input::finalize() } else if (image_format.pixel_format == FORMAT_BGRA) { format = GL_BGRA; bytes_per_pixel = 4; + } else if (image_format.pixel_format == FORMAT_GRAYSCALE) { + format = GL_LUMINANCE; + bytes_per_pixel = 1; } else { assert(false); } // 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 +78,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);