~l3kn/quad

ee6ecd67760d593b75674abf7fface1494bacb66 — Leon Rische 5 months ago ea5139e
Optional size argument
2 files changed, 12 insertions(+), 6 deletions(-)

M README.md
M quad.c
M README.md => README.md +7 -0
@@ 5,6 5,13 @@
## Installation

Depends on the `sdl2-dev` package.

Build with `make`, run with `./quad`.

The default size is 1024 pixels, optimized for 1080x1920px screens.
To use another size (ideally a power of two) run e.g `./quad 512` or
`./quad 2048`.

Run with `make run`.

## Interface

M quad.c => quad.c +5 -6
@@ 266,17 266,16 @@ void handleMouse(SDL_Event* event) {
}

int main(int argc, char* argv[]) {
  size = 1024;
  if (argc == 2) {
    size = atoi(argv[1]);
  }

  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    printf("error initializing SDL: %s\n", SDL_GetError());
    return 1;
  }

  SDL_DisplayMode dm;
  SDL_GetCurrentDisplayMode(0, &dm);
  int display_width = dm.w;
  int display_height = dm.h;

  size = 1 << (int)(log2(display_height - 2 * PADDING));
  menu_size = size / 16;
  menu_width = menu_size * 10;
  width = menu_width + menu_size + size + 2 * PADDING;