SystemTimeToVariantTime and DirectX

Hello,

I am using VS2005 Pro in XpPro with Sp2. I also have Platform SDK 3790.1830 and DirectX9.0 October 2005 installed.

I have ported our legacy code fromVC++6.0 into VS 2005 (no .NET) and we need to add directX capability.

I started with the BitmapMix sample code to interface with a USB camera in our system. After getting the camera interface working, I have noticed that after calling the function:

hr = m_pD3D->CreateDevice( ...); that the call to ::SystemTimeToVariantTime( ...) is no longer returning the proper time.

Are there known issues with DirectX 9.0 and this function?

thank you
[714 byte] By [drw627] at [2007-12-22]
# 1

The problem is that CreateDevice() by default sets the floating point precision of the CPU to 32-bits, the size of a float, in order to speed up certain operations. For most 3D applications this isn't a problem, but in your case it is because SystemTimeToVariantTime() tries to convert time into a 64-bit double value. The conversion calcuations get rounded to float precision which isn't enough represent the time values correctly.

The solution to the problem is to tell Direct3D not to change the floating point precision by using the D3DCREATE_FPU_PRESERVE flag when creating the device.

RossRidge at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2

That was the problem!

Thank you very much for all your help!

drw627 at 2007-8-30 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...