Add a return parameter to ImGui_Impl...._NewFrame()

Why does CreateDeviceObjects return a bool if the NewFrame doesn't ?
Added the return parameter cause CreateDeviceObjects can fail.
It did fail on DX11 with feature level to 9.
This commit is contained in:
Nemirtingas 2020-01-10 08:10:13 +01:00
parent 20c03cda75
commit 548f21c2f0
10 changed files with 26 additions and 16 deletions

View File

@ -63,7 +63,7 @@
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "imgui.h"
#include "../imgui.h"
#include "imgui_impl_opengl3.h"
#include <stdio.h>
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
@ -162,10 +162,12 @@ void ImGui_ImplOpenGL3_Shutdown()
ImGui_ImplOpenGL3_DestroyDeviceObjects();
}
void ImGui_ImplOpenGL3_NewFrame()
bool ImGui_ImplOpenGL3_NewFrame()
{
if (!g_FontTexture)
ImGui_ImplOpenGL3_CreateDeviceObjects();
return ImGui_ImplOpenGL3_CreateDeviceObjects();
return true;
}
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)

View File

@ -37,7 +37,7 @@
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_NewFrame();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
// Called by Init/NewFrame/Shutdown

View File

@ -548,8 +548,10 @@ void ImGui_ImplDX10_Shutdown()
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
}
void ImGui_ImplDX10_NewFrame()
bool ImGui_ImplDX10_NewFrame()
{
if (!g_pFontSampler)
ImGui_ImplDX10_CreateDeviceObjects();
return ImGui_ImplDX10_CreateDeviceObjects();
return true;
}

View File

@ -15,7 +15,7 @@ struct ID3D10Device;
IMGUI_IMPL_API bool ImGui_ImplDX10_Init(ID3D10Device* device);
IMGUI_IMPL_API void ImGui_ImplDX10_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX10_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplDX10_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data);
// Use if you want to reset your rendering device without losing ImGui state.

View File

@ -556,8 +556,10 @@ void ImGui_ImplDX11_Shutdown()
if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
}
void ImGui_ImplDX11_NewFrame()
bool ImGui_ImplDX11_NewFrame()
{
if (!g_pFontSampler)
ImGui_ImplDX11_CreateDeviceObjects();
return ImGui_ImplDX11_CreateDeviceObjects();
return true;
}

View File

@ -16,7 +16,7 @@ struct ID3D11DeviceContext;
IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context);
IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplDX11_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
// Use if you want to reset your rendering device without losing ImGui state.

View File

@ -668,8 +668,10 @@ void ImGui_ImplDX12_Shutdown()
g_frameIndex = UINT_MAX;
}
void ImGui_ImplDX12_NewFrame()
bool ImGui_ImplDX12_NewFrame()
{
if (!g_pPipelineState)
ImGui_ImplDX12_CreateDeviceObjects();
return ImGui_ImplDX12_CreateDeviceObjects();
return true;
}

View File

@ -26,7 +26,7 @@ struct D3D12_GPU_DESCRIPTOR_HANDLE;
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format,
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplDX12_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);
// Use if you want to reset your rendering device without losing ImGui state.

View File

@ -277,8 +277,10 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
}
void ImGui_ImplDX9_NewFrame()
bool ImGui_ImplDX9_NewFrame()
{
if (!g_FontTexture)
ImGui_ImplDX9_CreateDeviceObjects();
return ImGui_ImplDX9_CreateDeviceObjects();
return true;
}

View File

@ -15,7 +15,7 @@ struct IDirect3DDevice9;
IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device);
IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplDX9_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
// Use if you want to reset your rendering device without losing ImGui state.