aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAndre Weissflog <floooh@gmail.com>2019-07-11 13:02:35 +0200
committerAndre Weissflog <floooh@gmail.com>2019-07-11 13:02:35 +0200
commit1dde6a20860e86c96572bb65d8145f1d0360f132 (patch)
tree68baa6817e3eb87625bdf48a9564694d6d69242a /util
parent24c03cc042d95abd8994b7332ec088a133a0a915 (diff)
sokol_imgui/cimgui.h: set viewport and scissor to 'fullscreen' on entry and exit of render function
Diffstat (limited to 'util')
-rw-r--r--util/sokol_cimgui.h14
-rw-r--r--util/sokol_imgui.h15
2 files changed, 17 insertions, 12 deletions
diff --git a/util/sokol_cimgui.h b/util/sokol_cimgui.h
index b991c71e..aacc0af5 100644
--- a/util/sokol_cimgui.h
+++ b/util/sokol_cimgui.h
@@ -852,12 +852,6 @@ 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;
@@ -868,6 +862,12 @@ SOKOL_API_IMPL void scimgui_render(void) {
/* render the ImGui command list */
sg_push_debug_group("sokol-imgui");
+ 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);
+ sg_apply_scissor_rect(0, 0, fb_width, fb_height, true);
+
sg_apply_pipeline(_scimgui.pip);
_scimgui_vs_params_t vs_params;
vs_params.disp_size.x = igGetIO()->DisplaySize.x;
@@ -926,6 +926,8 @@ SOKOL_API_IMPL void scimgui_render(void) {
base_element += pcmd.ElemCount;
}
}
+ sg_apply_viewport(0, 0, fb_width, fb_height, true);
+ sg_apply_scissor_rect(0, 0, fb_width, fb_height, true);
sg_pop_debug_group();
}
diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h
index ae4d80a5..cfd8b055 100644
--- a/util/sokol_imgui.h
+++ b/util/sokol_imgui.h
@@ -862,12 +862,6 @@ 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;
@@ -878,6 +872,13 @@ SOKOL_API_IMPL void simgui_render(void) {
/* render the ImGui command list */
sg_push_debug_group("sokol-imgui");
+
+ 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);
+ sg_apply_scissor_rect(0, 0, fb_width, fb_height, true);
+
sg_apply_pipeline(_simgui.pip);
_simgui_vs_params_t vs_params;
vs_params.disp_size.x = ImGui::GetIO().DisplaySize.x;
@@ -930,6 +931,8 @@ SOKOL_API_IMPL void simgui_render(void) {
base_element += pcmd.ElemCount;
}
}
+ sg_apply_viewport(0, 0, fb_width, fb_height, true);
+ sg_apply_scissor_rect(0, 0, fb_width, fb_height, true);
sg_pop_debug_group();
}