Browse Source

Automagically determine ideal integer scale

master
Nathaniel Walizer 11 months ago
parent
commit
3b3f457634
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      src/sdl_render.c

+ 10
- 2
src/sdl_render.c View File

@@ -57,12 +57,20 @@ static int sdl_render_init(nes_Renderer* rend) {
fprintf(stderr, "SDL: Failed to initialize\n");

} else {
SDL_DisplayMode mode = {0};

SDL_GetCurrentDisplayMode(0, &mode);

int yscale = (mode.h - 1) / nes_ppu_scan_h;
int xscale = mode.w / nes_ppu_scan_w;
int scale = (xscale < yscale ? xscale : yscale);

data->window = SDL_CreateWindow(
"NESe",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
nes_ppu_scan_w * 4,
nes_ppu_scan_h * 4,
nes_ppu_scan_w * scale,
nes_ppu_scan_h * scale,
0
);
if (NULL == data->window) {


Loading…
Cancel
Save