@@ -59,6 +59,12 @@ bool D3D11::initialize() {
5959}
6060
6161void D3D11::render_imgui () {
62+ auto draw_data = ImGui::GetDrawData ();
63+
64+ if (draw_data == nullptr ) {
65+ return ;
66+ }
67+
6268 ComPtr<ID3D11DeviceContext> context{};
6369 float clear_color[]{0 .0f , 0 .0f , 0 .0f , 0 .0f };
6470
@@ -67,14 +73,23 @@ void D3D11::render_imgui() {
6773 device->GetImmediateContext (&context);
6874 context->ClearRenderTargetView (this ->rt_rtv .Get (), clear_color);
6975 context->OMSetRenderTargets (1 , this ->rt_rtv .GetAddressOf (), NULL );
70- ImGui_ImplDX11_RenderDrawData (ImGui::GetDrawData () );
76+ ImGui_ImplDX11_RenderDrawData (draw_data );
7177
7278 // Set the back buffer to be the render target.
7379 context->OMSetRenderTargets (1 , this ->bb_rtv .GetAddressOf (), nullptr );
74- ImGui_ImplDX11_RenderDrawData (ImGui::GetDrawData () );
80+ ImGui_ImplDX11_RenderDrawData (draw_data );
7581}
7682
7783void D3D11::render_imgui_vr (ID3D11DeviceContext* context, ID3D11RenderTargetView* rtv) {
84+ if (context == nullptr || rtv == nullptr ) {
85+ return ;
86+ }
87+
88+ auto draw_data = ImGui::GetDrawData ();
89+ if (draw_data == nullptr ) {
90+ return ;
91+ }
92+
7893 context->OMSetRenderTargets (1 , &rtv, NULL );
79- ImGui_ImplDX11_RenderDrawData (ImGui::GetDrawData () );
94+ ImGui_ImplDX11_RenderDrawData (draw_data );
8095}
0 commit comments