@@ -303,7 +303,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
303303 ctx->IASetInputLayout (old.InputLayout ); if (old.InputLayout ) old.InputLayout ->Release ();
304304}
305305
306- static void ImGui_ImplDX11_CreateFontsTexture ()
306+ static bool ImGui_ImplDX11_CreateFontsTexture ()
307307{
308308 // Build texture atlas
309309 ImGuiIO& io = ImGui::GetIO ();
@@ -331,8 +331,8 @@ static void ImGui_ImplDX11_CreateFontsTexture()
331331 subResource.pSysMem = pixels;
332332 subResource.SysMemPitch = desc.Width * 4 ;
333333 subResource.SysMemSlicePitch = 0 ;
334- bd->pd3dDevice ->CreateTexture2D (&desc, &subResource, &pTexture);
335- IM_ASSERT (pTexture != NULL ) ;
334+ if ( FAILED ( bd->pd3dDevice ->CreateTexture2D (&desc, &subResource, &pTexture)))
335+ return false ;
336336
337337 // Create texture view
338338 D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
@@ -341,7 +341,12 @@ static void ImGui_ImplDX11_CreateFontsTexture()
341341 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
342342 srvDesc.Texture2D .MipLevels = desc.MipLevels ;
343343 srvDesc.Texture2D .MostDetailedMip = 0 ;
344- bd->pd3dDevice ->CreateShaderResourceView (pTexture, &srvDesc, &bd->pFontTextureView );
344+ if (FAILED (bd->pd3dDevice ->CreateShaderResourceView (pTexture, &srvDesc, &bd->pFontTextureView )))
345+ {
346+ pTexture->Release ();
347+ return false ;
348+ }
349+
345350 pTexture->Release ();
346351 }
347352
@@ -361,8 +366,11 @@ static void ImGui_ImplDX11_CreateFontsTexture()
361366 desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
362367 desc.MinLOD = 0 .f ;
363368 desc.MaxLOD = 0 .f ;
364- bd->pd3dDevice ->CreateSamplerState (&desc, &bd->pFontSampler );
369+ if (FAILED (bd->pd3dDevice ->CreateSamplerState (&desc, &bd->pFontSampler )))
370+ return false ;
365371 }
372+
373+ return true ;
366374}
367375
368376bool ImGui_ImplDX11_CreateDeviceObjects ()
@@ -514,7 +522,8 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
514522 bd->pd3dDevice ->CreateDepthStencilState (&desc, &bd->pDepthStencilState );
515523 }
516524
517- ImGui_ImplDX11_CreateFontsTexture ();
525+ if (!ImGui_ImplDX11_CreateFontsTexture ())
526+ return false ;
518527
519528 return true ;
520529}
0 commit comments