|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
// CHANGELOG
|
|
// CHANGELOG
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
|
+// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
|
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
|
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
|
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
|
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
|
// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT).
|
|
// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT).
|
|
@@ -137,12 +138,10 @@ void ImGui_ImplOpenGL3_NewFrame()
|
|
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|
{
|
|
{
|
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
|
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
|
- ImGuiIO& io = ImGui::GetIO();
|
|
|
|
- int fb_width = (int)(draw_data->DisplaySize.x * io.DisplayFramebufferScale.x);
|
|
|
|
- int fb_height = (int)(draw_data->DisplaySize.y * io.DisplayFramebufferScale.y);
|
|
|
|
|
|
+ int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
|
|
|
+ int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
|
if (fb_width <= 0 || fb_height <= 0)
|
|
if (fb_width <= 0 || fb_height <= 0)
|
|
return;
|
|
return;
|
|
- draw_data->ScaleClipRects(io.DisplayFramebufferScale);
|
|
|
|
|
|
|
|
// Backup GL state
|
|
// Backup GL state
|
|
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
|
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
|
@@ -220,8 +219,11 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|
glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
|
|
glVertexAttribPointer(g_AttribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
|
|
glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
|
|
glVertexAttribPointer(g_AttribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
|
|
|
|
|
|
- // Draw
|
|
|
|
- ImVec2 pos = draw_data->DisplayPos;
|
|
|
|
|
|
+ // Will project scissor/clipping rectangles into framebuffer space
|
|
|
|
+ ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
|
|
|
+ ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
|
|
|
+
|
|
|
|
+ // Render command lists
|
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
|
{
|
|
{
|
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
|
@@ -243,7 +245,13 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- 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
|
|
|
|
+ ImVec4 clip_rect;
|
|
|
|
+ clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
|
|
|
+ clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
|
|
|
+ clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
|
|
|
+ clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
|
|
|
+
|
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
|
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
|
{
|
|
{
|
|
// Apply scissor/clipping rectangle
|
|
// Apply scissor/clipping rectangle
|