Mercurial > mm7
annotate Engine/Graphics/Texture.h @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | dd36326a9994 |
children |
rev | line source |
---|---|
2496 | 1 #pragma once |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
2 #include "Engine/Engine.h" |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
3 |
2496 | 4 #include <stdio.h> |
2518 | 5 #include <array> |
2496 | 6 |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
7 enum IMAGE_FORMAT |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
8 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
9 IMAGE_FORMAT_R5G6B5 = 0, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
10 IMAGE_FORMAT_A1R5G5B5, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
11 IMAGE_FORMAT_A8R8G8B8, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
12 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
13 IMAGE_NUM_FORMATS, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
14 IMAGE_INVALID_FORMAT = -1, |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
15 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
16 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
17 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
18 inline unsigned int IMAGE_FORMAT_BytesPerPixel(IMAGE_FORMAT format) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
19 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
20 switch (format) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
21 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
22 case IMAGE_FORMAT_R5G6B5: return 2; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
23 case IMAGE_FORMAT_A1R5G5B5: return 2; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
24 case IMAGE_FORMAT_A8R8G8B8: return 4; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
25 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
26 default: |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
27 Error("Invalid format: %d", format); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
28 return 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
29 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
30 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
31 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
32 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
33 struct ImageLoader |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
34 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
35 virtual bool Load(unsigned int *width, unsigned int *height, void **pixels, IMAGE_FORMAT *format) = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
36 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
37 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
38 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
39 |
2574 | 40 class Image |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
41 { |
2574 | 42 public: |
43 inline Image(bool lazy_initialization = true): | |
44 lazy_initialization(lazy_initialization), initialized(false), | |
45 width(0), height(0), native_format(IMAGE_INVALID_FORMAT), | |
46 loader(nullptr) | |
47 { | |
48 for (unsigned int i = 0; i < IMAGE_NUM_FORMATS; ++i) | |
49 pixels[i] = nullptr; | |
50 } | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
51 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
52 |
2574 | 53 bool Image16bit_From_LOD(const wchar_t *name); |
54 bool ColorKey_From_LOD(const wchar_t *name, unsigned __int16 colorkey); | |
55 bool Alpha_From_LOD(const wchar_t *name); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
56 |
2574 | 57 bool PCX_From_IconsLOD(const wchar_t *name); |
58 bool PCX_From_NewLOD(const wchar_t *name); | |
59 bool PCX_From_File(const wchar_t *filename); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
60 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
61 |
2574 | 62 unsigned int GetWidth(); |
63 unsigned int GetHeight(); | |
64 const void *GetPixels(IMAGE_FORMAT format); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
65 |
2574 | 66 bool Release(); |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
67 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
68 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
69 protected: |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
70 bool lazy_initialization; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
71 bool initialized; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
72 ImageLoader *loader; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
73 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
74 unsigned int width; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
75 unsigned int height; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
76 IMAGE_FORMAT native_format; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
77 void *pixels[IMAGE_NUM_FORMATS]; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
78 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
79 bool LoadImageData(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
80 }; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
81 |
2496 | 82 |
83 | |
84 /* 194 */ | |
85 #pragma pack(push, 1) | |
86 struct RGBTexture | |
87 { | |
88 RGBTexture(); | |
89 void Release(); | |
90 int LoadPCXFile(const char *Filename, unsigned int a3); | |
91 unsigned int LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile); | |
92 int DecodePCX(char *pPcx, unsigned __int16 *pOutPixels, unsigned int uNumPixels); | |
93 int Load(const char *pContainer, int mode); | |
94 int Reload(const char *pContainer); | |
95 | |
96 char pName[16]; | |
97 unsigned int uNumPixels; | |
98 unsigned __int16 uWidth; | |
99 unsigned __int16 uHeight; | |
100 __int16 field_18; | |
101 __int16 field_1A; | |
102 __int16 field_1C; | |
103 __int16 field_1E; | |
104 int _allocation_flags; // & 1 - malloc, else custom allocator | |
105 unsigned __int16 *pPixels; | |
2518 | 106 |
107 struct ID3D11ShaderResourceView *d3d11_srv; | |
108 struct D3D11_TEXTURE2D_DESC *d3d11_desc; | |
2496 | 109 }; |
110 #pragma pack(pop) | |
111 | |
112 | |
113 | |
114 #pragma pack(push, 1) | |
2574 | 115 struct Texture_MM7 |
2496 | 116 { |
2574 | 117 Texture_MM7(); |
2496 | 118 void Release(); |
119 void *UnzipPalette(); | |
120 | |
121 char pName[16]; | |
122 unsigned int uSizeOfMaxLevelOfDetail; | |
123 unsigned int uTextureSize; | |
124 unsigned __int16 uTextureWidth; | |
125 unsigned __int16 uTextureHeight; | |
126 __int16 uWidthLn2; | |
127 __int16 uHeightLn2; | |
128 __int16 uWidthMinus1; | |
129 __int16 uHeightMinus1; | |
130 short palette_id1; | |
131 short palette_id2; | |
132 unsigned int uDecompressedSize; | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
133 int pBits; // 0x0002 - generate mipmaps |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
134 // 0x0200 - 0th palette entry is transparent, else colorkey (7FF) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2544
diff
changeset
|
135 unsigned __int8 *paletted_pixels; |
2496 | 136 unsigned __int8 *pLevelOfDetail1; |
2524 | 137 /*unsigned __int8 *pLevelOfDetail2;*/ struct ID3D11ShaderResourceView *d3d11_srv; // replace ol SW stuff with new fields to keep data integrity |
138 /*unsigned __int8 *pLevelOfDetail3;*/ struct D3D11_TEXTURE2D_DESC *d3d11_desc; | |
2496 | 139 unsigned __int16 *pPalette16; |
140 unsigned __int8 *pPalette24; | |
141 }; | |
142 #pragma pack(pop) | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | |
160 /* 323 */ | |
161 enum TEXTURE_FRAME_TABLE_FLAGS | |
162 { | |
163 TEXTURE_FRAME_TABLE_MORE_FRAMES = 0x1, | |
164 TEXTURE_FRAME_TABLE_FIRST = 0x2, | |
165 }; | |
166 | |
167 | |
168 | |
169 /* 41 */ | |
170 #pragma pack(push, 1) | |
171 struct TextureFrame | |
172 { | |
173 char pTextureName[12]; | |
174 __int16 uTextureID; | |
175 __int16 uAnimTime; | |
176 __int16 uAnimLength; | |
177 __int16 uFlags; | |
178 }; | |
179 #pragma pack(pop) | |
180 | |
181 /* 40 */ | |
182 #pragma pack(push, 1) | |
183 struct TextureFrameTable | |
184 { | |
185 //----- (0044D4C9) -------------------------------------------------------- | |
186 inline TextureFrameTable() | |
187 { | |
188 pTextures = 0; | |
189 sNumTextures = 0; | |
190 } | |
191 int FromFileTxt(const char *Args); | |
192 void ToFile(); | |
193 void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); | |
194 void LoadAnimationSequenceAndPalettes(signed int uIconID); | |
195 int GetFrameTexture(int uFrameID, int time); | |
196 signed int FindTextureByName(const char *Str2); | |
197 | |
198 | |
199 signed int sNumTextures; | |
200 struct TextureFrame *pTextures; | |
201 }; | |
202 #pragma pack(pop) | |
203 | |
204 extern struct TextureFrameTable *pTextureFrameTable; | |
205 | |
206 | |
207 | |
208 | |
209 struct OptionsMenuSkin | |
210 { | |
211 OptionsMenuSkin(); | |
212 void Relaease(); | |
213 | |
2574 | 214 class Image *uTextureID_Background; // 507C60 |
215 class Image *uTextureID_TurnSpeed[3]; // 507C64 | |
216 class Image *uTextureID_ArrowLeft; // 507C70 | |
217 class Image *uTextureID_ArrowRight; // 507C74 | |
218 class Image *uTextureID_unused_0; // 507C78 | |
219 class Image *uTextureID_unused_1; // 507C7C | |
220 class Image *uTextureID_unused_2; // 507C80 | |
221 class Image *uTextureID_FlipOnExit; // 507C84 | |
222 class Image *uTextureID_SoundLevels[10]; // 507C88 | |
223 class Image *uTextureID_AlwaysRun; // 507CB0 | |
224 class Image *uTextureID_WalkSound; // 507CB4 | |
225 class Image *uTextureID_ShowDamage; // 507CB8 | |
2496 | 226 }; |
227 extern OptionsMenuSkin options_menu_skin; // 507C60 | |
228 | |
229 | |
230 extern struct stru355 stru_4E82A4;// = {0x20, 0x41, 0, 0x20, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}; moved to texture.h | |
231 extern struct stru355 stru_4EFCBC;// = {0x20, 0x41, 0, 0x10, 0x7C00, 0x3E0, 0x1F, 0x8000}; moved to texture.h | |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | |
238 | |
239 | |
240 | |
241 struct stru355 | |
242 { | |
243 int field_0; | |
244 int field_4; | |
245 int field_8; | |
246 int field_C; | |
247 int field_10; | |
248 int field_14; | |
249 int field_18; | |
250 int field_1C; | |
251 }; | |
252 | |
253 /* 390 */ | |
254 #pragma pack(push, 1) | |
255 struct stru350 | |
256 { | |
257 stru350 *_450DDE(); | |
258 bool _450DF1(const struct stru355 *p1, const struct stru355 *p2); | |
259 unsigned int _450F55(int a2); | |
260 int _450FB1(int a2); | |
261 int sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch, | |
262 unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch, | |
263 int a9, int a10); | |
264 | |
265 struct stru355 field_0; | |
266 struct stru355 field_20; | |
267 int field_40; | |
268 int field_44; | |
269 int field_48; | |
270 int field_4C; | |
271 int field_50; | |
272 int field_54; | |
273 int field_58; | |
274 int field_5C; | |
275 }; | |
276 #pragma pack(pop) | |
277 |