- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- check_error();
-
- // Create PBOs to hold the textures holding the input image, and then the texture itself.
- glGenBuffers(3, pbos);
- check_error();
- glGenTextures(3, texture_num);
- check_error();
-
- for (unsigned channel = 0; channel < 3; ++channel) {
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbos[channel]);
- check_error();
- glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, pitch[channel] * heights[channel], NULL, GL_STREAM_DRAW);
- check_error();
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
- check_error();
-
- glBindTexture(GL_TEXTURE_2D, texture_num[channel]);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- check_error();
- glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch[channel]);
- check_error();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, widths[channel], heights[channel], 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
- check_error();
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- check_error();
- }
-
- needs_update = true;