VERSIÓ 1.7

- [FIX] Si estem en consola de text, ignora zoom i fullscreen i dimensiona tot correcta en base a la resolució nativa del monitor.
This commit is contained in:
2026-03-08 14:08:54 +01:00
parent e92498fd16
commit 942ce2a6ff
2 changed files with 48 additions and 8 deletions

View File

@@ -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; i<num_render_drivers; ++i)
{
printf(" - %i: %s\n", i, SDL_GetRenderDriver(i));
}
for (int i=0; i<num_render_drivers; ++i) printf(" - %i: %s\n", i, SDL_GetRenderDriver(i));
printf("\nRenderer: %s\n", SDL_GetRendererName(sdl_renderer));
SDL_HideCursor();
@@ -183,7 +209,16 @@ namespace draw
SDL_DestroyWindow(sdl_window);
const int zoom = screen_fullscreen ? 1 : screen_zoom;
sdl_window = SDL_CreateWindow(screen_title.c_str(), screen_width * zoom, screen_height * zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN:0);
if (console) {
SDL_DisplayID display = SDL_GetPrimaryDisplay();
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(display);
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 * 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();