migrant a SDL3

This commit is contained in:
2025-03-25 20:26:45 +01:00
parent f1b0303474
commit a9c869baf6
49 changed files with 374 additions and 416 deletions

View File

@@ -1,7 +1,7 @@
#include "text.h"
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_rect.h> // Para SDL_FRect
#include <SDL3/SDL_render.h> // Para SDL_TEXTUREACCESS_TARGET
#include <stddef.h> // Para size_t
#include <fstream> // Para basic_ifstream, basic_istream, basic...
@@ -96,7 +96,7 @@ Text::Text(std::shared_ptr<Texture> texture, const std::string &text_file)
}
// Crea los objetos
sprite_ = std::make_unique<Sprite>(texture, (SDL_Rect){0, 0, box_width_, box_height_});
sprite_ = std::make_unique<Sprite>(texture, (SDL_FRect){0, 0, box_width_, box_height_});
// Inicializa variables
fixed_width_ = false;
@@ -116,7 +116,7 @@ Text::Text(std::shared_ptr<Texture> texture, std::shared_ptr<TextFile> text_file
}
// Crea los objetos
sprite_ = std::make_unique<Sprite>(texture, (SDL_Rect){0, 0, box_width_, box_height_});
sprite_ = std::make_unique<Sprite>(texture, (SDL_FRect){0, 0, box_width_, box_height_});
// Inicializa variables
fixed_width_ = false;
@@ -148,7 +148,7 @@ void Text::write2X(int x, int y, const std::string &text, int kerning)
for (size_t i = 0; i < text.length(); ++i)
{
auto index = static_cast<size_t>(text[i]);
SDL_Rect rect = {offset_[index].x, offset_[index].y, box_width_, box_height_};
SDL_FRect rect = {offset_[index].x, offset_[index].y, box_width_, box_height_};
sprite_->getTexture()->render(x + shift, y, &rect, 2.0f, 2.0f);
shift += (offset_[index].w + kerning) * 2;
}