This project has moved and is read-only. For the latest updates, please go here.
3

Closed

Provide a C++ virtual method model instead of C callbacks

description

DXUT follows the 'glut' style of using C callback functions to hook up the application with the framework. This design choice has often bother C++ developers used to using inheritance and overriding virtual methods instead.

In order to support the goal of easy porting of existing samples to this framework, I have retained the original C callback style.

However, it should be reasonably easy to write a C++ wrapper around these that would provide a more natural C++-style class model instead.
Closed Jun 16, 2015 at 8:17 PM by walbourn
A better solution is to make use of the Direct3D Win32 VS template and DirectX Tool Kit for a "modern C++" framework. http://blogs.msdn.com/b/chuckw/archive/2015/01/06/direct3d-win32-game-visual-studio-template.aspx

The real value in maintaining DXUT is to make it possible to keep older educational samples alive which were all written with the C-style callbacks.

comments

walbourn wrote Sep 10, 2013 at 1:40 AM

Here are the existing C-style callbacks

```DXUTSetCallbackFrameMove, LPDXUTCALLBACKFRAMEMOVEDXUTSetCallbackKeyboard, LPDXUTCALLBACKKEYBOARDDXUTSetCallbackMouse. LPDXUTCALLBACKMOUSEDXUTSetCallbackMsgProc, LPDXUTCALLBACKMSGPROCDXUTSetCallbackDeviceChanging, LPDXUTCALLBACKMODIFYDEVICESETTINGSDXUTSetCallbackDeviceRemoved, LPDXUTCALLBACKDEVICEREMOVEDDXUTSetCallbackD3D11DeviceAcceptable, LPDXUTCALLBACKISD3D11DEVICEACCEPTABLEDXUTSetCallbackD3D11DeviceCreated, LPDXUTCALLBACKD3D11DEVICECREATEDDXUTSetCallbackD3D11SwapChainResized, LPDXUTCALLBACKD3D11SWAPCHAINRESIZEDDXUTSetCallbackD3D11FrameRender. LPDXUTCALLBACKD3D11FRAMERENDERDXUTSetCallbackD3D11SwapChainReleasing, LPDXUTCALLBACKD3D11SWAPCHAINRELEASINGDXUTSetCallbackD3D11DeviceDestroyed. LPDXUTCALLBACKD3D11DEVICEDESTROYED

walbourn wrote Sep 10, 2013 at 8:16 AM

The primary drawback to adding the C++ version is that would likely obscure the simplicity of the existing samples. While I agree it's a little odd to be using C++11 language constructs in a sample that is using a C-style callback API and global variables, it does have the advantage of being pretty simple.

That said, a C++ wrapper that could be used instead is pretty trivial to implement...

kubera wrote Aug 17, 2014 at 10:29 AM

I remember, that DUXT used to work with classes.Maybe it does not matter, how it is done.In my opinion both methods are correct.