Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I use glTexImage2D() and / or glTexSubImage2D() (or maybe there's some other method I don't know about) with an already existing block of memory, instead of always uploading the changed pixels? I already have the changed pixels somewhere in memory, and I'd like to send a pointer to that location if possible.

The problem is that I'm likely going to update a large amount of pixels, and uploading all of them introduces a lot of overhead and wasted memory. And since the application will only run on a mobile device without dedicated GPU memory, all I'm doing now is copying a big chunk of memory to another location of the same memory...

Also, I'm looking for a solution that would work on iOS devices, since the application will only run on iOS.

share|improve this question

Yes, you can. But not with glTexImage2D, as the just uploads image data to the gpu.

What you can do however, is by binding the texture to a pixel buffer, and then mapping the pixel buffer to memory by using glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, ID).

This will give you a point to the pixel data.

share|improve this answer
Be aware that using a PBO will also give you a 2x memory overhead - once for the PBO and once for the texture. Also beware of pipeline stalls when mapping. – Le Comte du Merde-fou May 20 '12 at 18:28
Unfortunately, this won't work on iOS (which implements OpenGL ES 2.0). – rid May 22 '12 at 12:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.