corregides les textures amb filtre linear

This commit is contained in:
2026-04-03 10:20:26 +02:00
parent 7e570e2814
commit 8f1aeadeee
9 changed files with 41 additions and 3 deletions

View File

@@ -20,6 +20,7 @@
#include "lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK
#include "logo.h" // for Logo
#include "screen.h" // for FILTER_NEAREST, Screen, FILTER_...
#include "texture.h" // for Texture
#include "title.h" // for Title
#include "utils.h" // for options_t, input_t, boolToString
@@ -68,6 +69,9 @@ Director::Director(int argc, const char *argv[])
// Inicializa JailAudio
initJailAudio();
// Establece el modo de escalado de texturas
Texture::setGlobalScaleMode(options->filter == FILTER_NEAREST ? SDL_SCALEMODE_NEAREST : SDL_SCALEMODE_LINEAR);
// Crea los objetos
lang = new Lang(asset);
lang->setLang(options->language);

View File

@@ -14,7 +14,7 @@ struct options_t;
struct section_t;
// Textos
constexpr const char* WINDOW_CAPTION = "Coffee Crisis";
constexpr const char* WINDOW_CAPTION = "© 2020 Coffee Crisis — JailDesigner";
class Director
{

View File

@@ -10,6 +10,10 @@ Fade::Fade(SDL_Renderer *renderer)
mRenderer = renderer;
mBackbuffer = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (mBackbuffer != nullptr)
{
SDL_SetTextureScaleMode(mBackbuffer, SDL_SCALEMODE_NEAREST);
}
if (mBackbuffer == nullptr)
{
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;

View File

@@ -53,7 +53,11 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset,
// Crea un backbuffer para el renderizador
backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
if (backbuffer == nullptr)
if (backbuffer != nullptr)
{
SDL_SetTextureScaleMode(backbuffer, Texture::currentScaleMode);
}
else
{
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
}

View File

@@ -29,6 +29,10 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
// Crea la textura donde se dibujan los graficos del juego
gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight);
if (gameCanvas != nullptr)
{
SDL_SetTextureScaleMode(gameCanvas, options->filter == FILTER_NEAREST ? SDL_SCALEMODE_NEAREST : SDL_SCALEMODE_LINEAR);
}
if (gameCanvas == nullptr)
{
if (options->console)

View File

@@ -6,6 +6,13 @@
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // for stbi_failure_reason, stbi_image_free
SDL_ScaleMode Texture::currentScaleMode = SDL_SCALEMODE_NEAREST;
void Texture::setGlobalScaleMode(SDL_ScaleMode mode)
{
currentScaleMode = mode;
}
// Constructor
Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose)
{
@@ -96,6 +103,9 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer, bool verbos
// Obtiene las dimensiones de la imagen
this->width = loadedSurface->w;
this->height = loadedSurface->h;
// Aplica el modo de escalado
SDL_SetTextureScaleMode(newTexture, currentScaleMode);
}
// Elimina la textura cargada
@@ -121,6 +131,7 @@ bool Texture::createBlank(SDL_Renderer *renderer, int width, int height, SDL_Tex
{
this->width = width;
this->height = height;
SDL_SetTextureScaleMode(texture, currentScaleMode);
}
return texture != nullptr;

View File

@@ -16,6 +16,11 @@ private:
std::string path; // Ruta de la imagen de la textura
public:
static SDL_ScaleMode currentScaleMode; // Modo de escalado global para nuevas texturas
// Establece el modo de escalado global para nuevas texturas
static void setGlobalScaleMode(SDL_ScaleMode mode);
// Constructor
Texture(SDL_Renderer *renderer, std::string path = "", bool verbose = false);

View File

@@ -473,6 +473,8 @@ void Title::update()
options->filter = FILTER_NEAREST;
else
options->filter = FILTER_LINEAL;
Texture::setGlobalScaleMode(options->filter == FILTER_NEAREST ? SDL_SCALEMODE_NEAREST : SDL_SCALEMODE_LINEAR);
reLoadTextures();
updateMenuLabels();
break;
@@ -1058,6 +1060,10 @@ void Title::createTiledBackground()
{
// Crea la textura para el mosaico de fondo
background = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH * 2, GAMECANVAS_HEIGHT * 2);
if (background != nullptr)
{
SDL_SetTextureScaleMode(background, Texture::currentScaleMode);
}
if (background == nullptr)
{
if (options->console)

View File

@@ -20,7 +20,7 @@ struct JA_Music_t;
struct JA_Sound_t;
// Textos
constexpr const char *TEXT_COPYRIGHT = "@2020,2023 JailDesigner (v2.3.2)";
constexpr const char *TEXT_COPYRIGHT = "@2020 JailDesigner (v2.3.3)";
// Contadores
constexpr int TITLE_COUNTER = 800;