Mercurial > mm7
comparison Render.h @ 2410:2d3c3d1dff0c
added RenderStruct.h
author | Ritor1 |
---|---|
date | Tue, 15 Jul 2014 15:44:45 +0600 |
parents | 82512695b45d |
children | 1d04e48651d4 |
comparison
equal
deleted
inserted
replaced
2409:b29880e9ee79 | 2410:2d3c3d1dff0c |
---|---|
3 #include <cstdint> | 3 #include <cstdint> |
4 #include <cstdio> | 4 #include <cstdio> |
5 | 5 |
6 #include "lib\legacy_dx\d3d.h" | 6 #include "lib\legacy_dx\d3d.h" |
7 #include "OSWindow.h" | 7 #include "OSWindow.h" |
8 #include "RenderStruct.h" | |
8 | 9 |
9 #include "VectorTypes.h" | 10 #include "VectorTypes.h" |
10 | 11 |
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 struct Render | 12 struct Render |
285 { | 13 { |
286 Render(); | 14 Render(); |
287 ~Render(); | 15 ~Render(); |
288 | 16 |
537 void SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height); | 265 void SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height); |
538 | 266 |
539 //int windowed_mode_width; | 267 //int windowed_mode_width; |
540 //int windowed_mode_height; | 268 //int windowed_mode_height; |
541 }; | 269 }; |
542 #pragma pack(pop) | |
543 | |
544 bool PauseGameDrawing(); | |
545 | |
546 extern struct IDirectDrawClipper *pDDrawClipper; | |
547 extern struct Render *pRenderer; // idb | |
548 extern struct pUnkTerrain *Unks; | |
549 | |
550 | |
551 | |
552 /* 248 */ | |
553 #pragma pack(push, 1) | |
554 struct RenderBillboardTransform_local0 | |
555 { | |
556 void *pTarget; | |
557 int *pTargetZ; | |
558 int uScreenSpaceX; | |
559 int uScreenSpaceY; | |
560 int _screenspace_x_scaler_packedfloat; | |
561 int _screenspace_y_scaler_packedfloat; | |
562 char field_18[8]; | |
563 unsigned __int16 *pPalette; | |
564 unsigned __int16 *pPalette2; | |
565 union | |
566 { | |
567 int sZValue; | |
568 struct | |
569 { | |
570 unsigned short object_pid; | |
571 short zbuffer_depth; | |
572 }; | |
573 }; | |
574 unsigned int uFlags; // & 4 - mirror horizontally | |
575 unsigned int uTargetPitch; | |
576 unsigned int uViewportX; | |
577 unsigned int uViewportY; | |
578 unsigned int uViewportZ; | |
579 unsigned int uViewportW; | |
580 int field_44; | |
581 int sParentBillboardID; | |
582 int sTintColor; | |
583 }; | |
584 #pragma pack(pop) | |
585 | |
586 | |
587 | |
588 | |
589 extern int uNumDecorationsDrawnThisFrame; // weak | |
590 extern RenderBillboard pBillboardRenderList[500]; | |
591 extern unsigned int uNumBillboardsToDraw; | |
592 extern int uNumSpritesDrawnThisFrame; // weak | |
593 | |
594 | |
595 | |
596 | |
597 extern RenderVertexSoft array_507D30[50]; | |
598 extern RenderVertexSoft array_50AC10[50]; | |
599 extern RenderVertexSoft array_73D150[20]; | |
600 | |
601 extern RenderVertexD3D3 d3d_vertex_buffer[50]; | |
602 | |
603 | |
604 int ODM_NearClip(unsigned int uVertexID); // idb | |
605 int ODM_FarClip(unsigned int uNumVertices); |