Sign in to follow this  

Load Textures From File

Recommended Posts

Look at the D3DXCreateTextureFromFile family of functions that ship with DirectX -- they provide a lot of this functionality for you.

If you want to write the loader yourself, TGA files can be pretty simple. The header for a TGA file looks like this:

typedef struct
BYTE identsize; // size of ID field that follows 18 byte header (0 usually)
BYTE colourmaptype; // type of colour map 0=none, 1=has palette
BYTE imagetype; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed

short colourmapstart; // first colour map entry in palette
short colourmaplength; // number of colours in palette
BYTE colourmapbits; // number of bits per palette entry 15,16,24,32

short xstart; // image x origin
short ystart; // image y origin
short width; // image width in pixels
short height; // image height in pixels
BYTE bits; // image bits per pixel 8,16,24,32
BYTE descriptor; // image descriptor bits (vh flip bits)

// pixel data follows header


Hope this helps a little.

Edited by Coder: Source tags are almost always preferred, at least for the syntax highlighting. See GDNet Forums FAQ

[Edited by - Coder on August 3, 2004 4:36:09 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this