3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Maximus Minimus May 20 '12 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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