}
// 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);
private:
ImageFormat image_format;
GLenum format;
- GLuint texture_num;
+ GLuint pbo, texture_num;
bool needs_update;
int use_srgb_texture_format, needs_mipmaps;
unsigned width, height, bytes_per_pixel;
// generate a PDO to hold the data we read back with glReadPixels()
// (Intel/DRI goes into a slow path if we don't read to PDO)
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 1);
+ GLuint pbo;
+ glGenBuffers(1, &pbo);
+ glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
glBufferData(GL_PIXEL_PACK_BUFFER_ARB, WIDTH * HEIGHT * 4, NULL, GL_STREAM_READ);
make_hsv_wheel_texture();
input->set_pixel_data(src_img);
chain.render_to_screen();
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 1);
+ glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
check_error();
glReadPixels(0, 0, WIDTH, HEIGHT, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, BUFFER_OFFSET(0));
check_error();
SDL_GL_SwapBuffers();
check_error();
- glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 1);
+ glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
check_error();
unsigned char *screenbuf = (unsigned char *)glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY);
check_error();