Files
vibe1_delta/source/external/texture.h
Sergio Valor 0474c3166d Implementar batch rendering con SDL_RenderGeometry para rendimiento masivo
- Reemplazar 50K+ llamadas SDL_RenderTexture individuales por 1 SDL_RenderGeometry
- Crear sistema de acumulacion de vertices y indices para batch rendering
- Añadir addSpriteToBatch() para generar quads con posicion, UV y color
- Implementar getters Ball::getPosition() y getColor() para batch data
- Añadir Texture::getSDLTexture() para acceso directo a textura SDL
- Conversion correcta colores Uint8 a float para SDL_Vertex.color
- Arquitectura: 4 vertices + 6 indices por sprite (2 triangulos)

Rendimiento conseguido:
- 50K bolas: 10 FPS -> >75 FPS constante (mejora 750%)
- 100K bolas: inutilizable -> fluido y jugable
- Escalabilidad masiva para renderizado de sprites

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-15 12:12:50 +02:00

44 lines
1.0 KiB
C++

#pragma once
#include <SDL3/SDL_rect.h> // Para SDL_FRect
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <string> // Para std::string
class Texture
{
private:
SDL_Renderer *renderer_;
SDL_Texture *texture_;
// Dimensiones de la imagen
int width_;
int height_;
public:
// Inicializa las variables
explicit Texture(SDL_Renderer *renderer);
Texture(SDL_Renderer *renderer, const std::string &file_path);
// Libera la memoria
~Texture();
// Carga una imagen desde la ruta especificada
bool loadFromFile(const std::string &path);
// Libera la textura
void free();
// Renderiza la textura en el punto especificado
void render(SDL_FRect *src = nullptr, SDL_FRect *dst = nullptr);
// Obtiene las dimensiones de la imagen
int getWidth();
int getHeight();
// Modula el color de la textura
void setColor(int r, int g, int b);
// Getter para batch rendering
SDL_Texture* getSDLTexture() const { return texture_; }
};