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 2 of 2

Thread: Help me get started with transferring textures with buffer objects.

  1. #1
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    1

    Help me get started with transferring textures with buffer objects.

    I was looking at a doc from nVidia about how to perform fast transfers of textures to the GPU.

    There's a part in that document that suggests the following:
    To download data to the GPU, bind the buffer to the GL_PIXEL_UNPACK_
    BUFFER target using glBindBufferARB(). The glTexImage2D()
    command will then unpack (read) their data from the buffer object.
    But this is a little bit beyond me. Can someone help me through understanding this?

    I have to generate a texture object, I assume. And I think I have to generate a buffer object as well. The texture is like metadata about the format of the buffer (I think). The buffer is the actual storage of the pixels (I think).
    Then somehow I have to call glBindBuffer with GL_PIXEL_UNPACK_BUFFER.
    And it says to use glTexImage2D. So I'm not sure how the data gets where it needs to go. But here's my guess on how things work. Someone correct me if I'm wrong.

    glGenTextures( 1, &myTexture );
    glGenBuffers( 1, &myBuffer );
    glBindBuffer( GL_PIXEL_UNPACK_BUFFER, myBuffer );
    glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, width, height, format, type, 0 );

    I think that because there is something bound to GL_PIXEL_UNPACK_BUFFER that glTexSubImage2D gets its data from the buffer instead of from the data pointer argument. (and the data pointer becomes an offset)

    But before this happens, I'll need to get data into the buffer object. How do I get data into the buffer object? and isn't that just the same problem all over again?

  2. #2

Posting Permissions

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