From 198f5e501e806b57a6be2162eb0d7fe3ac1fc606 Mon Sep 17 00:00:00 2001 From: Roman Roibu Date: Tue, 8 Sep 2020 18:03:37 +0200 Subject: [PATCH 1/5] Only call glViewport if g_pool.camera_render_size is not negative --- pupil_src/launchables/eye.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pupil_src/launchables/eye.py b/pupil_src/launchables/eye.py index ad98a35810..4df94afcd9 100644 --- a/pupil_src/launchables/eye.py +++ b/pupil_src/launchables/eye.py @@ -236,9 +236,10 @@ def consume_events_and_render_buffer(): glfw.glfwMakeContextCurrent(main_window) clear_gl_screen() - glViewport(0, 0, *g_pool.camera_render_size) - for p in g_pool.plugins: - p.gl_display() + if 0 <= g_pool.camera_render_size[0] and g_pool.camera_render_size[1]: + glViewport(0, 0, *g_pool.camera_render_size) + for p in g_pool.plugins: + p.gl_display() glViewport(0, 0, *window_size) # render graphs From bf69d69c66205557f47ba2a07e13e2651ba9a2db Mon Sep 17 00:00:00 2001 From: Roman Roibu Date: Wed, 9 Sep 2020 11:14:49 +0200 Subject: [PATCH 2/5] Fix loging that ensures g_pool.camera_render_size is non-negative --- pupil_src/launchables/eye.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pupil_src/launchables/eye.py b/pupil_src/launchables/eye.py index 4df94afcd9..4ddb686ff9 100644 --- a/pupil_src/launchables/eye.py +++ b/pupil_src/launchables/eye.py @@ -236,7 +236,7 @@ def consume_events_and_render_buffer(): glfw.glfwMakeContextCurrent(main_window) clear_gl_screen() - if 0 <= g_pool.camera_render_size[0] and g_pool.camera_render_size[1]: + if all(c > 0 for c in g_pool.camera_render_size): glViewport(0, 0, *g_pool.camera_render_size) for p in g_pool.plugins: p.gl_display() From c3f0ef719083b9b6e32caba8bd80bb14c8f0cdca Mon Sep 17 00:00:00 2001 From: Roman Roibu Date: Wed, 9 Sep 2020 11:21:25 +0200 Subject: [PATCH 3/5] Only call glClear in eye on_resize only if not minimized --- pupil_src/launchables/eye.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pupil_src/launchables/eye.py b/pupil_src/launchables/eye.py index 4ddb686ff9..95f530609e 100644 --- a/pupil_src/launchables/eye.py +++ b/pupil_src/launchables/eye.py @@ -290,10 +290,14 @@ def on_resize(window, w, h): nonlocal window_size nonlocal content_scale - # Always clear buffers on resize to make sure that there are no overlapping - # artifacts from previous frames. - gl_utils.glClear(gl_utils.GL_COLOR_BUFFER_BIT) - gl_utils.glClearColor(0, 0, 0, 1) + framebuffer_size = glfw.glfwGetFramebufferSize(window) + is_minimized = framebuffer_size is not None and 0 in framebuffer_size + + if not is_minimized: + # Always clear buffers on resize to make sure that there are no overlapping + # artifacts from previous frames. + gl_utils.glClear(gl_utils.GL_COLOR_BUFFER_BIT) + gl_utils.glClearColor(0, 0, 0, 1) active_window = glfw.glfwGetCurrentContext() glfw.glfwMakeContextCurrent(window) From 01e19173f67a394fbff8655f4e23ab60a7b37568 Mon Sep 17 00:00:00 2001 From: Roman Roibu Date: Mon, 14 Sep 2020 12:29:59 +0200 Subject: [PATCH 4/5] Fix is_minimized expression in eye.py on_resize --- pupil_src/launchables/eye.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pupil_src/launchables/eye.py b/pupil_src/launchables/eye.py index 95f530609e..64bb454b15 100644 --- a/pupil_src/launchables/eye.py +++ b/pupil_src/launchables/eye.py @@ -291,7 +291,7 @@ def on_resize(window, w, h): nonlocal content_scale framebuffer_size = glfw.glfwGetFramebufferSize(window) - is_minimized = framebuffer_size is not None and 0 in framebuffer_size + is_minimized = any(c <= 0 for c in framebuffer_size) if not is_minimized: # Always clear buffers on resize to make sure that there are no overlapping From bd95f361b6841f1f0faaa1bd586b96aa7b4c7e7f Mon Sep 17 00:00:00 2001 From: Roman Roibu Date: Mon, 14 Sep 2020 13:14:25 +0200 Subject: [PATCH 5/5] Skip on_resize callback if window is minimized (iconified) --- pupil_src/launchables/eye.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pupil_src/launchables/eye.py b/pupil_src/launchables/eye.py index 64bb454b15..6df8f7f1b2 100644 --- a/pupil_src/launchables/eye.py +++ b/pupil_src/launchables/eye.py @@ -290,14 +290,15 @@ def on_resize(window, w, h): nonlocal window_size nonlocal content_scale - framebuffer_size = glfw.glfwGetFramebufferSize(window) - is_minimized = any(c <= 0 for c in framebuffer_size) - - if not is_minimized: - # Always clear buffers on resize to make sure that there are no overlapping - # artifacts from previous frames. - gl_utils.glClear(gl_utils.GL_COLOR_BUFFER_BIT) - gl_utils.glClearColor(0, 0, 0, 1) + is_minimized = bool(glfw.glfwGetWindowAttrib(window, glfw.GLFW_ICONIFIED)) + + if is_minimized: + return + + # Always clear buffers on resize to make sure that there are no overlapping + # artifacts from previous frames. + gl_utils.glClear(gl_utils.GL_COLOR_BUFFER_BIT) + gl_utils.glClearColor(0, 0, 0, 1) active_window = glfw.glfwGetCurrentContext() glfw.glfwMakeContextCurrent(window)