Results 1 to 2 of 2

Thread: After PBO update why I need glTexImage2D?

  1. #1
    Member Contributor
    Join Date
    Nov 2011
    Posts
    51

    After PBO update why I need glTexImage2D?

    I try to understand why I need to "re-create/allocate" image texture after a PBO upload....

    Execution:

    1. glGenTextures()
    2. glBindTexture()
    3. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0) //just memory/buffer allocation
    4. glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, w*h*4, GL_MAP_WRITE_BIT)
    5. memcpy(...)
    6. glUnmapBuffer()
    7. ...GPU fence waiting upload...
    8. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0) //same as n.3!!!!!!


    If I comment last line (n. I get a texture with "random"/wrong pixels color...
    glMapBufferRange and memcpy functions should have uploaded/updated/refreshed texture's bytes, so why the last command (n. needed to be executed?

    Thanks

  2. #2
    Member Newbie
    Join Date
    Dec 2013
    Posts
    45
    Have you tried commenting out the first glTexImage2D and leaving the second?

    The reason why the PBO upload doesn't update the texture is because the PBO isn't associated with the texture in any way. A PBO's purpose is to simply store pixel data that will be used at a later time (for a texture or whatever) and let the implementation decide how to manage it.

Similar Threads

  1. FBO and glTexImage2D
    By LaLaChen in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 04-30-2013, 11:23 PM
  2. glTexImage2D
    By rpenland in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-10-2003, 02:06 AM
  3. glTexImage2D
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-28-2003, 01:19 AM
  4. glTexImage2D
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-26-2003, 08:01 AM
  5. glTexImage2D
    By nystep in forum OpenGL: Advanced Coding
    Replies: 16
    Last Post: 07-16-2002, 06:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean