Rev 81 | Rev 124 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 81 | Rev 116 | ||
---|---|---|---|
Line 210... | Line 210... | ||
210 | static unsigned long HashFile (const wchar_t *file_pathname); |
210 | static unsigned long HashFile (const wchar_t *file_pathname); |
211 | static void ResolveWildcard (wchar_t *file_pathname, wchar_t *extensions_separated_by_bars); |
211 | static void ResolveWildcard (wchar_t *file_pathname, wchar_t *extensions_separated_by_bars); |
212 | static int SortReflectedObjects (const void *object1, const void *object2); |
212 | static int SortReflectedObjects (const void *object1, const void *object2); |
213 | 213 | ||
214 | 214 | ||
215 | bool Render_Init ( |
215 | bool Render_Init (const wchar_t *fmt, ...) |
216 | { |
216 | { |
217 | // this function sets up and initializes Direct3D |
217 | // this function sets up and initializes Direct3D |
218 | 218 | ||
- | 219 | static wchar_t splashscreen_pathname[MAX_PATH]; |
|
219 | static wchar_t *default_materialname = L"default"; |
220 | static wchar_t *default_materialname = L"default"; |
- | 221 | va_list argptr; |
|
220 | 222 | ||
221 | D3DCAPS9 device_capabilities; |
223 | D3DCAPS9 device_capabilities; |
222 | unsigned long behaviour_flags; |
224 | unsigned long behaviour_flags; |
223 | unsigned long multisample_quality_count; |
225 | unsigned long multisample_quality_count; |
224 | D3DPRESENT_PARAMETERS d3dpp; |
226 | D3DPRESENT_PARAMETERS d3dpp; |
Line 227... | Line 229... | ||
227 | material_t material; |
229 | material_t material; |
228 | HRESULT ret; |
230 | HRESULT ret; |
229 | RECT rect; |
231 | RECT rect; |
230 | RECT viewport_rect; |
232 | RECT viewport_rect; |
231 | FILE *fp; |
233 | FILE *fp; |
- | 234 | ||
- | 235 | // concatenate all the arguments in one string |
|
- | 236 | va_start (argptr, fmt); |
|
- | 237 | wvsprintf (splashscreen_pathname, fmt, argptr); |
|
- | 238 | va_end (argptr); |
|
232 | 239 | ||
233 | // create the Direct3D interface |
240 | // create the Direct3D interface |
234 | d3d = Direct3DCreate9 (D3D_SDK_VERSION); |
241 | d3d = Direct3DCreate9 (D3D_SDK_VERSION); |
235 | 242 | ||
236 | // get hardware capabilities |
243 | // get hardware capabilities |
Line 274... | Line 281... | ||
274 | // size before creating the DirectX device, so as to guarantee the viewport will never be upscaled in case of window resize. |
281 | // size before creating the DirectX device, so as to guarantee the viewport will never be upscaled in case of window resize. |
275 | MoveWindow (hMainWnd, rect.left, rect.top, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), false); |
282 | MoveWindow (hMainWnd, rect.left, rect.top, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), false); |
276 | if (FAILED (ret = d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
283 | if (FAILED (ret = d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
277 | { |
284 | { |
278 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
285 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
279 | 286 | ||
280 | // on error, write a log file on the user's desktop |
287 | // on error, write a log file on the user's desktop |
281 | errorfile_path[0] = 0; |
288 | errorfile_path[0] = 0; |
282 | SHGetSpecialFolderPath (NULL, errorfile_path, CSIDL_DESKTOP, true); |
289 | SHGetSpecialFolderPath (NULL, errorfile_path, CSIDL_DESKTOP, true); |
283 | wcscat_s (errorfile_path, WCHAR_SIZEOF (errorfile_path), L"\\Chess Giants error.log"); |
290 | wcscat_s (errorfile_path, WCHAR_SIZEOF (errorfile_path), L"\\Chess Giants error.log"); |
284 | _wfopen_s (&fp, errorfile_path, L"w, ccs=UNICODE"); |
291 | _wfopen_s (&fp, errorfile_path, L"w, ccs=UNICODE"); |
Line 415... | Line 422... | ||
415 | d3ddev->SetRenderState (D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); |
422 | d3ddev->SetRenderState (D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); |
416 | d3ddev->SetRenderState (D3DRS_COLORVERTEX, false); |
423 | d3ddev->SetRenderState (D3DRS_COLORVERTEX, false); |
417 | 424 | ||
418 | // enable 3D lighting |
425 | // enable 3D lighting |
419 | d3ddev->SetRenderState (D3DRS_LIGHTING, true); |
426 | d3ddev->SetRenderState (D3DRS_LIGHTING, true); |
- | 427 | ||
- | 428 | // load the splash screen sprite and display it |
|
- | 429 | int bgsprite_index = Render_LoadSprite (splashscreen_pathname); |
|
- | 430 | d3ddev->Clear (0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_XRGB (0, 0, 0), 1.0f, 0); |
|
- | 431 | d3ddev->BeginScene (); // begins the 3D scene |
|
- | 432 | Render_DrawSprite (&sprites[bgsprite_index], 0.0f, 0.0f, 100.0f, 100.0f, 0xFF); // draw the background sprite |
|
- | 433 | d3ddev->EndScene (); // ends the 3D scene |
|
- | 434 | d3ddev->Present (NULL, NULL, NULL, NULL); // displays the created frame on the screen |
|
420 | 435 | ||
421 | // open and parse the materials file and build the materials list |
436 | // open and parse the materials file and build the materials list |
422 | materials = NULL; |
437 | materials = NULL; |
423 | material_count = 0; |
438 | material_count = 0; |
424 | _wfopen_s (&fp, L"materials.cfg", L"r, ccs=UNICODE"); |
439 | _wfopen_s (&fp, L"materials.cfg", L"r, ccs=UNICODE"); |