mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 04:17:00 +00:00
Examples: OpenGL: skip rendering and calling glViewport() if we have a zero-fixed buffer (#486)
This commit is contained in:
parent
9e86d0e225
commit
2813a44dcc
@ -62,6 +62,8 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
||||||
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
||||||
|
if (fb_width == 0 || fb_height == 0)
|
||||||
|
return;
|
||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
@ -353,7 +355,7 @@ void ImGui_ImplGlfwGL3_NewFrame()
|
|||||||
glfwGetWindowSize(g_Window, &w, &h);
|
glfwGetWindowSize(g_Window, &w, &h);
|
||||||
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
|
@ -48,6 +48,8 @@ void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
||||||
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
||||||
|
if (fb_width == 0 || fb_height == 0)
|
||||||
|
return;
|
||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
@ -242,7 +244,7 @@ void ImGui_ImplGlfw_NewFrame()
|
|||||||
glfwGetWindowSize(g_Window, &w, &h);
|
glfwGetWindowSize(g_Window, &w, &h);
|
||||||
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
|
||||||
|
|
||||||
// Setup time step
|
// Setup time step
|
||||||
double current_time = glfwGetTime();
|
double current_time = glfwGetTime();
|
||||||
|
@ -57,6 +57,8 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
||||||
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
||||||
|
if (fb_width == 0 || fb_height == 0)
|
||||||
|
return;
|
||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// Setup orthographic projection matrix
|
// Setup orthographic projection matrix
|
||||||
|
@ -41,6 +41,8 @@ void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
int fb_width = (int)(io.DisplaySize.x * io.DisplayFramebufferScale.x);
|
||||||
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
int fb_height = (int)(io.DisplaySize.y * io.DisplayFramebufferScale.y);
|
||||||
|
if (fb_width == 0 || fb_height == 0)
|
||||||
|
return;
|
||||||
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
||||||
|
|
||||||
// Setup viewport, orthographic projection matrix
|
// Setup viewport, orthographic projection matrix
|
||||||
|
Loading…
Reference in New Issue
Block a user