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 ||
}
if (snapshot_prefix) {
- char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no);
- if (src->writePNG(filename) && retrace::verbosity >= 0) {
- std::cout << "Wrote " << filename << "\n";
+ if (snapshot_prefix[0] == '-' && snapshot_prefix[1] == 0) {
+ char comment[21];
+ snprintf(comment, sizeof comment, "%u", call_no);
+ src->writePNM(std::cout, comment);
+ } else {
+ char filename[PATH_MAX];
+ snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no);
+ if (src->writePNG(filename) && retrace::verbosity >= 0) {
+ std::cout << "Wrote " << filename << "\n";
+ }
}
}
static void display(void) {
+ retrace::Retracer retracer;
+
+ retracer.addCallbacks(gl_callbacks);
+ retracer.addCallbacks(glx_callbacks);
+ retracer.addCallbacks(wgl_callbacks);
+ retracer.addCallbacks(cgl_callbacks);
+
startTime = OS::GetTime();
Trace::Call *call;
while ((call = parser.parse_call())) {
- const char *name = call->name();
-
if (retrace::verbosity >= 1) {
std::cout << *call;
std::cout.flush();
}
- if (name[0] == 'C' && name[1] == 'G' && name[2] == 'L') {
- glretrace::retrace_call_cgl(*call);
- }
- else if (name[0] == 'w' && name[1] == 'g' && name[2] == 'l') {
- glretrace::retrace_call_wgl(*call);
- }
- else if (name[0] == 'g' && name[1] == 'l' && name[2] == 'X') {
- glretrace::retrace_call_glx(*call);
- } else {
- retrace::retrace_call(*call);
- }
+ retracer.retrace(*call);
if (!insideGlBeginEnd &&
drawable && context &&
" -c PREFIX compare against snapshots\n"
" -db use a double buffer visual (default)\n"
" -sb use a single buffer visual\n"
- " -s PREFIX take snapshots\n"
+ " -s PREFIX take snapshots; `-` for PNM stdout output\n"
" -S FREQUENCY snapshot frequency: frame (default), framebuffer, or draw\n"
" -v verbose output\n"
" -D CALLNO dump state at specific call no\n"
if (snapshot_frequency == FREQUENCY_NEVER) {
snapshot_frequency = FREQUENCY_FRAME;
}
+ if (snapshot_prefix[0] == '-' && snapshot_prefix[1] == 0) {
+ retrace::verbosity = -2;
+ }
} else if (!strcmp(arg, "-S")) {
arg = argv[++i];
if (!strcmp(arg, "frame")) {