Game Development Community

dev|Pro Game Development Curriculum

Targa Support

by J. Donavan Stanley · 12/13/2002 (3:07 pm) · 13 comments

Download Code File

From the README.TXT file:


The enclosed files add support for loading Targa files within TGE. Why use Targa files? Because they're one of the few file formats that Photshop supports alpha channels in. Note: Contrary to what Photoshop says the alpha channel is only saved in 32 bits per pixel mode.

The patch file is for the HEAD version of the source although it SHOULD work with Release_1_1_2 as well.

Installation

Copy the enclosed .cc and .h files to torque\engine\dgl then add them to your projects.
Copy TGA_PATCH.TXT to \torque and then run: "patch -p3 < TGA_PATCH.TXT"
Rebuild your source.

This patch is part an upcoming UI patch from the Torque Enhancment Project ( http://tge.ta-network.net/cgi-bin/ikonboard.cgi ).

#1
12/13/2002 (3:49 pm)
Woohoo! I was just going to do this tonight, but looks like it won't be necessary now, great timing man. :)
#2
12/13/2002 (5:14 pm)
How do you run: "patch -p3 < TGA_PATCH.TXT"

i dont understand.

tga will be a good thing for torque :)
#3
12/13/2002 (7:09 pm)
Check out the handy resource on patches.
#4
12/14/2002 (7:50 am)
ya, i seen that before, it makes no sence to me, can i just add the three files to my project and compile.

i have win98se and vc++6.0
#5
12/14/2002 (9:33 am)
In addition to adding the files you need to make a few changes to some of the other source files. Hence the patch file.

If you take a look at the patch.txt file it contains the lines you need to add but i'll detail them here:

Add the following function to gBitmap.cc
ResourceInstance* constructBitmapTGA(Stream &stream)
 {
    GBitmap* bmp = new GBitmap;
    if (bmp->readTGA(stream))
       return bmp;
     else 
     {
       delete bmp;
       return NULL;
    }
 }

Add the following line to gBitmap.h (line 32)
extern ResourceInstance* constructBitmapTGA(Stream& stream);

On line 134 add:
bool readTGA(Stream& stream);

And then in main.cc on line 147 add:
ResourceManager->registerExtension(".tga", constructBitmapTGA);
#6
12/15/2002 (7:38 am)
Thanks J.D. , i really appreciate that
#7
04/21/2003 (8:53 am)
Very useful, thanks!
#8
09/03/2003 (12:43 pm)
I think you will need to add

static const char* extArray[EXT_ARRAY_SIZE] = { "", ".jpg", ".png", ".gif", ".bmp", ".tga" };

on line 79 of gTexManager.cc
to get targa's to work with interiors correctly.
#9
08/10/2004 (2:55 am)
If you want it to work under visual 7, you have to initialise some values to 0, what is not done by the compiler by default.

LibTarga.cc - line 250 :

U8 cmap_bytes_entry = 0;
    U32 cmap_bytes = 0;
#10
02/07/2006 (2:26 am)
I have some problems to compile with TGE 1.4:

....

Linking...
engine.lib(bitmapTGA.obj) : error LNK2019: unresolved external symbol _tga_load referenced in function "public: bool __thiscall GBitmap::readTGA(class Stream &)" (?readTGA@GBitmap@@QAE_NAAVStream@@@Z)
../tools/langc.exe : fatal error LNK1120: 1 unresolved externals...

...


?????
#11
08/02/2006 (9:33 pm)
You'll see that problem if you don't add the new files to your project.
#12
09/12/2006 (8:07 am)
Took me about 10 mins to get this working with TSE MS 4.0.
Thanks for posting a great resource.
Really saved me a bunch of time.

Todd
#13
01/05/2007 (1:19 am)