How can I read/write pixels in an OpenGL texture?

BlitzMax Forums/BlitzMax OpenGL Programming/How can I read/write pixels in an OpenGL texture?

To download pixels from the backbuffer into main memory you use glReadPixels(). You have to set up things like glTexParameter() before you do the transfer, and you need some memory allocated to download to - which is what pixmaps usually are for. You could use a bank.

To download from a texture to main memory I presume you'd use glGetTexImage(). I've never heard of that one.

glTexSubImage2d uploads pixels from main memory to a portion on an existing previously defined texture, kind of a drawimage-rect (which is faster than making a new texture).