Mercurial > repos > blastem
diff render_sdl.c @ 444:cc754a309ead
Add fullscreen support and add a keybinding for exiting the emulator
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 17 Jul 2013 22:26:11 -0700 |
parents | 18cde14e8c10 |
children | 80a9527c812c |
line wrap: on
line diff
--- a/render_sdl.c Wed Jul 17 00:23:45 2013 -0700 +++ b/render_sdl.c Wed Jul 17 22:26:11 2013 -0700 @@ -88,7 +88,7 @@ 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 @@ 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 @@ 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;