primer commit

This commit is contained in:
2025-04-08 08:23:18 +02:00
parent 94c89b7ced
commit b6682fe7ff
30 changed files with 18573 additions and 1 deletions

109
source/screen.h Normal file
View File

@@ -0,0 +1,109 @@
#pragma once
#include <SDL3/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL3/SDL_stdinc.h> // for Uint8
#include <SDL3/SDL_video.h> // for SDL_Window
#include <memory> // for shared_ptr
#include "options.h" // for Options, OptionsVideo, options
#include "surface.h" // for Surface
#include "utils.h" // for Color
class Screen
{
private:
// Constantes
static constexpr int WINDOWS_DECORATIONS_ = 35;
// [SINGLETON] Objeto privado
static Screen *screen_;
// Objetos y punteros
SDL_Window *window_; // Ventana de la aplicación
SDL_Renderer *renderer_; // El renderizador de la ventana
SDL_Texture *game_texture_; // Textura donde se dibuja el juego
std::shared_ptr<Surface> game_surface_; // Surface principal para manejar game_surface_data_
std::shared_ptr<std::shared_ptr<Surface>> renderer_surface_; // Puntero a la Surface que actua
// Variables
int window_width_; // Ancho de la pantalla o ventana
int window_height_; // Alto de la pantalla o ventana
// Arranca SDL VIDEO y crea la ventana
bool initSDL();
// Calcula el tamaño de la ventana
void adjustWindowSize();
// Copia la surface a la textura
void surfaceToTexture();
// Copia la textura al renderizador
void textureToRenderer();
// Obtiene información sobre la pantalla
void getDisplayInfo();
// Constructor
Screen();
// Destructor
~Screen();
public:
// [SINGLETON] Crearemos el objeto con esta función estática
static void init();
// [SINGLETON] Destruiremos el objeto con esta función estática
static void destroy();
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
static Screen *get();
// Limpia el renderer
void clearRenderer(Color color = {0x00, 0x00, 0x00});
// Limpia la game_surface_
void clearSurface(Uint8 index);
// Prepara para empezar a dibujar en la textura de juego
void start();
// Vuelca el contenido del renderizador en pantalla
void render();
// Actualiza la lógica de la clase
void update();
// Establece el modo de video
void setFullscreenMode(bool mode = options.video.fullscreen);
// Cambia entre pantalla completa y ventana
void toggleFullscreen();
// Reduce el tamaño de la ventana
bool decWindowZoom();
// Aumenta el tamaño de la ventana
bool incWindowZoom();
// Muestra la ventana
void show();
// Oculta la ventana
void hide();
// Establece el renderizador para las surfaces
void setRendererSurface(std::shared_ptr<Surface> surface = nullptr);
// Activa / desactiva el escalado entero
void toggleIntegerScale();
// Activa / desactiva el vsync
void toggleVSync();
// Getters
SDL_Renderer *getRenderer();
std::shared_ptr<Surface> getRendererSurface();
};