Skip to main content

Drawing

Pushrod draws everything itself through SDL2 and keeps the work on the GPU:

  1. Each widget has its own GPU texture.
  2. When a widget is invalidated, Pushrod calls its paint once with a Painter, drawing into that texture.
  3. Each frame where something changed, Pushrod clears the screen and copies every visible widget's texture to it in tree order, then presents the frame. Copying cached textures is cheap; repainting only happens for widgets that changed.
  4. If nothing changed, nothing is drawn and the previous frame stays on screen.

Widgets draw only through the Painter trait, never an SDL type. SDL2 is the default backend; see Backend-neutral paint API.

This is why widgets never draw directly to the screen and why changing a widget only requires marking it invalidated.

Rules for widget authors​

  • Draw only inside paint, from (0, 0) to get_size().
  • Use the paint helpers (fill, border, text) so widgets share one look: flat, with no gradients, bevels, shadows, or rounded corners (design philosophy).
  • Pushrod never uses operating-system menus, dialogs, or controls: everything on screen is a Pushrod widget, so applications look the same everywhere.

Renderer on macOS​

On macOS, Pushrod asks SDL2 for the OpenGL renderer. With the Metal and software renderers the whole window appeared to move one pixel each time a click repainted a widget. To pick a different renderer, set the SDL_RENDER_DRIVER environment variable (metal, opengl, or software) before starting your application; Pushrod then leaves the choice alone.