From 757b2b61e1781fbc903413f8703628468fd6c2f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Mon, 19 Sep 2011 10:09:53 +0100 Subject: [PATCH] Infer the drawable size from glBlitFramebuffer too --- glretrace.hpp | 1 + glretrace.py | 22 ++++++---------------- glretrace_main.cpp | 31 +++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/glretrace.hpp b/glretrace.hpp index 255dd6f..5b93f2d 100644 --- a/glretrace.hpp +++ b/glretrace.hpp @@ -69,6 +69,7 @@ void retrace_call_wgl(Trace::Call &call); void snapshot(unsigned call_no); void frame_complete(unsigned call_no); +void updateDrawable(int width, int height); } /* namespace glretrace */ diff --git a/glretrace.py b/glretrace.py index 53afdbe..356659a 100644 --- a/glretrace.py +++ b/glretrace.py @@ -207,23 +207,13 @@ class GlRetracer(Retracer): def call_function(self, function): + # Infer the drawable size from GL calls if function.name == "glViewport": - print ' GLint draw_framebuffer = 0;' - print ' glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer);' - print ' if (draw_framebuffer == 0) {' - print ' if (glretrace::drawable) {' - print ' int drawable_width = x + width;' - print ' int drawable_height = y + height;' - print ' if (drawable_width > (int)glretrace::drawable->width ||' - print ' drawable_height > (int)glretrace::drawable->height) {' - print ' glretrace::drawable->resize(drawable_width, drawable_height);' - print ' if (!glretrace::drawable->visible) {' - print ' glretrace::drawable->show();' - print ' }' - print ' glScissor(0, 0, drawable_width, drawable_height);' - print ' }' - print ' }' - print ' }' + print ' glretrace::updateDrawable(x + width, y + height);' + if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'): + # Some applications do all their rendering in a framebuffer, and + # then just blit to the drawable without ever calling glViewport. + print ' glretrace::updateDrawable(std::max(dstX0, dstX1), std::max(dstY0, dstY1));' if function.name == "glEnd": print ' glretrace::insideGlBeginEnd = false;' diff --git a/glretrace_main.cpp b/glretrace_main.cpp index 3a90092..cd35889 100644 --- a/glretrace_main.cpp +++ b/glretrace_main.cpp @@ -103,6 +103,37 @@ checkGlError(Trace::Call &call) { std::cerr << "\n"; } +/** + * Grow the current drawble. + * + * We need to infer the drawable size from GL calls because the drawable sizes + * are specified by OS specific calls which we do not trace. + */ +void +updateDrawable(int width, int height) { + if (!drawable) { + return; + } + + if (width <= glretrace::drawable->width && + height <= glretrace::drawable->height) { + return; + } + + // Check for bound framebuffer last, as this may have a performance impact. + GLint draw_framebuffer = 0; + glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &draw_framebuffer); + if (draw_framebuffer != 0) { + return; + } + + glretrace::drawable->resize(width, height); + if (!drawable->visible) { + drawable->show(); + } + glScissor(0, 0, width, height); +} + void snapshot(unsigned call_no) { if (!drawable || -- 2.43.0