1

I am trying to perform something like the old glDrawPixels: I have a Pixel buffer created with text and I would like to apply it to the back buffer (where all the scene is already rendered).

unsigned char a[] = {255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0};

// What I would
//glDrawPixels(2, 2, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)pixels);

// What I am trying
GLuint pbo = 0;
glGenBuffers(1, &pbo);
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER, 12, a, GL_STREAM_DRAW);
// Blit pbo to back buffer, but how?

// Release all
....

Most tutorial[1] seem to copy the pixel buffer to a texture and then apply this texture to a quad, but this solution seem to perform lot of unnecessary operations: copy the data, create filtering for the texture, draw a quad (which mean a new VBO), etc...

Other answers[2] speak about "Blitting", but I am unable to get it working.

Also, most information about OpenGL still use glDrawPixels which is deprecated (and unavailable) for OpenGL 3.X.

[1] http://www.songho.ca/opengl/gl_pbo.html

Render TTF SDL2.0 opengl 3.1

[2] https://devtalk.nvidia.com/default/topic/453751/cuda-programming-and-performance/direct-access-to-frame-buffer-/

Community
  • 1
  • 1
Adrian Maire
  • 14,354
  • 9
  • 45
  • 85
  • 2
    Blitting from an arbitrary read buffer to a draw buffer is generally slower than texture mapping, believe it or not. Particularly since you would be unnecessarily copying image data every frame in your current scenario. Just copy this image data to a texture and apply that. – Andon M. Coleman May 06 '14 at 18:58
  • Applying a texture to (for example) a quad, it lose a lot of definition due to rotate, scale, filters, etc., that mean the image (with texts) is very ugly after the render. There is not a better way to just merge pixels? EDIT: With ugly, I mean the text quality comes worse. – Adrian Maire May 07 '14 at 15:07
  • I finally applied your technique: create a texture and apply it to a quad. Lot of job but, it finally work. Thanks – Adrian Maire May 09 '14 at 11:23

0 Answers0