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

Thread: Loading a tga file directly into openGL

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2008
    Posts
    17

    Loading a tga file directly into openGL

    Hello! I would like to know if there is any techniques that allow the loading of a tga file into an openGL scene. For example,I have to make a nature scene with a forest and I have tga files of different trees. Is there a way to put the picture file directly into the scene?

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,979

    Re: Loading a tga file directly into openGL

    Read about texturing in OpenGL (there should be plenty of tutorials, for example ones from NeHe). You may be also interested in billboarding. As to tga loading, simple google search will give you some code.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2008
    Posts
    17

    Re: Loading a tga file directly into openGL

    Thanks! I didn't know what I was looking for was called billboarding.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    748

    Re: Loading a tga file directly into openGL


  5. #5
    Junior Member Newbie
    Join Date
    Jan 2008
    Posts
    17

    Re: Loading a tga file directly into openGL

    Thanks for the link! But,I can't understand everything in the Billboarding tutorial. Can anyone make it simpler for me? For example,if I just want the tga file to appear and not the snowman.

  6. #6
    Junior Member Regular Contributor songho's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    247

    Re: Loading a tga file directly into openGL

    girish3110,
    Please take a look at this:
    imageTga.zip

    It loads a TGA image and render it using glDrawPixels(). You can get better rendering performance by using OpenGL texture object. However, most images are not power of 2 (POT) in resolution, so, glDrawPixels() is much simpler for NPOT images.

    You may use OpenGL extension, GL_ARB_texture_non_power_of_two, and GL_ARB_texture_rectangle if the video card supports them.
    Here is an example to load NPOT images and render it as texture.
    textureNPOT.zip
    textureRectangle.zip

  7. #7
    Junior Member Newbie
    Join Date
    Jan 2008
    Posts
    17

    Re: Loading a tga file directly into openGL

    Thanks.

Posting Permissions

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