glGetTexImage and glTexImage2D-- what's the difference?

Discussion in 'Game Development (Technical)' started by esrix, Sep 9, 2005.

  1. esrix

    Original Member

    Joined:
    Aug 11, 2005
    Messages:
    143
    Likes Received:
    0
    I'm doing R&D for our game and I'm attempting to get a full understanding of SDL + Opengl.

    My question is:
    What is the difference between glGetTexImage and glTexImage2D functions? Are they both writing pixel data to video memory?

    I've been Googling information for several hours, but it doesn't help when every page is nearly the exact same documentation on OpenGL, just copied and pasted or a list of OpenGL functions

    I appreciate any help.
     
  2. zppz

    Original Member

    Joined:
    Aug 29, 2005
    Messages:
    104
    Likes Received:
    0
    glTexImage2D: you already have image data in memory, and you want to draw it on the screen.

    glGetTexImage: you have done the above and given a texture to OpenGL for rendering, and you want to get the pixels of it back into memory.

    Read the 'pixels' parameter of these functions, slowly ;)

    Must admit I had never heard of glGetTexImage, it doesn't seem like such a useful function really. Maybe if the original texture file you had has disappeared for some reason, or you want to get the mipmap levels as separate images.
     
  3. ggambett

    Moderator Original Member Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    1,982
    Likes Received:
    6
    glTexImage2D uploads pixel data from system memory to texture memory, and associates it with the currently bound texture. This is what you use when you load an image from disk and want to use it as a texture in OpenGL. After this call you don't need the original data anymore.

    glGetTexImage does the opposite, copies texture memory to system memory. You usually don't want to do this as the AGP bus is optimized to send data TO the video card, not FROM it, so it's usually slow. And for 90% of the applications you don't need to, anyway.
     
  4. esrix

    Original Member

    Joined:
    Aug 11, 2005
    Messages:
    143
    Likes Received:
    0
    Ah. Thanks for clearing that up ^_^
     
  5. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    It's often a pain in the ass to find documentation for GL stuff, especially when it comes to extensions. For future reference:

    http://www.opengl.org/

    has online copies of the red and blue books (GL programming guide and reference, respectively), albeit old versions.

    http://msdn.microsoft.com

    has documentation for most of the older (1.1 and earlier) GL functions. The GL section is kinda hard to find, usually I just do a search for glVertex and that takes me to the GL section :)

    And...

    http://oss.sgi.com/projects/ogl-sample/registry/

    has documentation for every extension. Very dry reading but also very thorough.

    Have fun...
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer