2496
|
1 #pragma once
|
|
2
|
|
3 #include <cstdint>
|
|
4 #include <cstdio>
|
|
5
|
|
6 #include "lib\legacy_dx\d3d.h"
|
|
7 #include "OSWindow.h"
|
|
8
|
2499
|
9 #include "../VectorTypes.h"
|
2496
|
10
|
|
11
|
|
12 #define ErrD3D(hr) \
|
|
13 do \
|
|
14 { \
|
|
15 extern void ErrHR(HRESULT, const char *, const char *, const char *, int); \
|
|
16 ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__); \
|
|
17 } while(0)
|
|
18
|
|
19 struct Polygon;
|
|
20 struct Texture;
|
|
21 struct RGBTexture;
|
|
22 struct RenderBillboardTransform_local0;
|
|
23 struct ODMFace;
|
|
24
|
|
25
|
|
26 unsigned __int16 Color16(unsigned __int32 r, unsigned __int32 g, unsigned __int32 b);
|
|
27 unsigned __int32 Color32(unsigned __int16 color16);
|
2523
|
28 unsigned __int32 Color32_SwapRedBlue(unsigned __int16 color16);
|
2496
|
29
|
|
30 /* 119 */
|
|
31 #pragma pack(push, 1)
|
|
32 struct RenderVertexSoft
|
|
33 {
|
|
34 inline RenderVertexSoft():
|
|
35 flt_2C(0.0f)
|
|
36 {}
|
|
37
|
|
38 Vec3_float_ vWorldPosition;
|
|
39 Vec3_float_ vWorldViewPosition;
|
|
40 float vWorldViewProjX;
|
|
41 float vWorldViewProjY;
|
|
42 float _rhw;
|
|
43 float u;
|
|
44 float v;
|
|
45 float flt_2C;
|
|
46 };
|
|
47 #pragma pack(pop)
|
|
48
|
|
49
|
|
50
|
|
51 /* 112 */
|
|
52 #pragma pack(push, 1)
|
|
53 struct RenderVertexD3D3
|
|
54 {
|
|
55 Vec3_float_ pos;
|
|
56 float rhw;
|
|
57 signed int diffuse;
|
|
58 unsigned int specular;
|
|
59 Vec2_float_ texcoord;
|
|
60 };
|
|
61 #pragma pack(pop)
|
|
62
|
|
63 class Sprite;
|
|
64 class SpriteFrame;
|
|
65
|
|
66 /* 161 */
|
|
67 #pragma pack(push, 1)
|
|
68 struct RenderBillboard
|
|
69 {
|
|
70 int _screenspace_x_scaler_packedfloat;
|
|
71 int _screenspace_y_scaler_packedfloat;
|
|
72 float fov_x;
|
|
73 float fov_y;
|
|
74 union
|
|
75 {
|
|
76 int sZValue;
|
|
77 struct
|
|
78 {
|
|
79 unsigned __int16 object_pid;
|
|
80 signed __int16 actual_z;
|
|
81 };
|
|
82 };
|
|
83 int field_14_actor_id;
|
|
84 signed __int16 HwSpriteID;
|
|
85 __int16 uPalette;
|
|
86 __int16 uIndoorSectorID;
|
|
87 __int16 field_1E;
|
|
88 __int16 world_x;
|
|
89 __int16 world_y;
|
|
90 __int16 world_z;
|
|
91 __int16 uScreenSpaceX;
|
|
92 __int16 uScreenSpaceY;
|
|
93 unsigned __int16 dimming_level;
|
|
94 signed int sTintColor;
|
|
95 SpriteFrame *pSpriteFrame;
|
|
96
|
|
97 inline float GetFloatZ() const
|
|
98 {
|
|
99 return (float)object_pid / 65535.0f + (float)actual_z;
|
|
100 }
|
|
101 };
|
|
102 #pragma pack(pop)
|
|
103
|
|
104
|
|
105 #pragma pack(push, 1)
|
|
106 struct RenderD3D__DevInfo
|
|
107 {
|
|
108 unsigned int bIsDeviceCompatible;
|
|
109 char *pName;
|
|
110 char *pDescription;
|
|
111 GUID *pGUID;
|
|
112 unsigned int uCaps;
|
|
113 char *pDriverName;
|
|
114 char *pDeviceDesc;
|
|
115 char *pDDraw4DevDesc;
|
|
116 GUID *pDirectDrawGUID;
|
|
117 int uVideoMem;
|
|
118 };
|
|
119 #pragma pack(pop)
|
|
120
|
|
121
|
|
122
|
|
123 #pragma pack(push, 1)
|
|
124 struct RenderD3D_D3DDevDesc
|
|
125 {
|
|
126 int field_0;
|
|
127 int field_4;
|
|
128 int field_8;
|
|
129 int field_C;
|
|
130 int field_10;
|
|
131 char *pDriverName;
|
|
132 char *pDeviceDesc;
|
|
133 char *pDDraw4DevDesc;
|
|
134 GUID *pGUID;
|
|
135 unsigned int uVideoMem;
|
|
136 };
|
|
137 #pragma pack(pop)
|
|
138
|
|
139
|
|
140
|
|
141
|
|
142
|
|
143
|
|
144
|
|
145
|
|
146
|
|
147 /* 280 */
|
|
148 #pragma pack(push, 1)
|
|
149 struct HWLTexture
|
|
150 {
|
|
151 inline HWLTexture():
|
|
152 field_0(0), field_4(0), field_8(0),
|
|
153 field_C(0), field_10(0), field_14(0)
|
|
154 {}
|
|
155
|
|
156 int field_0;
|
|
157 int field_4;
|
|
158 int field_8;
|
|
159 int field_C;
|
|
160 int field_10;
|
|
161 int field_14;
|
|
162 int uBufferWidth;
|
|
163 int uBufferHeight;
|
|
164 int uAreaWidth;
|
|
165 int uAreaHeigth;
|
|
166 unsigned int uWidth;
|
|
167 unsigned int uHeight;
|
|
168 int uAreaX;
|
|
169 int uAreaY;
|
|
170 unsigned __int16 *pPixels;
|
|
171 };
|
|
172 #pragma pack(pop)
|
|
173
|
|
174
|
|
175 /* 185 */
|
|
176 #pragma pack(push, 1)
|
|
177 struct RenderHWLContainer
|
|
178 {
|
|
179 RenderHWLContainer();
|
|
180 bool Load(const wchar_t *pFilename);
|
|
181 bool Release();
|
|
182
|
|
183 HWLTexture *LoadTexture(const char *pName, int bMipMaps);
|
|
184
|
|
185 FILE *pFile;
|
|
186 uint32_t uSignature;
|
|
187 unsigned int uDataOffset;
|
|
188 unsigned int uNumItems;
|
|
189 char *pSpriteNames[50000];
|
|
190 int pSpriteOffsets[50000];
|
|
191 int bDumpDebug;
|
|
192 int scale_hwls_to_half;
|
|
193 };
|
|
194 #pragma pack(pop)
|
|
195
|
|
196
|
|
197
|
|
198 /* 242 */
|
|
199 #pragma pack(push, 1)
|
|
200 struct RenderBillboardD3D
|
|
201 {
|
|
202 inline RenderBillboardD3D():
|
|
203 opacity(Transparent),
|
|
204 field_90(-1),
|
|
205 sParentBillboardID(-1),
|
|
206 uNumVertices(4)
|
|
207 {}
|
|
208
|
|
209 enum OpacityType: unsigned __int32
|
|
210 {
|
|
211 Transparent = 0,
|
|
212 Opaque_1 = 1,
|
|
213 Opaque_2 = 2,
|
|
214 Opaque_3 = 3,
|
|
215 NoBlend = 0xFFFFFFFF
|
|
216 };
|
|
217
|
|
218 IDirect3DTexture2 *pTexture;
|
|
219 unsigned int uNumVertices;
|
|
220 RenderVertexD3D3 pQuads[4];
|
|
221 float z_order;
|
|
222 OpacityType opacity;
|
|
223 int field_90;
|
|
224 int sZValue;
|
|
225 signed int sParentBillboardID;
|
|
226 };
|
|
227 #pragma pack(pop)
|
|
228
|
|
229
|
|
230
|
|
231
|
|
232 #pragma pack(push, 1)
|
|
233 struct RenderD3D_aux
|
|
234 {
|
|
235 RenderD3D__DevInfo *pInfo;
|
|
236 RenderD3D_D3DDevDesc *ptr_4;
|
|
237 };
|
|
238 #pragma pack(pop)
|
|
239
|
|
240
|
|
241
|
|
242 /* 183 */
|
|
243 #pragma pack(push, 1)
|
|
244 class RenderD3D
|
|
245 {
|
|
246 public:
|
|
247 RenderD3D();
|
|
248
|
|
249 void GetAvailableDevices(RenderD3D__DevInfo **pOutDevices);
|
|
250 void Release();
|
|
251 bool CreateDevice(unsigned int uDeviceID, int bWindowed, OSWindow *window);
|
|
252 unsigned int GetDeviceCaps();
|
|
253 void ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear);
|
|
254 void Present(bool bForceBlit);
|
|
255 bool CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim);
|
|
256 void HandleLostResources();
|
|
257
|
|
258
|
|
259 unsigned int bWindowed;
|
|
260 int field_4;
|
|
261 int field_8;
|
|
262 HWND hWindow;
|
|
263 int field_10;
|
|
264 int field_14;
|
|
265 int field_18;
|
|
266 RenderD3D__DevInfo *pAvailableDevices;
|
|
267 IDirectDraw4 *pHost;
|
|
268 IDirect3D3 *pDirect3D;
|
|
269 IUnknown *pUnk;
|
|
270 IDirectDrawSurface4 *pBackBuffer;
|
|
271 IDirectDrawSurface4 *pFrontBuffer;
|
|
272 IDirectDrawSurface4 *pZBuffer;
|
|
273 IDirect3DDevice3 *pDevice;
|
|
274 IDirect3DViewport3 *pViewport;
|
|
275 int field_40;
|
|
276 int field_44;
|
|
277 char pErrorMessage[48];
|
|
278 char field_78[208];
|
|
279 };
|
|
280 #pragma pack(pop)
|
|
281 extern struct RenderVertexD3D3 pVertices[50];
|
|
282
|
|
283 /* 182 */
|
|
284 #pragma pack(push, 1)
|
|
285
|
|
286 #pragma pack(pop)
|
|
287
|
|
288 bool PauseGameDrawing();
|
|
289
|
|
290 extern struct IDirectDrawClipper *pDDrawClipper;
|
|
291 extern struct IRender *pRenderer; // idb
|
|
292 extern struct pUnkTerrain *Unks;
|
|
293
|
|
294
|
|
295
|
|
296 /* 248 */
|
|
297 #pragma pack(push, 1)
|
|
298 struct RenderBillboardTransform_local0
|
|
299 {
|
|
300 void *pTarget;
|
|
301 int *pTargetZ;
|
|
302 int uScreenSpaceX;
|
|
303 int uScreenSpaceY;
|
|
304 int _screenspace_x_scaler_packedfloat;
|
|
305 int _screenspace_y_scaler_packedfloat;
|
|
306 char field_18[8];
|
|
307 unsigned __int16 *pPalette;
|
|
308 unsigned __int16 *pPalette2;
|
|
309 union
|
|
310 {
|
|
311 int sZValue;
|
|
312 struct
|
|
313 {
|
|
314 unsigned short object_pid;
|
|
315 short zbuffer_depth;
|
|
316 };
|
|
317 };
|
|
318 unsigned int uFlags; // & 4 - mirror horizontally
|
|
319 unsigned int uTargetPitch;
|
|
320 unsigned int uViewportX;
|
|
321 unsigned int uViewportY;
|
|
322 unsigned int uViewportZ;
|
|
323 unsigned int uViewportW;
|
|
324 int field_44;
|
|
325 int sParentBillboardID;
|
|
326 int sTintColor;
|
|
327 };
|
|
328 #pragma pack(pop)
|
|
329
|
|
330
|
|
331
|
|
332
|
|
333 extern int uNumDecorationsDrawnThisFrame; // weak
|
|
334 extern RenderBillboard pBillboardRenderList[500];
|
|
335 extern unsigned int uNumBillboardsToDraw;
|
|
336 extern int uNumSpritesDrawnThisFrame; // weak
|
|
337
|
|
338
|
|
339
|
|
340
|
|
341 extern RenderVertexSoft array_507D30[50];
|
|
342 extern RenderVertexSoft array_50AC10[50];
|
|
343 extern RenderVertexSoft array_73D150[20];
|
|
344
|
|
345 extern RenderVertexD3D3 d3d_vertex_buffer[50];
|
|
346
|
|
347
|
|
348 int ODM_NearClip(unsigned int uVertexID); // idb
|
|
349 int ODM_FarClip(unsigned int uNumVertices); |