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