Hi,
This is actually "by design". MS loong time ago (when vertex processing was done on CPU) decided to automatically reduce FPU precision to single at time of CreateDevice() call. You can avoid this in DXUT based applications creating you own ModifyDeviceSettings() that changes DeviceSettings.BehaviorFlags flag to include D3DCREATE_FPU_PRESERVE flag. This flag is later used while calling pD3D.CreateDevice(pNewDeviceSettings.AdapterOrdinal, pNewDeviceSettings.DeviceType, DXUTGetHWNDFocus, pNewDeviceSettings.BehaviorFlags, @pNewDeviceSettings.pp, pd3dDevice);
Another (quite often recommended) way - is to separate contol logic and draw login in your app. So you recalculate everything and on subroutine with FPUcontrol set to full precision and exceptions enabled (Delphi default) and later disable exceptions and set FP precision to single before calling Direct3D drawing functions (or any other C/C++ code).
-Alexey
PS. Actually just loading DLL can lead to change to FPU control word, so be aware to this too.
Citation:
Hi,
First, I thank you for the DirectX SDK in Delphi. Nice Job !
As I was building my project, I've seen the following strange bug. After calling DXUTCreateDevice, Delphi function Now return a date rounded to ... 5 minutes 37,5 sec. There is a simple way to see this bug :
1. Open the Text3D sample in DirectX 9.0 SDK.
2. In Text3DUnit, line 485 ("Demonstration Part 2"), add the two following lines :
SetRect(rc, 10, nHeight - 15*8, 0, 0);
g_pFont2.DrawTextA(g_pTextSprite, PChar(TimeToStr(500 + Time) + ' <=> ' + TimeToStr(Time)), -1, @rc, DT_NOCLIP, D3DXColorToDWord(D3DXColor( 1.0, 1.0, 1.0, 1.0)));
3. Run the project. Could you explain why the left time value increases by 4 seconds ? If you replace "500 + Time" by "Now", it's worth !
In fact, TDateTime seems to contains a single value not a double as it's defined in SysUtils unit. More over, values of constants in SysUtils lose precision after DXUTCreateDevice (DateDelta lose approximatively 9 minutes).
I don't know if you're able to answer or if you have time to. However, i think you could be interested by this bug.
Bye