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);
22 scr.ScreenShot(output);
25 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))
27 View view(doc,bounds, c);
29 scr.DebugFontInit("DejaVuSansMono.ttf");
30 scr.SetMouseHandler([&](int x, int y, int buttons, int wheel) // [?] wtf
32 static bool oldButtonDown = false;
33 static int oldx, oldy;
34 if (buttons && !oldButtonDown)
36 // We're beginning a drag.
40 scr.SetMouseCursor(Screen::CursorMove);
44 view.Translate(Real(oldx-x)/Real(scr.ViewportWidth()), Real(oldy-y)/Real(scr.ViewportHeight()));
48 oldButtonDown = false;
49 scr.SetMouseCursor(Screen::CursorArrow);
56 view.ScaleAroundPoint(Real(x)/Real(scr.ViewportWidth()),Real(y)/Real(scr.ViewportHeight()), expf(-wheel/20.f));
61 double init_time = SDL_GetPerformanceCounter();
62 while (scr.PumpEvents())
66 scr.DebugFontPrintF("[CPU] Render took %lf ms (%lf FPS)\n", (SDL_GetPerformanceCounter() - init_time)* 1000.0/SDL_GetPerformanceFrequency(), SDL_GetPerformanceFrequency()/(SDL_GetPerformanceCounter() - init_time));
67 scr.DebugFontPrintF("View bounds: (%f, %f) - (%f, %f)\n", view.GetBounds().x, view.GetBounds().y, view.GetBounds().w, view.GetBounds().h);
69 init_time = SDL_GetPerformanceCounter();