I'm trying to programm now a "game", and started with the EmptyProject that's provided by the DirectX SDK. The problem is that the Callbacks are confusing me. Can please someone explain me?


DXUTSetCallbackD3D9DeviceAcceptable( IsD3D9DeviceAcceptable ); // not sure but I think       that's the caps?
DXUTSetCallbackD3D9DeviceLost( OnD3D9LostDevice );
DXUTSetCallbackDeviceChanging( ModifyDeviceSettings );
DXUTSetCallbackFrameMove( OnFrameMove );
  • 2
    \$\begingroup\$ Can you be more specific? Is it a certain call back or simply how callbacks work? \$\endgroup\$ – NtscCobalt Nov 13 '12 at 18:46
  • \$\begingroup\$ he's trying to use the DXUT library and is unclear on the callback functions it needs to operate - longer explanation below \$\endgroup\$ – Philip Nov 13 '12 at 19:24
  • \$\begingroup\$ Wow, what did I wrong? 3 downrates.... \$\endgroup\$ – LaVolpe Nov 14 '12 at 16:18

The DXUT Framework requires you to define a number of functions in order to plug into it. Each of those names - IsD3D9DeviceAcceptable, OnD3D9LostDevice, ModifyDeviceSettings, and OnFrameMove - are functions that YOU need to define in your code. The signatures are as follows:

static bool CALLBACK IsD3D9DeviceAcceptable( D3DCAPS9* PCAPS, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, bool bWindowed, void *pUserContext);

static void CALLBACK OnD3D9LostDevice( void* pUserContext );

static bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, void* pUserContext );

static void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext );

So in the first function you determine if the d3d9 device will work for your program or not, and return true if it does. In the second you tell it what to do if it loses the device (if someone minimizes the screen for instance). In the third you allow the user to change the device settings, and.... I'm actually not too sure about the fourth, I use DXUTOnFrameRender instead.

It's annoying that Microsoft took down the documentation for the DXUT library. If you Google any of those function names you'll find the Japanese version of MSDN, which somehow survived the purge. If you really want a complete example of the DXUT library in use, try the Game Coding Complete code:


The file GameCode4.cpp is the initializer, where they use these function declarations just like you typed them in. The bodies of the user-defined functions are in gamecode.cpp and gamecode.h

I believe the DXUT tutorials are also in the DirectX SDK for DX9

  • \$\begingroup\$ Yeah, there is a Tutorial how to use DXUT. But it doesn't explain DXUT it self. \$\endgroup\$ – LaVolpe Nov 16 '12 at 18:20
  • \$\begingroup\$ Install the June 2010 DirectX SDK, and go to the Samples/C++/Direct3D10/Tutorials/ and look at Tutorials 8-14. These are designed to teach DXUT, but they were taken out of the corresponding Direct3D11 folder for some reason. That's the best I think you can do anymore since MSDN was stripped. \$\endgroup\$ – Philip Nov 16 '12 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.