Render multiple images to an offscreen surface.


I am trying to come up with a way of doing the following using OpenGL:
A client receives multiple png images from a server (it can be thousands of them). Each image has an x,y coordinate for where it should be rendered.
I need to render these images as mosaic on an off screen surface. The server will indicate when it is time to flip the offscreen surface and show it on the screen.
The offscreen surface and the screen has the same size, and the size is known a head of time.
With other graphics libraries I have used an offscreen surface and done blits of the images as they are coming in.
In OpenGL I do not see the concept of offscreen surfaces that can blit images. It looks like textures are used to load images, but theres is only one image per texture. There are also texture arrays and frame buffers, but all of these require that I keep all the images in memory and then render them. To save memory I need to to have one image that is as big as the screen that I can modify (by applying the new images as they are coming in from the server).
What would be the best approach to accomplish this in OpenGL?


  1. Why do you want to use OpenGL for this? It doesn’t seem like a task which would get much benefit from the video hardware.

  2. If, for whatever reason, the completed mosaic must be an OpenGL texture, you have a number of options:
    a) create the mosaic in client memory, then convert the completed mosaic to a texture with glTexImage2D().
    b) create a blank texture then paste the individual images onto it with glTexSubImage2D().
    c) create a blank texture, attach it to a framebuffer object, convert the individual images to textures, then paste them onto the mosaic by drawing textured rectangles.

There might be some advantage to c) if you wanted to use an image more than once. Otherwise, it increases complexity for no gain.

Thanks for the quick response. There is one thing I left out. A video is playing underneath and each frame is displayed as a texture.
The mosaic image will be an overlay over the video texture.

I will give the gltexsubimage2d a shot.

Thanks again for your help.