diff --git a/source/jdraw.cpp b/source/jdraw.cpp index 16bbb32..714854c 100644 --- a/source/jdraw.cpp +++ b/source/jdraw.cpp @@ -43,6 +43,8 @@ namespace draw surface* managed[50]; int num_managed = 0; + bool console = false; + namespace stencil { static bool enabled = false; @@ -87,20 +89,44 @@ namespace draw screen_height = height; // [TODO] Incloure gestió de pantalla completa + const char *driver = SDL_GetCurrentVideoDriver(); + if (!driver) { + // No video driver at all → likely a text console with no graphics + printf("No video driver, probably running in a text console.\n"); + console = true; + } else { + printf("Video driver: %s\n", driver); + + if (strcmp(driver, "x11") == 0) { + printf("Running under X11.\n"); + } else if (strcmp(driver, "wayland") == 0) { + printf("Running under Wayland.\n"); + } else if (strcmp(driver, "kmsdrm") == 0) { + printf("Running on a text console using KMS/DRM.\n"); + console = true; + } + } + + if (console) { + SDL_DisplayID display = SDL_GetPrimaryDisplay(); + const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(display); + if (mode) { + printf("Native resolution: %dx%d @ %d Hz\n", mode->w, mode->h, mode->refresh_rate); + } + screen_fullscreen = true; + sdl_window = SDL_CreateWindow(screen_title.c_str(), mode->w, mode->h, SDL_WINDOW_FULLSCREEN); + } else { + sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * screen_zoom, screen_height * screen_zoom, screen_fullscreen ? SDL_WINDOW_FULLSCREEN : 0); + } // Inicialització de les estructures de SDL - sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * screen_zoom, screen_height * screen_zoom, screen_fullscreen ? SDL_WINDOW_FULLSCREEN : 0); sdl_renderer = SDL_CreateRenderer(sdl_window, nullptr); sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height); SDL_SetTextureScaleMode(sdl_texture, SDL_SCALEMODE_NEAREST); const int num_render_drivers = SDL_GetNumRenderDrivers(); printf("Available renderers:\n"); - for (int i=0; iw, mode->h, SDL_WINDOW_FULLSCREEN); + } else { + sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * zoom, screen_height * zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN:0); + } + sdl_renderer = SDL_CreateRenderer(sdl_window, nullptr); sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height); SDL_SetTextureScaleMode(sdl_texture, SDL_SCALEMODE_NEAREST); @@ -213,6 +248,7 @@ namespace draw void setZoom(const int value) { + if (console) return; if (value < 1) return; const SDL_DisplayMode *dm = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(sdl_window)); @@ -225,22 +261,26 @@ namespace draw void incZoom() { + if (console) return; setZoom(screen_zoom+1); } void decZoom() { + if (console) return; setZoom(screen_zoom-1); } void toggleFullscreen() { + if (console) return; screen_fullscreen = !screen_fullscreen; reinit(); } void setFullscreen(const bool value) { + if (console) return; if (screen_fullscreen == value) return; screen_fullscreen = value; reinit(); diff --git a/source/versio.h b/source/versio.h index 412c44b..4d877ea 100644 --- a/source/versio.h +++ b/source/versio.h @@ -1,3 +1,3 @@ #pragma once -#define VERSIO "v1.6" +#define VERSIO "v1.7"