Files
vibe4_shaders/source/backends/sdl_renderer.h
Sergio Valor 6a84234265 Implementar arquitectura multi-backend para vibe4_shaders
- 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>
2025-09-27 23:07:48 +02:00

59 lines
1.6 KiB
C++

#pragma once
#include "renderer_interface.h"
#include <SDL3/SDL_render.h>
#include <vector>
namespace vibe4 {
// Implementación básica usando SDL_Renderer como fallback
class SDLRenderer : public RendererInterface {
public:
SDLRenderer();
~SDLRenderer() override;
// Implementación de la interfaz
bool initialize(SDL_Window* window, int width, int height) override;
void shutdown() override;
bool beginFrame() override;
void endFrame() override;
void present() override;
void renderGradientBackground(
float top_r, float top_g, float top_b,
float bottom_r, float bottom_g, float bottom_b
) override;
void renderSpriteBatch(
const std::vector<SpriteData>& sprites,
void* texture_data
) override;
void setCRTParams(const CRTParams& params) override;
void enableCRT(bool enable) override;
BackendType getBackendType() const override { return BackendType::SDL; }
const char* getBackendName() const override { return "SDL Fallback"; }
void setVSync(bool enable) override;
void resize(int width, int height) override;
private:
SDL_Renderer* renderer_ = nullptr;
SDL_Texture* sprite_texture_ = nullptr;
// Buffers para batch rendering
std::vector<SDL_Vertex> batch_vertices_;
std::vector<int> batch_indices_;
// Métodos auxiliares
void addSpriteToBatch(float x, float y, float w, float h, float r, float g, float b);
void clearBatch();
void renderBatch();
// Simulación básica de efectos CRT (sin shaders reales)
void applyCRTEffectsToColor(float& r, float& g, float& b, float x, float y);
};
} // namespace vibe4