X-Git-Url: http://deadsoftware.ru/gitweb?p=flatwaifu.git;a=blobdiff_plain;f=src%2Fsdl%2Fmain.c;h=9227725c9876a90f48dd1c9380ab3695acda90ae;hp=36b32798913dd64aa89f179ecec0dee2a9c80a8e;hb=4a0a2f1f4922d5346c4aee584e7d4a13803bffab;hpb=fbbbdcdd6dd7fe274a993b9868d540c6cf8f0eb4 diff --git a/src/sdl/main.c b/src/sdl/main.c index 36b3279..9227725 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -56,6 +56,7 @@ static int quit = 0; static SDL_Surface *surf = NULL; static int mode = MODE_NONE; static int text_input; +static videomode_t vlist; /* --- error.h --- */ @@ -151,6 +152,47 @@ int Y_set_videomode_software (int w, int h, int fullscreen) { return s != NULL; } +static void init_videomode_list (Uint32 flags) { + int i, n; + SDL_Rect **r; + if (vlist.modes != NULL) { + free(vlist.modes); + vlist.modes = NULL; + vlist.n = 0; + } + r = SDL_ListModes(NULL, flags); + if (r == (SDL_Rect **)-1) { + if ((flags & SDL_FULLSCREEN) == 0) { + init_videomode_list(flags | SDL_FULLSCREEN); + } + } else if (r != (SDL_Rect**)0) { + n = 0; + while (r[n] != NULL) { + n++; + } + vlist.modes = malloc(n * sizeof(videomode_size_t)); + if (vlist.modes != NULL) { + vlist.n = n; + for (i = 0; i < n; i++) { + vlist.modes[i] = (videomode_size_t) { + .w = r[i]->w, + .h = r[i]->h + }; + } + } + } +} + +const videomode_t *Y_get_videomode_list_opengl (int fullscreen) { + init_videomode_list(SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0)); + return &vlist; +} + +const videomode_t *Y_get_videomode_list_software (int fullscreen) { + init_videomode_list(SDL_SWSURFACE | SDL_HWPALETTE | (fullscreen ? SDL_FULLSCREEN : 0)); + return &vlist; +} + void Y_get_videomode (int *w, int *h) { if (mode != MODE_NONE) { *w = surf->w;