调用回调函数 DXUTCreateDevice() 后,DXUTgui.cpp 断言检查返回错误。断言说首先调用 CDXUTDialog::Init() 但我应该把它放在 WinMain() 哪里?
问问题
49 次
1 回答
0
将您的 DXUT 客户端代码与EmptyProject和SimpleSample的内容进行比较——假设您使用的是来自GitHub的 DXUT11 。
典型的模式是创建一个全局变量 for CDXUTDialogResourceManager
,然后在你得到回调之前调用CDXUTDialog::Init
fromInitApp
DXUTCreateDevice
int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow )
{
// Enable run-time memory check for debug builds.
#ifdef _DEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
// DXUT will create and use the best device
// that is available on the system depending on which D3D callbacks are set below
// Set DXUT callbacks
DXUTSetCallbackMsgProc( MsgProc );
DXUTSetCallbackKeyboard( OnKeyboard );
DXUTSetCallbackFrameMove( OnFrameMove );
DXUTSetCallbackDeviceChanging( ModifyDeviceSettings );
DXUTSetCallbackD3D11DeviceAcceptable( IsD3D11DeviceAcceptable );
DXUTSetCallbackD3D11DeviceCreated( OnD3D11CreateDevice );
DXUTSetCallbackD3D11SwapChainResized( OnD3D11ResizedSwapChain );
DXUTSetCallbackD3D11SwapChainReleasing( OnD3D11ReleasingSwapChain );
DXUTSetCallbackD3D11DeviceDestroyed( OnD3D11DestroyDevice );
DXUTSetCallbackD3D11FrameRender( OnD3D11FrameRender );
InitApp(); <-- // THIS IS WHERE DXUT GUI WIDGETS GET INITIALIZED, BEFORE THE WINDOW OR DEVICE IS CREATED
DXUTInit( true, true, nullptr ); // Parse the command line, show msgboxes on error, no extra command line params
DXUTSetCursorSettings( true, true );
DXUTCreateWindow( L"SimpleSample11" );
// Only require 10-level hardware, change to D3D_FEATURE_LEVEL_11_0 to require 11-class hardware
// Switch to D3D_FEATURE_LEVEL_9_x for 10level9 hardware
DXUTCreateDevice( D3D_FEATURE_LEVEL_10_0, true, 800, 600 );
DXUTMainLoop(); // Enter into the DXUT render loop
return DXUTGetExitCode();
}
不建议使用 DXUT 启动新项目。它实际上仅用于维护依赖于 DXUT 的现有代码,同时删除对 D3DX11 和其他旧版 DirectX SDK 内容的依赖。DXUT 的绝大多数功能对于大多数应用程序来说都是多余的。它也是越野车,实际上仅适用于样品。
于 2016-02-22T05:00:38.320 回答