mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 20:59:01 +08:00
ENABLE_GL_IMGUI_SHADERS - Fixes in ImGuiWrapper::render_draw_data()
This commit is contained in:
parent
8ce9241c48
commit
4964d6ecd5
@ -1528,13 +1528,9 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
|||||||
glsafe(::glLoadIdentity());
|
glsafe(::glLoadIdentity());
|
||||||
#endif // ENABLE_GL_IMGUI_SHADERS
|
#endif // ENABLE_GL_IMGUI_SHADERS
|
||||||
|
|
||||||
#if ENABLE_GL_IMGUI_SHADERS
|
|
||||||
// Will project scissor/clipping rectangles into framebuffer space
|
// Will project scissor/clipping rectangles into framebuffer space
|
||||||
const ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
const ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||||
const ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
const ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||||
#else
|
|
||||||
const ImVec2 pos = draw_data->DisplayPos;
|
|
||||||
#endif // ENABLE_GL_IMGUI_SHADERS
|
|
||||||
|
|
||||||
// Render command lists
|
// Render command lists
|
||||||
for (int n = 0; n < draw_data->CmdListsCount; ++n) {
|
for (int n = 0; n < draw_data->CmdListsCount; ++n) {
|
||||||
@ -1596,18 +1592,20 @@ void ImGuiWrapper::render_draw_data(ImDrawData *draw_data)
|
|||||||
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));
|
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));
|
||||||
glsafe(::glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))));
|
glsafe(::glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))));
|
||||||
#else
|
#else
|
||||||
const ImVec4 clip_rect = ImVec4(pcmd->ClipRect.x - pos.x, pcmd->ClipRect.y - pos.y, pcmd->ClipRect.z - pos.x, pcmd->ClipRect.w - pos.y);
|
// Project scissor/clipping rectangles into framebuffer space
|
||||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f) {
|
const ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y);
|
||||||
// Apply scissor/clipping rectangle
|
const ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y);
|
||||||
glsafe(::glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y)));
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Apply scissor/clipping rectangle (Y is inverted in OpenGL)
|
||||||
|
glsafe(::glScissor((int)clip_min.x, (int)(fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y)));
|
||||||
|
|
||||||
// Bind texture, Draw
|
// Bind texture, Draw
|
||||||
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));
|
glsafe(::glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));
|
||||||
glsafe(::glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))));
|
glsafe(::glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer + pcmd->IdxOffset));
|
||||||
}
|
|
||||||
#endif // ENABLE_GL_IMGUI_SHADERS
|
#endif // ENABLE_GL_IMGUI_SHADERS
|
||||||
}
|
}
|
||||||
idx_buffer += pcmd->ElemCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GL_IMGUI_SHADERS
|
#if ENABLE_GL_IMGUI_SHADERS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user