Rev 1 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 2 | ||
---|---|---|---|
Line 220... | Line 220... | ||
220 | 220 | ||
221 | D3DCAPS9 device_capabilities; |
221 | D3DCAPS9 device_capabilities; |
222 | unsigned long behaviour_flags; |
222 | unsigned long behaviour_flags; |
223 | unsigned long best_multisample_type; |
223 | unsigned long best_multisample_type; |
224 | D3DPRESENT_PARAMETERS d3dpp; |
224 | D3DPRESENT_PARAMETERS d3dpp; |
- | 225 | wchar_t errorfile_path[MAX_PATH]; |
|
225 | wchar_t line_buffer[256]; |
226 | wchar_t line_buffer[256]; |
226 | material_t material; |
227 | material_t material; |
- | 228 | HRESULT ret; |
|
227 | RECT rect; |
229 | RECT rect; |
228 | FILE *fp; |
230 | FILE *fp; |
229 | 231 | ||
230 | // create the Direct3D interface |
232 | // create the Direct3D interface |
231 | MessageBox (NULL, L"about to call Direct3dCreate9()", L"info", MB_OK); |
- | |
232 | d3d = Direct3DCreate9 (D3D_SDK_VERSION); |
233 | d3d = Direct3DCreate9 (D3D_SDK_VERSION); |
233 | MessageBox (NULL, L"Direct3dCreate9() call returned", L"info", MB_OK); |
- | |
234 | 234 | ||
235 | // get hardware capabilities |
235 | // get hardware capabilities |
236 | if (FAILED (d3d->GetDeviceCaps (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &device_capabilities))) |
236 | if (FAILED (d3d->GetDeviceCaps (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &device_capabilities))) |
237 | { |
237 | { |
238 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevGetDeviceCapsFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
238 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevGetDeviceCapsFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
239 | return (false); |
239 | return (false); |
240 | } |
240 | } |
241 | MessageBox (NULL, L"GetDeviceCaps() call returned", L"info", MB_OK); |
- | |
242 | 241 | ||
243 | // grab info from that and adjust our D3D settings |
242 | // grab info from that and adjust our D3D settings |
244 | 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); |
245 | 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); |
246 | 245 | ||
Line 250... | Line 249... | ||
250 | { |
249 | { |
251 | best_multisample_type++; // increase multisample type as long as the next one is supported |
250 | best_multisample_type++; // increase multisample type as long as the next one is supported |
252 | if ((best_multisample_type == D3DMULTISAMPLE_2_SAMPLES) && !options.want_hiquality) |
251 | if ((best_multisample_type == D3DMULTISAMPLE_2_SAMPLES) && !options.want_hiquality) |
253 | break; // stop searching for the best one if we don't want the highest possible quality |
252 | break; // stop searching for the best one if we don't want the highest possible quality |
254 | } |
253 | } |
255 | MessageBox (NULL, L"CheckDeviceMultiSampleType() call returned", L"info", MB_OK); |
- | |
256 | 254 | ||
257 | memset (&d3dpp, 0, sizeof (d3dpp)); // clear out the struct for use |
255 | memset (&d3dpp, 0, sizeof (d3dpp)); // clear out the struct for use |
258 | d3dpp.Windowed = true; // always windowed (because we can't display dialog boxes in fullscreen mode) |
256 | d3dpp.Windowed = true; // always windowed (because we can't display dialog boxes in fullscreen mode) |
259 | d3dpp.BackBufferCount = 1; |
257 | d3dpp.BackBufferCount = 1; |
260 | d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames |
258 | d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames |
Line 263... | Line 261... | ||
263 | d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // D3DFMT_D15S1 15 bits should be enough to store each pixel's Z depth |
261 | d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // D3DFMT_D15S1 15 bits should be enough to store each pixel's Z depth |
264 | d3dpp.MultiSampleType = (D3DMULTISAMPLE_TYPE) best_multisample_type; // use multisampling (full scene antialiasing) if supported |
262 | d3dpp.MultiSampleType = (D3DMULTISAMPLE_TYPE) best_multisample_type; // use multisampling (full scene antialiasing) if supported |
265 | d3dpp.MultiSampleQuality = (multisample_quality > 0 ? multisample_quality - 1 : 0); |
263 | d3dpp.MultiSampleQuality = (multisample_quality > 0 ? multisample_quality - 1 : 0); |
266 | 264 | ||
267 | // create a device class using this information and the info from the d3dpp stuct |
265 | // create a device class using this information and the info from the d3dpp stuct |
268 | if (FAILED (d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
266 | if (FAILED (ret = d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hMainWnd, behaviour_flags, &d3dpp, &d3ddev))) |
269 | { |
267 | { |
270 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
268 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotCreateD3DDevCreateDeviceFailed"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
- | 269 | ||
- | 270 | // on error, write a log file on the user's desktop |
|
- | 271 | errorfile_path[0] = 0; |
|
- | 272 | SHGetSpecialFolderPath (NULL, errorfile_path, CSIDL_DESKTOP, true); |
|
- | 273 | wcscat_s (errorfile_path, WCHAR_SIZEOF (errorfile_path), L"\\Chess Giants error.log"); |
|
- | 274 | _wfopen_s (&fp, errorfile_path, L"w, ccs=UNICODE"); |
|
- | 275 | if (fp != NULL) |
|
- | 276 | { |
|
- | 277 | fwprintf (fp, L"device_capabilities.DeviceType = %d\n", device_capabilities.DeviceType); |
|
- | 278 | fwprintf (fp, L"device_capabilities.AdapterOrdinal = %ul\n", device_capabilities.AdapterOrdinal); |
|
- | 279 | fwprintf (fp, L"device_capabilities.Caps = %ul\n", device_capabilities.Caps); |
|
- | 280 | fwprintf (fp, L"device_capabilities.Caps2 = %ul\n", device_capabilities.Caps2); |
|
- | 281 | fwprintf (fp, L"device_capabilities.Caps3 = %ul\n", device_capabilities.Caps3); |
|
- | 282 | fwprintf (fp, L"device_capabilities.PresentationIntervals = %ul\n", device_capabilities.PresentationIntervals); |
|
- | 283 | fwprintf (fp, L"device_capabilities.CursorCaps = %ul\n", device_capabilities.CursorCaps); |
|
- | 284 | fwprintf (fp, L"device_capabilities.DevCaps = %ul\n", device_capabilities.DevCaps); |
|
- | 285 | fwprintf (fp, L"device_capabilities.PrimitiveMiscCaps = %ul\n", device_capabilities.PrimitiveMiscCaps); |
|
- | 286 | fwprintf (fp, L"device_capabilities.RasterCaps = %ul\n", device_capabilities.RasterCaps); |
|
- | 287 | fwprintf (fp, L"device_capabilities.ZCmpCaps = %ul\n", device_capabilities.ZCmpCaps); |
|
- | 288 | fwprintf (fp, L"device_capabilities.SrcBlendCaps = %ul\n", device_capabilities.SrcBlendCaps); |
|
- | 289 | fwprintf (fp, L"device_capabilities.DestBlendCaps = %ul\n", device_capabilities.DestBlendCaps); |
|
- | 290 | fwprintf (fp, L"device_capabilities.AlphaCmpCaps = %ul\n", device_capabilities.AlphaCmpCaps); |
|
- | 291 | fwprintf (fp, L"device_capabilities.ShadeCaps = %ul\n", device_capabilities.ShadeCaps); |
|
- | 292 | fwprintf (fp, L"device_capabilities.TextureCaps = %ul\n", device_capabilities.TextureCaps); |
|
- | 293 | fwprintf (fp, L"device_capabilities.TextureFilterCaps = %ul\n", device_capabilities.TextureFilterCaps); |
|
- | 294 | fwprintf (fp, L"device_capabilities.CubeTextureFilterCaps = %ul\n", device_capabilities.CubeTextureFilterCaps); |
|
- | 295 | fwprintf (fp, L"device_capabilities.VolumeTextureFilterCaps = %ul\n", device_capabilities.VolumeTextureFilterCaps); |
|
- | 296 | fwprintf (fp, L"device_capabilities.TextureAddressCaps = %ul\n", device_capabilities.TextureAddressCaps); |
|
- | 297 | fwprintf (fp, L"device_capabilities.VolumeTextureAddressCaps = %ul\n", device_capabilities.VolumeTextureAddressCaps); |
|
- | 298 | fwprintf (fp, L"device_capabilities.LineCaps = %ul\n", device_capabilities.LineCaps); |
|
- | 299 | fwprintf (fp, L"device_capabilities.MaxTextureWidth = %ul\n", device_capabilities.MaxTextureWidth); |
|
- | 300 | fwprintf (fp, L"device_capabilities.MaxTextureHeight = %ul\n", device_capabilities.MaxTextureHeight); |
|
- | 301 | fwprintf (fp, L"device_capabilities.MaxVolumeExtent = %ul\n", device_capabilities.MaxVolumeExtent); |
|
- | 302 | fwprintf (fp, L"device_capabilities.MaxTextureRepeat = %ul\n", device_capabilities.MaxTextureRepeat); |
|
- | 303 | fwprintf (fp, L"device_capabilities.MaxTextureAspectRatio = %ul\n", device_capabilities.MaxTextureAspectRatio); |
|
- | 304 | fwprintf (fp, L"device_capabilities.MaxAnisotropy = %ul\n", device_capabilities.MaxAnisotropy); |
|
- | 305 | fwprintf (fp, L"device_capabilities.MaxVertexW = %f\n", device_capabilities.MaxVertexW); |
|
- | 306 | fwprintf (fp, L"device_capabilities.GuardBandLeft = %f\n", device_capabilities.GuardBandLeft); |
|
- | 307 | fwprintf (fp, L"device_capabilities.GuardBandTop = %f\n", device_capabilities.GuardBandTop); |
|
- | 308 | fwprintf (fp, L"device_capabilities.GuardBandRight = %f\n", device_capabilities.GuardBandRight); |
|
- | 309 | fwprintf (fp, L"device_capabilities.GuardBandBottom = %f\n", device_capabilities.GuardBandBottom); |
|
- | 310 | fwprintf (fp, L"device_capabilities.ExtentsAdjust = %f\n", device_capabilities.ExtentsAdjust); |
|
- | 311 | fwprintf (fp, L"device_capabilities.StencilCaps = %ul\n", device_capabilities.StencilCaps); |
|
- | 312 | fwprintf (fp, L"device_capabilities.FVFCaps = %ul\n", device_capabilities.FVFCaps); |
|
- | 313 | fwprintf (fp, L"device_capabilities.TextureOpCaps = %ul\n", device_capabilities.TextureOpCaps); |
|
- | 314 | fwprintf (fp, L"device_capabilities.MaxTextureBlendStages = %ul\n", device_capabilities.MaxTextureBlendStages); |
|
- | 315 | fwprintf (fp, L"device_capabilities.MaxSimultaneousTextures = %ul\n", device_capabilities.MaxSimultaneousTextures); |
|
- | 316 | fwprintf (fp, L"device_capabilities.VertexProcessingCaps = %ul\n", device_capabilities.VertexProcessingCaps); |
|
- | 317 | fwprintf (fp, L"device_capabilities.MaxActiveLights = %ul\n", device_capabilities.MaxActiveLights); |
|
- | 318 | fwprintf (fp, L"device_capabilities.MaxUserClipPlanes = %ul\n", device_capabilities.MaxUserClipPlanes); |
|
- | 319 | fwprintf (fp, L"device_capabilities.MaxVertexBlendMatrices = %ul\n", device_capabilities.MaxVertexBlendMatrices); |
|
- | 320 | fwprintf (fp, L"device_capabilities.MaxVertexBlendMatrixIndex = %ul\n", device_capabilities.MaxVertexBlendMatrixIndex); |
|
- | 321 | fwprintf (fp, L"device_capabilities.MaxPointSize = %f\n", device_capabilities.MaxPointSize); |
|
- | 322 | fwprintf (fp, L"device_capabilities.MaxPrimitiveCount = %ul\n", device_capabilities.MaxPrimitiveCount); |
|
- | 323 | fwprintf (fp, L"device_capabilities.MaxVertexIndex = %ul\n", device_capabilities.MaxVertexIndex); |
|
- | 324 | fwprintf (fp, L"device_capabilities.MaxStreams = %ul\n", device_capabilities.MaxStreams); |
|
- | 325 | fwprintf (fp, L"device_capabilities.MaxStreamStride = %ul\n", device_capabilities.MaxStreamStride); |
|
- | 326 | fwprintf (fp, L"device_capabilities.VertexShaderVersion = %ul\n", device_capabilities.VertexShaderVersion); |
|
- | 327 | fwprintf (fp, L"device_capabilities.MaxVertexShaderConst = %ul\n", device_capabilities.MaxVertexShaderConst); |
|
- | 328 | fwprintf (fp, L"device_capabilities.PixelShaderVersion = %ul\n", device_capabilities.PixelShaderVersion); |
|
- | 329 | fwprintf (fp, L"device_capabilities.PixelShader1xMaxValue = %f\n", device_capabilities.PixelShader1xMaxValue); |
|
- | 330 | fwprintf (fp, L"device_capabilities.DevCaps2 = %ul\n", device_capabilities.DevCaps2); |
|
- | 331 | fwprintf (fp, L"device_capabilities.MaxNpatchTessellationLevel = %f\n", device_capabilities.MaxNpatchTessellationLevel); |
|
- | 332 | fwprintf (fp, L"device_capabilities.Reserved5 = %ul\n", device_capabilities.Reserved5); |
|
- | 333 | fwprintf (fp, L"device_capabilities.MasterAdapterOrdinal = %ul\n", device_capabilities.MasterAdapterOrdinal); |
|
- | 334 | fwprintf (fp, L"device_capabilities.AdapterOrdinalInGroup = %ul\n", device_capabilities.AdapterOrdinalInGroup); |
|
- | 335 | fwprintf (fp, L"device_capabilities.NumberOfAdaptersInGroup = %ul\n", device_capabilities.NumberOfAdaptersInGroup); |
|
- | 336 | fwprintf (fp, L"device_capabilities.DeclTypes = %ul\n", device_capabilities.DeclTypes); |
|
- | 337 | fwprintf (fp, L"device_capabilities.NumSimultaneousRTs = %ul\n", device_capabilities.NumSimultaneousRTs); |
|
- | 338 | fwprintf (fp, L"device_capabilities.StretchRectFilterCaps = %ul\n", device_capabilities.StretchRectFilterCaps); |
|
- | 339 | fwprintf (fp, L"device_capabilities.VS20Caps.Caps = %ul\n", device_capabilities.VS20Caps.Caps); |
|
- | 340 | fwprintf (fp, L"device_capabilities.VS20Caps.DynamicFlowControlDepth = %d\n", device_capabilities.VS20Caps.DynamicFlowControlDepth); |
|
- | 341 | fwprintf (fp, L"device_capabilities.VS20Caps.NumTemps = %d\n", device_capabilities.VS20Caps.NumTemps); |
|
- | 342 | fwprintf (fp, L"device_capabilities.VS20Caps.StaticFlowControlDepth = %d\n", device_capabilities.VS20Caps.StaticFlowControlDepth); |
|
- | 343 | fwprintf (fp, L"device_capabilities.PS20Caps.Caps = %ul\n", device_capabilities.PS20Caps.Caps); |
|
- | 344 | fwprintf (fp, L"device_capabilities.PS20Caps.DynamicFlowControlDepth = %d\n", device_capabilities.PS20Caps.DynamicFlowControlDepth); |
|
- | 345 | fwprintf (fp, L"device_capabilities.PS20Caps.NumTemps = %d\n", device_capabilities.PS20Caps.NumTemps); |
|
- | 346 | fwprintf (fp, L"device_capabilities.PS20Caps.StaticFlowControlDepth = %d\n", device_capabilities.PS20Caps.StaticFlowControlDepth); |
|
- | 347 | fwprintf (fp, L"device_capabilities.PS20Caps.NumInstructionSlots = %d\n", device_capabilities.PS20Caps.NumInstructionSlots); |
|
- | 348 | fwprintf (fp, L"device_capabilities.VertexTextureFilterCaps = %ul\n", device_capabilities.VertexTextureFilterCaps); |
|
- | 349 | fwprintf (fp, L"device_capabilities.MaxVShaderInstructionsExecuted = %ul\n", device_capabilities.MaxVShaderInstructionsExecuted); |
|
- | 350 | fwprintf (fp, L"device_capabilities.MaxPShaderInstructionsExecuted = %ul\n", device_capabilities.MaxPShaderInstructionsExecuted); |
|
- | 351 | fwprintf (fp, L"device_capabilities.MaxVertexShader30InstructionSlots = %ul\n", device_capabilities.MaxVertexShader30InstructionSlots); |
|
- | 352 | fwprintf (fp, L"device_capabilities.MaxPixelShader30InstructionSlots = %ul\n", device_capabilities.MaxPixelShader30InstructionSlots); |
|
- | 353 | fwprintf (fp, L"========\n"); |
|
- | 354 | fwprintf (fp, L"(guessed) behaviour_flags = %ul\n", behaviour_flags); |
|
- | 355 | fwprintf (fp, L"(guessed) d3dpp.MultiSampleType = %d\n", best_multisample_type); |
|
- | 356 | fwprintf (fp, L"(guessed) d3dpp.MultiSampleQuality = %d\n", (multisample_quality > 0 ? multisample_quality - 1 : 0)); |
|
- | 357 | fwprintf (fp, L"========\n"); |
|
- | 358 | fwprintf (fp, L"d3d->CreateDevice() returned %d\n", (int) ret); |
|
- | 359 | fclose (fp); |
|
- | 360 | ||
- | 361 | MessageBox (NULL, LOCALIZE (L"Error_GameCouldNotStartPleaseSendLogToAuthor"), LOCALIZE (L"Information"), MB_ICONINFORMATION | MB_OK); |
|
- | 362 | } |
|
- | 363 | else |
|
- | 364 | MessageBox (NULL, LOCALIZE (L"Error_CouldNotWriteToLogFile"), LOCALIZE (L"FatalError"), MB_ICONERROR | MB_OK); |
|
- | 365 | ||
271 | return (false); |
366 | return (false); |
272 | } |
367 | } |
273 | MessageBox (NULL, L"CreateDevice() call returned", L"info", MB_OK); |
- | |
274 | 368 | ||
275 | // get the device view port and save the initial width and height |
369 | // get the device view port and save the initial width and height |
276 | GetClientRect (hMainWnd, &rect); |
370 | GetClientRect (hMainWnd, &rect); |
277 | initial_width = rect.right; // they may differ from window width and window height |
371 | initial_width = rect.right; // they may differ from window width and window height |
278 | initial_height = rect.bottom; // because of title bars, menus, borders, etc. |
372 | initial_height = rect.bottom; // because of title bars, menus, borders, etc. |
Line 306... | Line 400... | ||
306 | d3ddev->SetRenderState (D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); |
400 | d3ddev->SetRenderState (D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL); |
307 | d3ddev->SetRenderState (D3DRS_COLORVERTEX, false); |
401 | d3ddev->SetRenderState (D3DRS_COLORVERTEX, false); |
308 | 402 | ||
309 | // enable 3D lighting |
403 | // enable 3D lighting |
310 | d3ddev->SetRenderState (D3DRS_LIGHTING, true); |
404 | d3ddev->SetRenderState (D3DRS_LIGHTING, true); |
311 | MessageBox (NULL, L"SetRenderState() calls returned", L"info", MB_OK); |
- | |
312 | 405 | ||
313 | // open and parse the materials file and build the materials list |
406 | // open and parse the materials file and build the materials list |
314 | materials = NULL; |
407 | materials = NULL; |
315 | material_count = 0; |
408 | material_count = 0; |
316 | _wfopen_s (&fp, L"materials.cfg", L"r, ccs=UNICODE"); |
409 | _wfopen_s (&fp, L"materials.cfg", L"r, ccs=UNICODE"); |