- Infraestructura GPU: GpuContext, GpuPipeline, GpuSpriteBatch, GpuTexture - Engine::render() migrat a 2-pass: sprites → offscreen R8G8B8A8 → swapchain + vignette - UI/text via software renderer (SDL3_ttf) + upload com a textura overlay GPU - CMakeLists.txt actualitzat per incloure subsistema gpu/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL_gpu.h>
|
|
#include <SDL3/SDL_video.h>
|
|
|
|
// ============================================================================
|
|
// GpuContext — SDL_GPU device + swapchain wrapper
|
|
// Replaces SDL_Renderer as the main rendering backend.
|
|
// ============================================================================
|
|
class GpuContext {
|
|
public:
|
|
bool init(SDL_Window* window);
|
|
void destroy();
|
|
|
|
SDL_GPUDevice* device() const { return device_; }
|
|
SDL_Window* window() const { return window_; }
|
|
SDL_GPUTextureFormat swapchainFormat() const { return swapchain_format_; }
|
|
|
|
// Per-frame helpers
|
|
SDL_GPUCommandBuffer* acquireCommandBuffer();
|
|
// Returns nullptr if window is minimized (swapchain not available).
|
|
SDL_GPUTexture* acquireSwapchainTexture(SDL_GPUCommandBuffer* cmd_buf,
|
|
Uint32* out_w, Uint32* out_h);
|
|
void submit(SDL_GPUCommandBuffer* cmd_buf);
|
|
|
|
// VSync control (call after init)
|
|
bool setVSync(bool enabled);
|
|
|
|
private:
|
|
SDL_GPUDevice* device_ = nullptr;
|
|
SDL_Window* window_ = nullptr;
|
|
SDL_GPUTextureFormat swapchain_format_ = SDL_GPU_TEXTUREFORMAT_INVALID;
|
|
};
|