Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: dynamically generated textures...

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2000
    Posts
    3

    dynamically generated textures...

    Hi !

    I want to generate a texture between to frames, in order to draw it on a quad, during the next frames. To generate my texture, I render the desired scene, and I store the back buffer without displaying it.

    That's OK, I can do it with the glReadPixels() function. It stores the buffer into the processor memory. Then I can create a texture object with glGenTexture2D() and use this texture object for the next frames.

    But it is very slow, because the texture is send from the video memory to the processor memory (glReadPixels), and then from the processor memory to the video memory (glGenTexture2D). The texture generation has to be very fast, otherwise the frame rate of the main scene will collapse...

    Is there a way to store my new texture directly into the video memory, as a texture object ? (kind of "readPixelsIntoTexture2D()" function ...)

    Thank you for your help !

    Aurelien

  2. #2
    Member Regular Contributor
    Join Date
    Feb 2000
    Location
    milano, italy
    Posts
    282

    Re: dynamically generated textures...

    glReadPixels is notoriously slow , only the arb can do something on this side...
    to my knowledge, there's no fast "framebuffer to texture" routine.

    however to speed up things you should use glTexSubimage instead of recreate a texture object every frame.

    while starting up the application, generate the texture as usual, with glGenTexture, glBindTexture and glTexImage.

    then, into the heartbeat, update the texture with glTexSubimage.

    Dolo/\/\ightY
    Dolo/\/\ightY

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: dynamically generated textures...

    Depending on the effect you want to create, you could render your texture in a DIB (which is not hardware accelerated !) and then glTexSubImage the result !

    This will avoid the slow glReadPixels process (but perhaps it is even slower !).

    Well, if your texture is really complicated to generate, it is not worth a try but in case of a simple thing, why not... (I have never done that but if I'll probably try it one day !).

    Eric

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2000
    Posts
    3

    Re: dynamically generated textures...

    Thank you for your answers !

    I have study the glTexSubImage2D() function in the red book, and I have found a very interesting one, wich is explained in the same section : glCopyTexSubImage2D(). It seems to do exactly what I want ! What do you think about that ?

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: dynamically generated textures...

    Hi Joe !

    Yes, I have just read the specs for this function and it seems to be exactly what you wanted ! (sorry, I did not think about it...).

    Try it and tell us if it is slow or acceptable !!!!

    Eric

  6. #6
    Junior Member Newbie
    Join Date
    Apr 2000
    Posts
    3

    Re: dynamically generated textures...

    Hi !

    There is a new problem : I want to generate some alpha in my texture. When I used glReadPixels(), I was able to modify my texture, and to change one color into alpha.

    But now, I can't access the texture. Do you know if there is a way to generate some alpha ?

    Thanks

    Jo Blue

Posting Permissions

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