1 //-----------------------------------------------------------------------------
2 //
3 // ImageLib Sources
4 // Copyright (C) 2000-2009 by Denton Woods
5 // Last modified: 02/16/2009
6 //
7 // Filename: src-IL/src/il_texture.c
8 //
9 // Description: Reads from a Medieval II: Total War	(by Creative Assembly)
10 //				Texture (.texture) file.
11 //
12 //-----------------------------------------------------------------------------
13 
14 #include "il_internal.h"
15 #ifndef IL_NO_TEXTURE
16 
17 
18 //! Reads a TEXTURE file
ilLoadTexture(ILconst_string FileName)19 ILboolean ilLoadTexture(ILconst_string FileName)
20 {
21 	ILHANDLE	TextureFile;
22 	ILboolean	bTexture = IL_FALSE;
23 
24 	TextureFile = iopenr(FileName);
25 	if (TextureFile == NULL) {
26 		ilSetError(IL_COULD_NOT_OPEN_FILE);
27 		return bTexture;
28 	}
29 
30 	bTexture = ilLoadTextureF(TextureFile);
31 	icloser(TextureFile);
32 
33 	return bTexture;
34 }
35 
36 
37 //! Reads an already-opened TEXTURE file
ilLoadTextureF(ILHANDLE File)38 ILboolean ilLoadTextureF(ILHANDLE File)
39 {
40 	ILuint		FirstPos;
41 	ILboolean	bRet;
42 
43 	iSetInputFile(File);
44 	FirstPos = itell();
45 	// From http://forums.totalwar.org/vb/showthread.php?t=70886, all that needs to be done
46 	//  is to strip out the first 48 bytes, and then it is DDS data.
47 	iseek(48, IL_SEEK_CUR);
48 	bRet = ilLoadDdsF(File);
49 	iseek(FirstPos, IL_SEEK_SET);
50 
51 	return bRet;
52 }
53 
54 
55 //! Reads from a memory "lump" that contains a TEXTURE
ilLoadTextureL(const void * Lump,ILuint Size)56 ILboolean ilLoadTextureL(const void *Lump, ILuint Size)
57 {
58 	iSetInputLump(Lump, Size);
59 	// From http://forums.totalwar.org/vb/showthread.php?t=70886, all that needs to be done
60 	//  is to strip out the first 48 bytes, and then it is DDS data.
61 	iseek(48, IL_SEEK_CUR);
62 	return ilLoadDdsL(Lump, Size);
63 }
64 
65 #endif//IL_NO_TEXTURE
66 
67