#pragma once #include #include // ============================================================================ // 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; };