Rev 2 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 5 | ||
---|---|---|---|
Line 188... | Line 188... | ||
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 }; |
191 | static const vector_t upwards_direction = { 0.0f, 0.0f, 1.0f }; |
191 | static const vector_t upwards_direction = { 0.0f, 0.0f, 1.0f }; |
192 | static int best_supported_filter; |
192 | static int best_supported_filter; |
193 | static |
193 | static bool is_fsaa_supported = false; |
194 | 194 | ||
195 | static wchar_t printf_buffer[0xffff]; |
195 | static wchar_t printf_buffer[0xffff]; |
196 | 196 | ||
197 | 197 | ||
198 | // prototypes of functions used in this module only |
198 | // prototypes of functions used in this module only |
Line 218... | Line 218... | ||
218 | 218 | ||
219 | static wchar_t *default_materialname = L"default"; |
219 | static wchar_t *default_materialname = L"default"; |
220 | 220 | ||
221 | D3DCAPS9 device_capabilities; |
221 | D3DCAPS9 device_capabilities; |
222 | unsigned long behaviour_flags; |
222 | unsigned long behaviour_flags; |
223 | unsigned long |
223 | unsigned long multisample_quality_count; |
224 | D3DPRESENT_PARAMETERS d3dpp; |
224 | D3DPRESENT_PARAMETERS d3dpp; |
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; |
Line 241... | Line 241... | ||
241 | 241 | ||
242 | // grab info from that and adjust our D3D settings |
242 | // grab info from that and adjust our D3D settings |
243 | best_supported_filter = (device_capabilities.RasterCaps & D3DPRASTERCAPS_ANISOTROPY ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR); |
243 | best_supported_filter = (device_capabilities.RasterCaps & D3DPRASTERCAPS_ANISOTROPY ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR); |
244 | behaviour_flags = (device_capabilities.VertexProcessingCaps != 0 ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING); |
244 | behaviour_flags = (device_capabilities.VertexProcessingCaps != 0 ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING); |
245 | 245 | ||
246 | // see if full-scene antialiasing is supported and |
246 | // see if simple (non-maskable) full-scene antialiasing is supported and in how many quality flavors |
247 | best_multisample_type = D3DMULTISAMPLE_NONE; |
- | |
248 |
|
247 | if (SUCCEEDED (d3d->CheckDeviceMultiSampleType (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, false, D3DMULTISAMPLE_NONMASKABLE, &multisample_quality_count))) |
249 | { |
- | |
250 |
|
248 | is_fsaa_supported = true; // remember FSAA is supported |
251 | if ((best_multisample_type == D3DMULTISAMPLE_2_SAMPLES) && !options.want_hiquality) |
- | |
252 | break; // stop searching for the best one if we don't want the highest possible quality |
- | |
253 | } |
- | |
254 | 249 | ||
255 | memset (&d3dpp, 0, sizeof (d3dpp)); // clear out the struct for use |
250 | memset (&d3dpp, 0, sizeof (d3dpp)); // clear out the struct for use |
256 | d3dpp.Windowed = true; // always windowed (because we can't display dialog boxes in fullscreen mode) |
251 | d3dpp.Windowed = true; // always windowed (because we can't display dialog boxes in fullscreen mode) |
257 | d3dpp.BackBufferCount = 1; |
252 | d3dpp.BackBufferCount = 1; |
258 | d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames |
253 | d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames |
259 | d3dpp.hDeviceWindow = hMainWnd; // set the window to be used by Direct3D |
254 | d3dpp.hDeviceWindow = hMainWnd; // set the window to be used by Direct3D |
260 | d3dpp.EnableAutoDepthStencil = true; // enable Z-buffer and stencil buffer |
255 | d3dpp.EnableAutoDepthStencil = true; // enable Z-buffer and stencil buffer |
261 | d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // D3DFMT_D15S1 15 bits should be enough to store each pixel's Z depth |
256 | d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // D3DFMT_D15S1 15 bits should be enough to store each pixel's Z depth |
- | 257 | if (is_fsaa_supported) |
|
- | 258 | { |
|
262 |
|
259 | d3dpp.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; // use multisampling (full scene antialiasing) if supported |
263 | d3dpp.MultiSampleQuality = |
260 | d3dpp.MultiSampleQuality = multisample_quality_count - 1; // use the best available multisample quality |
- | 261 | } |
|
- | 262 | else |
|
- | 263 | { |
|
- | 264 | d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; // do not use multisampling (full scene antialiasing) |
|
- | 265 | d3dpp.MultiSampleQuality = 0; |
|
- | 266 | } |
|
264 | 267 | ||
265 | // create a device class using this information and the info from the d3dpp stuct |
268 | // create a device class using this information and the info from the d3dpp stuct |
266 | if (FAILED (ret = d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
269 | if (FAILED (ret = d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
267 | { |
270 | { |
268 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
271 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
Line 350... | Line 353... | ||
350 | fwprintf (fp, L"device_capabilities.MaxPShaderInstructionsExecuted = %ul\n", device_capabilities.MaxPShaderInstructionsExecuted); |
353 | fwprintf (fp, L"device_capabilities.MaxPShaderInstructionsExecuted = %ul\n", device_capabilities.MaxPShaderInstructionsExecuted); |
351 | fwprintf (fp, L"device_capabilities.MaxVertexShader30InstructionSlots = %ul\n", device_capabilities.MaxVertexShader30InstructionSlots); |
354 | fwprintf (fp, L"device_capabilities.MaxVertexShader30InstructionSlots = %ul\n", device_capabilities.MaxVertexShader30InstructionSlots); |
352 | fwprintf (fp, L"device_capabilities.MaxPixelShader30InstructionSlots = %ul\n", device_capabilities.MaxPixelShader30InstructionSlots); |
355 | fwprintf (fp, L"device_capabilities.MaxPixelShader30InstructionSlots = %ul\n", device_capabilities.MaxPixelShader30InstructionSlots); |
353 | fwprintf (fp, L"========\n"); |
356 | fwprintf (fp, L"========\n"); |
354 | fwprintf (fp, L"(guessed) behaviour_flags = %ul\n", behaviour_flags); |
357 | fwprintf (fp, L"(guessed) behaviour_flags = %ul\n", behaviour_flags); |
- | 358 | fwprintf (fp, L"========\n"); |
|
355 | fwprintf (fp, L" |
359 | fwprintf (fp, L"d3dpp.MultiSampleType = %d\n", d3dpp.MultiSampleType); |
356 | fwprintf (fp, L" |
360 | fwprintf (fp, L"d3dpp.MultiSampleQuality = %d\n", d3dpp.MultiSampleQuality); |
357 | fwprintf (fp, L"========\n"); |
361 | fwprintf (fp, L"========\n"); |
358 | fwprintf (fp, L"d3d->CreateDevice() returned %d\n", (int) ret); |
362 | fwprintf (fp, L"d3d->CreateDevice() returned %d\n", (int) ret); |
359 | fclose (fp); |
363 | fclose (fp); |
360 | 364 | ||
361 | MessageBox (NULL, LOCALIZE (L"Error_GameCouldNotStartPleaseSendLogToAuthor"), LOCALIZE (L"Information"), MB_ICONINFORMATION | MB_OK); |
365 | MessageBox (NULL, LOCALIZE (L"Error_GameCouldNotStartPleaseSendLogToAuthor"), LOCALIZE (L"Information"), MB_ICONINFORMATION | MB_OK); |
Line 643... | Line 647... | ||
643 | d3ddev->SetSamplerState (0, D3DSAMP_MINFILTER, best_supported_filter); |
647 | d3ddev->SetSamplerState (0, D3DSAMP_MINFILTER, best_supported_filter); |
644 | d3ddev->SetSamplerState (0, D3DSAMP_MAGFILTER, best_supported_filter); |
648 | d3ddev->SetSamplerState (0, D3DSAMP_MAGFILTER, best_supported_filter); |
645 | d3ddev->SetSamplerState (0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); |
649 | d3ddev->SetSamplerState (0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); |
646 | 650 | ||
647 | // turn on fullscene antialiasing only if capable |
651 | // turn on fullscene antialiasing only if capable |
648 | d3ddev->SetRenderState (D3DRS_MULTISAMPLEANTIALIAS, |
652 | d3ddev->SetRenderState (D3DRS_MULTISAMPLEANTIALIAS, is_fsaa_supported); |
649 | } |
653 | } |
650 | else |
654 | else |
651 | { |
655 | { |
652 | d3ddev->SetSamplerState (0, D3DSAMP_MINFILTER, D3DTEXF_NONE); |
656 | d3ddev->SetSamplerState (0, D3DSAMP_MINFILTER, D3DTEXF_NONE); |
653 | d3ddev->SetSamplerState (0, D3DSAMP_MAGFILTER, D3DTEXF_NONE); |
657 | d3ddev->SetSamplerState (0, D3DSAMP_MAGFILTER, D3DTEXF_NONE); |