Rev 5 | Rev 9 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 6 | ||
---|---|---|---|
Line 179... | Line 179... | ||
179 | static sprite_t *sprites = NULL; |
179 | static sprite_t *sprites = NULL; |
180 | static int sprite_count = 0; |
180 | static int sprite_count = 0; |
181 | static const float fov_value = 45.0f; // field of view width, in degrees |
181 | static const float fov_value = 45.0f; // field of view width, in degrees |
182 | static const float viewdist_near = 1.0f; // nearest view plane distance |
182 | static const float viewdist_near = 1.0f; // nearest view plane distance |
183 | static const float viewdist_far = 200.0f; // farthest view plane distance |
183 | static const float viewdist_far = 200.0f; // farthest view plane distance |
184 | static int initial_width = 0; // initial width of the render surface, in pixels |
184 | static int initial_width = 0; // initial width of the render surface, in pixels (typically equal to the max displayable size) |
185 | static int initial_height = 0; // initial height of the render surface, in pixels |
185 | static int initial_height = 0; // initial height of the render surface, in pixels (typically equal to the max displayable size) |
186 | static float current_width = 0.0f; // current width of the client area on which the render surface is rendered, in pixels |
186 | static float current_width = 0.0f; // current width of the client area on which the render surface is rendered, in pixels |
187 | static float current_height = 0.0f; // current height of the client area on which the render surface is rendered, in pixels |
187 | static float current_height = 0.0f; // current height of the client area on which the render surface is rendered, in pixels |
188 | static D3DCOLOR ambient_light; |
188 | static D3DCOLOR ambient_light; |
189 | static vector_t camera_position; |
189 | static vector_t camera_position; |
190 | static const vector_t scene_center = { 0.0f, 0.0f, 0.0f }; |
190 | static const vector_t scene_center = { 0.0f, 0.0f, 0.0f }; |
Line 225... | Line 225... | ||
225 | wchar_t errorfile_path[MAX_PATH]; |
225 | wchar_t errorfile_path[MAX_PATH]; |
226 | wchar_t line_buffer[256]; |
226 | wchar_t line_buffer[256]; |
227 | material_t material; |
227 | material_t material; |
228 | HRESULT ret; |
228 | HRESULT ret; |
229 | RECT rect; |
229 | RECT rect; |
- | 230 | RECT viewport_rect; |
|
230 | FILE *fp; |
231 | FILE *fp; |
231 | 232 | ||
232 | // create the Direct3D interface |
233 | // create the Direct3D interface |
233 | d3d = Direct3DCreate9 (D3D_SDK_VERSION); |
234 | d3d = Direct3DCreate9 (D3D_SDK_VERSION); |
234 | 235 | ||
Line 263... | Line 264... | ||
263 | { |
264 | { |
264 | d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; // do not use multisampling (full scene antialiasing) |
265 | d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; // do not use multisampling (full scene antialiasing) |
265 | d3dpp.MultiSampleQuality = 0; |
266 | d3dpp.MultiSampleQuality = 0; |
266 | } |
267 | } |
267 | 268 | ||
- | 269 | // get main window's current rectangle and full screen size |
|
- | 270 | GetWindowRect (hMainWnd, &rect); |
|
- | 271 | ||
268 | // create a device class using this information and the info from the d3dpp stuct |
272 | // create a device class using this information and the info from the d3dpp stuct. Resize the window to the max displayable |
- | 273 | // size before creating the DirectX device, so as to guarantee the viewport will never be upscaled in case of window resize. |
|
- | 274 | MoveWindow (hMainWnd, rect.left, rect.top, GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN), false); |
|
269 | if (FAILED (ret = d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
275 | if (FAILED (ret = d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
270 | { |
276 | { |
271 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
277 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
272 | 278 | ||
273 | // on error, write a log file on the user's desktop |
279 | // on error, write a log file on the user's desktop |
Line 368... | Line 374... | ||
368 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotWriteToLogFile"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
374 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotWriteToLogFile"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
369 | 375 | ||
370 | return (false); |
376 | return (false); |
371 | } |
377 | } |
372 | 378 | ||
373 | // |
379 | // save the viewport's width and height |
374 | GetClientRect (hMainWnd, & |
380 | GetClientRect (hMainWnd, &viewport_rect); |
- | 381 | initial_width = viewport_rect.right; |
|
- | 382 | initial_height = viewport_rect.bottom; |
|
- | 383 | ||
375 |
|
384 | // now resize the window to its original size |
376 |
|
385 | MoveWindow (hMainWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, false); |
377 | 386 | ||
378 | // set the texture parameters |
387 | // set the texture parameters |
379 | d3ddev->SetSamplerState (0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); // wrap textures around their edges |
388 | d3ddev->SetSamplerState (0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); // wrap textures around their edges |
380 | d3ddev->SetSamplerState (0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); |
389 | d3ddev->SetSamplerState (0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); |
381 | d3ddev->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); // and modulate their alpha with the material's alpha |
390 | d3ddev->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); // and modulate their alpha with the material's alpha |