- Actualizar proyecto de vibe3_physics a vibe4_shaders - Crear sistema modular de renderizado con RendererInterface - Añadir WindowManager para gestión de ventana y backends - Implementar backends: SDL (fallback), Vulkan, Metal - Añadir soporte para efectos CRT en software - Migrar sistema de renderizado a batch processing - Actualizar README con nueva arquitectura NOTA: Funcionalidad básica necesita restauración (texto y texturas) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
// Forward declarations
|
|
struct SDL_Window;
|
|
|
|
namespace vibe4 {
|
|
|
|
// Tipos de backend disponibles
|
|
enum class BackendType {
|
|
METAL, // macOS
|
|
VULKAN, // Windows/Linux
|
|
SDL // Fallback básico
|
|
};
|
|
|
|
// Estructura para vértices de sprite
|
|
struct SpriteVertex {
|
|
float x, y; // Posición
|
|
float u, v; // Coordenadas de textura
|
|
float r, g, b, a; // Color
|
|
};
|
|
|
|
// Estructura para datos de sprite individual
|
|
struct SpriteData {
|
|
float x, y, w, h; // Posición y tamaño
|
|
float r, g, b; // Color RGB (0-255)
|
|
};
|
|
|
|
// Parámetros de efectos CRT
|
|
struct CRTParams {
|
|
float scanline_intensity = 0.5f;
|
|
float curvature_x = 0.1f;
|
|
float curvature_y = 0.1f;
|
|
float bloom_factor = 1.2f;
|
|
float mask_brightness = 0.8f;
|
|
bool enable_scanlines = true;
|
|
bool enable_curvature = true;
|
|
bool enable_bloom = true;
|
|
};
|
|
|
|
// Interfaz común para todos los backends de renderizado
|
|
class RendererInterface {
|
|
public:
|
|
virtual ~RendererInterface() = default;
|
|
|
|
// Inicialización y limpieza
|
|
virtual bool initialize(SDL_Window* window, int width, int height) = 0;
|
|
virtual void shutdown() = 0;
|
|
|
|
// Control de renderizado
|
|
virtual bool beginFrame() = 0;
|
|
virtual void endFrame() = 0;
|
|
virtual void present() = 0;
|
|
|
|
// Renderizado de fondo degradado
|
|
virtual void renderGradientBackground(
|
|
float top_r, float top_g, float top_b,
|
|
float bottom_r, float bottom_g, float bottom_b
|
|
) = 0;
|
|
|
|
// Batch rendering de sprites
|
|
virtual void renderSpriteBatch(
|
|
const std::vector<SpriteData>& sprites,
|
|
void* texture_data
|
|
) = 0;
|
|
|
|
// Control de efectos CRT
|
|
virtual void setCRTParams(const CRTParams& params) = 0;
|
|
virtual void enableCRT(bool enable) = 0;
|
|
|
|
// Información del backend
|
|
virtual BackendType getBackendType() const = 0;
|
|
virtual const char* getBackendName() const = 0;
|
|
|
|
// Control de V-Sync
|
|
virtual void setVSync(bool enable) = 0;
|
|
|
|
// Redimensionado
|
|
virtual void resize(int width, int height) = 0;
|
|
|
|
protected:
|
|
// Datos comunes
|
|
int screen_width_ = 0;
|
|
int screen_height_ = 0;
|
|
SDL_Window* window_ = nullptr;
|
|
CRTParams crt_params_;
|
|
bool crt_enabled_ = true;
|
|
bool vsync_enabled_ = true;
|
|
};
|
|
|
|
} // namespace vibe4
|