PDA

View Full Version : glTexImage3D reload/refresh



jacktca
03-19-2012, 05:01 PM
I have malloc-ed data in a buffer. I run glTexImage3D and supply the data as a parameter. Everything works fine. I make changes to the data. I rerun glTexImage3D. Everything works fine and I can see the changes that were made on the screen. The problem is that this is a rather slow process. Rerunning glTexImage3D to reload/refresh the data in malloc-ed memory takes time. Is there any faster way of doing this?

Alfonse Reinheart
03-19-2012, 07:55 PM
You should use glTexSubImage3D for uploading new data to an already existing texture. You can pick pixel transfer parameters (http://www.opengl.org/wiki/Pixel_Transfer) that your implementation won't have to convert. And you can use pixel buffers to make the transfer asynchronous (http://www.opengl.org/wiki/Pixel_Buffer_Object), but this will only be "faster" if you have something you could be doing while the transfer is going on.

V-man
03-20-2012, 02:56 AM
I suggest that you use a format that is directly supported by the GPU. Example, all cards support B8G8R8A8 (GL_BGRA).
http://www.opengl.org/wiki/Common_Mistakes#Unsupported_formats_.233

jacktca
03-20-2012, 11:52 AM
I tried glTexSubImage3D and I tried glCopyTexSubImage3D and stopwatch showed pretty much the same benchmark timing as when I just ran glTexImage3D over again. It didn't seem to speed things up.