View Full Version : Loading a tga file directly into openGL
01-04-2008, 03:17 AM
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?
01-04-2008, 03:46 AM
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.
01-04-2008, 04:05 AM
Thanks! I didn't know what I was looking for was called billboarding. :)
01-04-2008, 06:11 AM
TGA loading (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=33)
01-04-2008, 08:27 AM
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.
01-04-2008, 03:31 PM
Please take a look at this:
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.
01-04-2008, 09:54 PM
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.