} 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();
{
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);