neteja tidy a source/core i encamina Texture::loadFromFile pel ResourceHelper

This commit is contained in:
2026-05-14 20:22:54 +02:00
parent 88fa3f296f
commit 1912200b21
40 changed files with 699 additions and 578 deletions
+7 -6
View File
@@ -3,6 +3,7 @@
#include <SDL3/SDL.h>
#include <algorithm> // for max, min
#include <cmath> // for lround
#include <cstring> // for memcpy
#include <iostream> // for basic_ostream, operator<<, cout, endl
#include <string> // for basic_string, char_traits, string
@@ -108,7 +109,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
}
if (gameCanvas == nullptr) {
if (Options::settings.console) {
std::cout << "gameCanvas could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
std::cout << "gameCanvas could not be created!\nSDL Error: " << SDL_GetError() << '\n';
}
}
@@ -351,7 +352,7 @@ void Screen::applyFullscreen(bool fullscreen) {
void Screen::applyWindowedLayout() {
windowWidth = gameCanvasWidth;
windowHeight = gameCanvasHeight;
dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
dest = {.x = 0, .y = 0, .w = gameCanvasWidth, .h = gameCanvasHeight};
#ifdef __EMSCRIPTEN__
windowWidth *= WASM_RENDER_SCALE;
@@ -396,12 +397,12 @@ void Screen::computeFullscreenGameRect() {
float ratio = (float)gameCanvasWidth / (float)gameCanvasHeight;
if ((windowWidth - gameCanvasWidth) >= (windowHeight - gameCanvasHeight)) {
dest.h = windowHeight;
dest.w = (int)((windowHeight * ratio) + 0.5f);
dest.w = static_cast<int>(std::lround(windowHeight * ratio));
dest.x = (windowWidth - dest.w) / 2;
dest.y = (windowHeight - dest.h) / 2;
} else {
dest.w = windowWidth;
dest.h = (int)((windowWidth / ratio) + 0.5f);
dest.h = static_cast<int>(std::lround(windowWidth / ratio));
dest.x = (windowWidth - dest.w) / 2;
dest.y = (windowHeight - dest.h) / 2;
}
@@ -579,7 +580,7 @@ void Screen::toggleShaderEnabled() {
setShaderEnabled(!Options::video.shader.enabled);
}
auto Screen::isShaderEnabled() const -> bool {
auto Screen::isShaderEnabled() -> bool {
return Options::video.shader.enabled;
}
@@ -595,7 +596,7 @@ void Screen::setActiveShader(Rendering::ShaderType type) {
notify(type == Rendering::ShaderType::CRTPI ? "Shader: CRTPI" : "Shader: POSTFX", MAGENTA, BLACK, DUR_MS);
}
auto Screen::getActiveShader() const -> Rendering::ShaderType {
auto Screen::getActiveShader() -> Rendering::ShaderType {
return Options::video.shader.current_shader;
}
#endif