Arreglos tontos de codi

This commit is contained in:
2025-02-23 09:12:15 +01:00
parent a42141ebd7
commit f43d18e6f0
8 changed files with 10 additions and 37 deletions

View File

@@ -316,12 +316,10 @@ bool Director::initSDL()
std::cout << "Warning: texture filtering not enabled!\n";
}
#ifndef NO_SHADERS
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
{
std::cout << "Warning: opengl not enabled!\n";
}
#endif
// Crea la ventana
window_ = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param.game.width * options.video.window.size, param.game.height * options.video.window.size, SDL_WINDOW_HIDDEN);
@@ -339,10 +337,8 @@ bool Director::initSDL()
flags = SDL_RENDERER_PRESENTVSYNC;
}
#ifndef NO_SHADERS
// La aceleración se activa según el define
flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
#endif
renderer_ = SDL_CreateRenderer(window_, -1, flags);

View File

@@ -1,5 +1,3 @@
#ifndef NO_SHADERS
#include "jail_shader.h"
#include <SDL2/SDL_rect.h> // para SDL_Point
#include <stdlib.h> // para NULL, free, malloc, exit
@@ -247,5 +245,4 @@ namespace shader
SDL_RenderPresent(renderer);
}
}
}
#endif
}

View File

@@ -1,5 +1,3 @@
#ifndef NO_SHADERS
#pragma once
#include <SDL2/SDL_render.h> // para SDL_Texture
@@ -44,5 +42,4 @@ namespace shader
const char *vertexShader, const char *fragmentShader = nullptr);
void render();
}
#endif
}

View File

@@ -53,9 +53,6 @@ Logo::Logo()
color_.push_back(Color(0x00, 0xd8, 0xd8)); // Cyan
color_.push_back(Color(0xd8, 0xd8, 0x00)); // Yellow
color_.push_back(Color(0xFF, 0xFF, 0xFF)); // Bright white
mi_textura = copyTextureToTarget(Screen::get()->getRenderer(), Resource::get()->getTexture("logo_retroweekend.png")->getSDLTexture());
pixels_ = extractPixels(mi_textura);
}
// Destructor

View File

@@ -12,22 +12,22 @@
#include "texture.h" // Para Texture
#include "resource.h"
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
// [SINGLETON]
Notifier *Notifier::notifier_ = nullptr;
// [SINGLETON] Crearemos el objeto screen con esta función estática
// [SINGLETON] Crearemos el objeto con esta función estática
void Notifier::init(const std::string &icon_file, std::shared_ptr<Text> text)
{
Notifier::notifier_ = new Notifier(icon_file, text);
}
// [SINGLETON] Destruiremos el objeto screen con esta función estática
// [SINGLETON] Destruiremos el objeto con esta función estática
void Notifier::destroy()
{
delete Notifier::notifier_;
}
// [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
Notifier *Notifier::get()
{
return Notifier::notifier_;

View File

@@ -13,7 +13,7 @@ class Texture; // lines 11-11
class Notifier
{
private:
// [SINGLETON] Objeto notifier privado para Don Melitón
// [SINGLETON] Objeto notifier
static Notifier *notifier_;
enum class NotificationStatus
@@ -77,13 +77,13 @@ private:
~Notifier() = default;
public:
// [SINGLETON] Crearemos el objeto notifier con esta función estática
// [SINGLETON] Crearemos el objeto con esta función estática
static void init(const std::string &icon_file, std::shared_ptr<Text> text);
// [SINGLETON] Destruiremos el objeto notifier con esta función estática
// [SINGLETON] Destruiremos el objeto con esta función estática
static void destroy();
// [SINGLETON] Con este método obtenemos el objeto notifier y podemos trabajar con él
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
static Notifier *get();
// Dibuja las notificaciones por pantalla

View File

@@ -15,10 +15,7 @@
#include "on_screen_help.h" // Para OnScreenHelp
#include "options.h" // Para Options, OptionsVideo, options, Options...
#include "mouse.h"
#ifndef NO_SHADERS
#include "jail_shader.h" // para init, render
#endif
// [SINGLETON]
Screen *Screen::screen_ = nullptr;
@@ -105,11 +102,6 @@ void Screen::renderScreen()
SDL_SetRenderTarget(renderer_, nullptr);
clean();
#ifdef NO_SHADERS
// Actualiza la pantalla con el contenido del buffer de renderizado
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
SDL_RenderPresent(renderer_);
#else
if (options.video.shaders)
{
// Aplica shaders y renderiza el contenido
@@ -121,7 +113,6 @@ void Screen::renderScreen()
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
SDL_RenderPresent(renderer_);
}
#endif
}
// Establece el modo de video
@@ -174,13 +165,11 @@ void Screen::setVideoMode(ScreenVideoMode videoMode)
// Reinicia los shaders
if (options.video.shaders)
{
#ifndef NO_SHADERS
const std::string glsl_file = param.game.game_area.rect.h == 256 ? "crtpi_256.glsl" : "crtpi_240.glsl";
std::ifstream f(Asset::get()->get(glsl_file).c_str());
std::string source((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
shader::init(window_, game_canvas_, source.c_str());
#endif
}
}

View File

@@ -110,9 +110,6 @@ private:
// Calcula la nueva posición de la ventana a partir de la antigua al cambiarla de tamaño
SDL_Point getNewPosition();
// Actualiza la pantalla con el contenido del game_canvas_
void presentGameCanvas();
// Selecciona y ejecuta el método de renderizado adecuado basado en la configuración de shaders
void renderScreen();