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;'
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 ||