imgui: Fix assert in new_frame()

This commit is contained in:
Vojtech Kral 2019-02-22 14:52:32 +01:00
parent 49d131be4d
commit 77c309f4cb
2 changed files with 15 additions and 0 deletions

View file

@ -101,6 +101,10 @@ void ImGuiWrapper::set_style_scaling(float scaling)
bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
{
if (! display_initialized()) {
return false;
}
ImGuiIO& io = ImGui::GetIO();
io.MousePos = ImVec2((float)evt.GetX(), (float)evt.GetY());
io.MouseDown[0] = evt.LeftDown();
@ -116,6 +120,10 @@ bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
{
if (! display_initialized()) {
return false;
}
ImGuiIO& io = ImGui::GetIO();
if (evt.GetEventType() == wxEVT_CHAR) {
@ -521,6 +529,12 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
}
bool ImGuiWrapper::display_initialized() const
{
const ImGuiIO& io = ImGui::GetIO();
return io.DisplaySize.x >= 0.0f && io.DisplaySize.y >= 0.0f;
}
void ImGuiWrapper::destroy_device_objects()
{
destroy_fonts_texture();

View file

@ -75,6 +75,7 @@ private:
void init_input();
void init_style();
void render_draw_data(ImDrawData *draw_data);
bool display_initialized() const;
void destroy_device_objects();
void destroy_fonts_texture();