12 inline void OverlayBMP(Document & doc, const char * input, const char * output, const Rect & bounds = Rect(0,0,1,1), const Colour & c = Colour(0.f,0.f,0.f,1.f))
14 View view(doc, bounds, c);
20 scr.ScreenShot(output);
24 inline void MainLoop(Document & doc, const Rect & bounds = Rect(0,0,1,1), const Colour & c = Colour(0.f,0.f,0.f,1.f))
26 View view(doc,bounds, c);
28 scr.DebugFontInit("DejaVuSansMono.ttf");
29 scr.SetMouseHandler([&](int x, int y, int buttons, int wheel) // [?] wtf
31 static bool oldButtonDown = false;
32 static int oldx, oldy;
33 if (buttons > 1 && !oldButtonDown)
36 view.ToggleGPUTransform();
41 if (buttons && !oldButtonDown)
43 // We're beginning a drag.
47 scr.SetMouseCursor(Screen::CursorMove);
51 view.Translate(Real(oldx-x)/Real(scr.ViewportWidth()), Real(oldy-y)/Real(scr.ViewportHeight()));
55 oldButtonDown = false;
56 scr.SetMouseCursor(Screen::CursorArrow);
63 view.ScaleAroundPoint(Real(x)/Real(scr.ViewportWidth()),Real(y)/Real(scr.ViewportHeight()), expf(-wheel/20.f));
68 double init_time = SDL_GetPerformanceCounter();
69 while (scr.PumpEvents())
73 scr.DebugFontPrintF("[CPU] Render took %lf ms (%lf FPS)\n", (SDL_GetPerformanceCounter() - init_time)* 1000.0/SDL_GetPerformanceFrequency(), SDL_GetPerformanceFrequency()/(SDL_GetPerformanceCounter() - init_time));
74 scr.DebugFontPrintF("View bounds: (%f, %f) - (%f, %f)\n", view.GetBounds().x, view.GetBounds().y, view.GetBounds().w, view.GetBounds().h);
75 if (view.UsingGPUTransform())
77 scr.DebugFontPrint("Doing coordinate transform on the GPU.\n");
81 scr.DebugFontPrint("Doing coordinate transform on the CPU.\n");
84 init_time = SDL_GetPerformanceCounter();