X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fsdl%2Fmain.c;h=4f529db45c1667da9e7b40e0c3b1e41444174cd2;hb=02f89a09888d2aab62c7bd92b8d3ac33fcd0c0ab;hp=36b32798913dd64aa89f179ecec0dee2a9c80a8e;hpb=7b2f2285593458477b8185e62099d61975faf7d4;p=flatwaifu.git diff --git a/src/sdl/main.c b/src/sdl/main.c index 36b3279..4f529db 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -28,8 +28,6 @@ #include #include #include // srand exit -#include // strcasecmp -#include #include #include "system.h" #include "input.h" @@ -56,6 +54,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 +150,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;