Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

Edit:

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

1 Answer

up vote 0 down vote accepted

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:

http://code.google.com/p/gamecode4/

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

share|improve this answer
    
Yeah, there is a Tutorial how to use DXUT. But it doesn't explain DXUT it self. –  Techie Nov 16 '12 at 18:20
    
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. –  Philip Nov 16 '12 at 22:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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