From 0731283a9f44bb9c2478d062daa3ef58370c99f4 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Thu, 1 Apr 2021 22:39:53 +0200 Subject: [PATCH] plat_sdl_screen in RGBSurface, removed debug on screen --- menu.c | 11 +++++++++++ plat_sdl.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/menu.c b/menu.c index 50138f3..dfb5a77 100644 --- a/menu.c +++ b/menu.c @@ -162,8 +162,14 @@ void text_out16(int x, int y, const char *texto, ...) } /* draws in 6x8 font, might multiply size by integer */ +//#define ALLOW_TEXT_OUT static void smalltext_out16_(int x, int y, const char *texto, int color) { + +#ifndef ALLOW_TEXT_OUT + return; +#endif //ALLOW_TEXT_OUT + unsigned char *src; unsigned short *dst; int multiplier = me_sfont_w / 6; @@ -202,6 +208,11 @@ static void smalltext_out16_(int x, int y, const char *texto, int color) static void smalltext_out16(int x, int y, const char *texto, int color) { + +#ifndef ALLOW_TEXT_OUT + return; +#endif //ALLOW_TEXT_OUT + char buffer[128]; int maxw = (g_menuscreen_w - x) / me_sfont_w; diff --git a/plat_sdl.c b/plat_sdl.c index e79f2ef..0624d58 100644 --- a/plat_sdl.c +++ b/plat_sdl.c @@ -90,7 +90,12 @@ int plat_sdl_change_video_mode(int w, int h, int force) // (seen on r-pi) SDL_PumpEvents(); - plat_sdl_screen = SDL_SetVideoMode(win_w, win_h, 0, flags); + //plat_sdl_screen = SDL_SetVideoMode(win_w, win_h, 0, flags); + if (plat_sdl_screen) + SDL_FreeSurface(plat_sdl_screen); + printf("Creating plat_sdl_screen surface: win_w=%d, win_h=%d\n", win_w, win_h); + plat_sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, + win_w, win_h, 16, 0xFFFF, 0xFFFF, 0xFFFF, 0); if (plat_sdl_screen == NULL) { fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError()); plat_target.vout_method = 0; @@ -123,13 +128,12 @@ int plat_sdl_change_video_mode(int w, int h, int force) if (plat_target.vout_method == 0) { SDL_PumpEvents(); -#if defined SDL_SURFACE_SW - plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_SWSURFACE); -#elif defined(SDL_TRIPLEBUF) && defined(SDL_BUFFER_3X) - plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_TRIPLEBUF); -#else - plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); -#endif + //plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); + if (plat_sdl_screen) + SDL_FreeSurface(plat_sdl_screen); + printf("Creating plat_sdl_screen surface: w=%d, h=%d\n", w, h); + plat_sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, + w, h, 16, 0xFFFF, 0xFFFF, 0xFFFF, 0); if (plat_sdl_screen == NULL) { fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError()); return -1; @@ -198,6 +202,8 @@ int plat_sdl_init(void) return -1; } + SDL_ShowCursor(0); + info = SDL_GetVideoInfo(); if (info != NULL) { fs_w = info->current_w; @@ -219,7 +225,12 @@ int plat_sdl_init(void) ret = plat_sdl_change_video_mode(g_menuscreen_w, g_menuscreen_h, 1); if (ret != 0) { - plat_sdl_screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE); + //plat_sdl_screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE); + if (plat_sdl_screen) + SDL_FreeSurface(plat_sdl_screen); + printf("Creating plat_sdl_screen surface: w=%d, h=%d\n", 0, 0); + plat_sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, + 0, 0, 16, 0xFFFF, 0xFFFF, 0xFFFF, 0); if (plat_sdl_screen == NULL) { fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError()); goto fail; @@ -237,6 +248,11 @@ int plat_sdl_init(void) // overlay/gl require native bpp in some cases.. plat_sdl_screen = SDL_SetVideoMode(g_menuscreen_w, g_menuscreen_h, 0, plat_sdl_screen->flags); + if (plat_sdl_screen) + SDL_FreeSurface(plat_sdl_screen); + printf("Creating plat_sdl_screen surface: g_menuscreen_w=%d, g_menuscreen_h=%d\n", g_menuscreen_w, g_menuscreen_h); + plat_sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, + g_menuscreen_w, g_menuscreen_h, 16, 0xFFFF, 0xFFFF, 0xFFFF, 0); if (plat_sdl_screen == NULL) { fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError()); goto fail;