Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: glTexImage3D update with frame buffers

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    25

    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.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    723

    Re: glTexImage3D update with frame buffers

    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)

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: glTexImage3D update with frame buffers

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

    Theory is here
    http://www.opengl.org/wiki/Framebuffer_Objects

    and some example here
    http://www.opengl.org/wiki/Framebuffer_Object_Examples

    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.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    25

    Re: glTexImage3D update with frame buffers

    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?

  5. #5
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,719

    Re: glTexImage3D update with frame buffers

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

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    25

    Re: glTexImage3D update with frame buffers

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

  7. #7
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,719

    Re: glTexImage3D update with frame buffers

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

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    723

    Re: glTexImage3D update with frame buffers

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

  9. #9
    Junior Member Newbie
    Join Date
    Nov 2011
    Posts
    25

    Re: glTexImage3D update with frame buffers

    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.

  10. #10
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,171

    Re: glTexImage3D update with frame buffers

    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •