View Full Version : glTexImage3D update with frame buffers
03-28-2012, 03:17 PM
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.
03-29-2012, 12:41 AM
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)
03-29-2012, 05:44 AM
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.
04-05-2012, 11:34 AM
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
glTexImage3D(GL_TEXTURE_3D, 0,GL_RGBA8 , WIDTH, HEIGHT, DEPTH, 0, GL_RGBA, GL_UNSIGNED_BYTE, 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?
04-05-2012, 11:39 AM
You should use glTexSubImage3D (http://www.opengl.org/wiki/GLAPI/glTexSubImage3D) to update an existing texture. Think of glTexSubImage as a memcpy, while glTexImage is a malloc+memcpy.
04-06-2012, 11:53 AM
Thank you for the suggestion but glTexSubImage and glTexImage benchmarked take about the same time.
04-06-2012, 02:25 PM
How are you benchmarking just the update, as opposed to the entire render process?
04-07-2012, 07:41 AM
I agree with Alfonse; I would be looking for another bottle neck other than the glTexSubImage
04-11-2012, 03:17 PM
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.
04-12-2012, 02:59 AM
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).
04-12-2012, 03:02 PM
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.