diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-07-17 22:26:11 -0700 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-07-17 22:26:11 -0700 |
commit | b94c9fd1cd3731c9a0bdcabcb15e7bead85021dc (patch) | |
tree | c8728e73773862cf1314e59b540f84369af8c681 /render_sdl.c | |
parent | 1482ef3c532eca86baf1d81a02822ff0962cedf8 (diff) |
Add fullscreen support and add a keybinding for exiting the emulator
Diffstat (limited to 'render_sdl.c')
-rw-r--r-- | render_sdl.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/render_sdl.c b/render_sdl.c index 6148c96..bde6825 100644 --- a/render_sdl.c +++ b/render_sdl.c @@ -88,7 +88,7 @@ uint8_t render_depth() return screen->format->BytesPerPixel * 8; } -void render_init(int width, int height, char * title, uint32_t fps) +void render_init(int width, int height, char * title, uint32_t fps, uint8_t fullscreen) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); @@ -97,7 +97,13 @@ void render_init(int width, int height, char * title, uint32_t fps) atexit(SDL_Quit); atexit(render_close_audio); printf("width: %d, height: %d\n", width, height); - screen = SDL_SetVideoMode(width, height, 32, SDL_SWSURFACE | SDL_ANYFORMAT); + uint32_t flags = SDL_ANYFORMAT; + if (fullscreen) { + flags |= SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF; + } else { + flags |= SDL_SWSURFACE; + } + screen = SDL_SetVideoMode(width, height, 32, flags); if (!screen) { fprintf(stderr, "Unable to get SDL surface: %s\n", SDL_GetError()); exit(1); @@ -216,7 +222,8 @@ void render_context(vdp_context * context) if ( SDL_MUSTLOCK(screen) ) { SDL_UnlockSurface(screen); } - SDL_UpdateRect(screen, 0, 0, screen->clip_rect.w, screen->clip_rect.h); + //SDL_UpdateRect(screen, 0, 0, screen->clip_rect.w, screen->clip_rect.h); + SDL_Flip(screen); if (context->regs[REG_MODE_4] & BIT_INTERLACE) { context->framebuf = context->framebuf == context->oddbuf ? context->evenbuf : context->oddbuf; |