summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2019-07-09 16:36:36 +0200
committerAndre Weissflog <floooh@gmail.com>2019-07-09 16:36:36 +0200
commit51f4c084c6ba117e12d612c6ab625c0fb1877aeb (patch)
tree5bc6e1b2d24e536491aa7a994de50662e5e343c4 /util
parent3c5aa9f29a5e3605f5cb69d194666802e0735435 (diff)
sokol_imgui.h / sokol_cimgui.h: init viewport to defined state before rendering
Diffstat (limited to 'util')
-rw-r--r--util/sokol_cimgui.h8
-rw-r--r--util/sokol_imgui.h8
2 files changed, 14 insertions, 2 deletions
diff --git a/util/sokol_cimgui.h b/util/sokol_cimgui.h
index dd51ac77..b991c71e 100644
--- a/util/sokol_cimgui.h
+++ b/util/sokol_cimgui.h
@@ -851,6 +851,13 @@ SOKOL_API_IMPL void scimgui_new_frame(int width, int height, double delta_time)
SOKOL_API_IMPL void scimgui_render(void) {
igRender();
+
+ /* reset viewport to a defined state */
+ const float dpi_scale = _scimgui.desc.dpi_scale;
+ const int fb_width = (const int) (igGetIO()->DisplaySize.x * dpi_scale);
+ const int fb_height = (const int) (igGetIO()->DisplaySize.y * dpi_scale);
+ sg_apply_viewport(0, 0, fb_width, fb_height, true);
+
ImDrawData* draw_data = igGetDrawData();
if (draw_data == NULL) {
return;
@@ -858,7 +865,6 @@ SOKOL_API_IMPL void scimgui_render(void) {
if (draw_data->CmdListsCount == 0) {
return;
}
- const float dpi_scale = _scimgui.desc.dpi_scale;
/* render the ImGui command list */
sg_push_debug_group("sokol-imgui");
diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h
index 085bc4b3..ae4d80a5 100644
--- a/util/sokol_imgui.h
+++ b/util/sokol_imgui.h
@@ -861,6 +861,13 @@ SOKOL_API_IMPL void simgui_new_frame(int width, int height, double delta_time) {
SOKOL_API_IMPL void simgui_render(void) {
ImGui::Render();
+
+ /* reset viewport to a defined state */
+ const float dpi_scale = _simgui.desc.dpi_scale;
+ const int fb_width = (const int) (ImGui::GetIO().DisplaySize.x * dpi_scale);
+ const int fb_height = (const int) (ImGui::GetIO().DisplaySize.y * dpi_scale);
+ sg_apply_viewport(0, 0, fb_width, fb_height, true);
+
ImDrawData* draw_data = ImGui::GetDrawData();
if (nullptr == draw_data) {
return;
@@ -868,7 +875,6 @@ SOKOL_API_IMPL void simgui_render(void) {
if (draw_data->CmdListsCount == 0) {
return;
}
- const float dpi_scale = _simgui.desc.dpi_scale;
/* render the ImGui command list */
sg_push_debug_group("sokol-imgui");