glTexImage3D update with frame buffers

I have heard there is a way to update the information that is being displayed using glTexImage3D with the help of frame buffers or something like that. Does anybody know how to do that? I already have something being displayed. I get new fresh information and want to update it.

Can you explain a little better what you want to do. Frame buffers are render targets (ie you render to them instead of the back buffer)

Sounds like you are talking about RTT (Render To Texture).
In GL, it is done with FBO.

Theory is here

and some example here

examples are for 2D textures but it is easy to do it for 3D as well. Just attach each layer of your texture and render to it.

What I am doing is using glTexImage3D to render science data that I acquire using an instrument. This is not computer graphics. This is real live science data. Below is the code I use.

unsigned char* data


It works perfectly fine. Beautiful images come out. Only problem is that the data changes because it is live science data. As it changes I need to update what is seen on the screen. So what I do currently is just call the above glTexImage3D again. Works. Updates the image. The only problem is that the update takes about 1/2 second (500 milliseconds). That is too long for my application. My customers don’t like the response time. I don’t like the response time.

I have heard that one can set up a second frame buffer. Update the data in that buffer offline. Then do the switch from the offline buffer the online buffer really quickly.

The examples I see switch buffers, but do not show how to update the data. I guess they all work with computer graphics commands to generate images. My images originate from real live science instrument data.

Does that make sense? Do I need to elaborate further? Do you know of any examples that let you do what I describe above?

You should use glTexSubImage3D to update an existing texture. Think of glTexSubImage as a memcpy, while glTexImage is a malloc+memcpy.

Thank you for the suggestion but glTexSubImage and glTexImage benchmarked take about the same time.

How are you benchmarking just the update, as opposed to the entire render process?

I agree with Alfonse; I would be looking for another bottle neck other than the glTexSubImage

I have seen examples of what I’m trying to do online a while back. I just can’t remember where.

The last parameter of glTexImage3D is data.

const GLvoid * data

What occurs is the NULL value is passed for this parameter. This parameter is essentially a pointer to where the image data is stored.

There is some other way to provide and update this image data pointer.

What occurs is the NULL value is passed for this parameter.

Yes, you could create the texture object with a NULL data pointer. That will create the object but with no texture image.

You can supply that data separately, if you so wish - perhaps by using Pixel Buffer Objects (PBOs).

I thought PBO’s were for 2 dimensional displays with glTexImage2D

I found an excellent write-up of what you just described here…

The “Streaming Texture” example is what I am trying to do. However couldn’t get it to work with glTexImage3D. Oh well, still trying.