10#include <SDL3/SDL_gpu.h>
31 SDL_GPUTextureFormat suggested_depth_format);
89 void drawViews(SDL_GPURenderPass *pass, std::span<const MeshView> meshViews,
90 Uint32 numInstances = 1);
100 inline void draw(SDL_GPURenderPass *pass,
const Mesh &mesh,
101 Uint32 numInstances = 1) {
111 Uint32 numInstances = 1);
116 std::span<const SDL_GPUTextureSamplerBinding> bindings) {
117 SDL_BindGPUVertexSamplers(pass, first_slot, bindings.data(),
118 Uint32(bindings.size()));
124 SDL_GPURenderPass *pass, Uint32 first_slot,
125 std::initializer_list<SDL_GPUTextureSamplerBinding> sampler_bindings) {
132 std::span<const SDL_GPUTextureSamplerBinding> bindings) {
133 SDL_BindGPUFragmentSamplers(pass, first_slot, bindings.data(),
134 Uint32(bindings.size()));
140 SDL_GPURenderPass *pass, Uint32 first_slot,
141 std::initializer_list<SDL_GPUTextureSamplerBinding> sampler_bindings) {
Definition CommandBuffer.h:17
A view into a Mesh object.
Definition Mesh.h:22
Handle class for meshes (vertex buffers and an optional index buffer) on the GPU.
Definition Mesh.h:57
std::span< const MeshView > views() const
Definition Mesh.h:92
void drawView(SDL_GPURenderPass *pass, const MeshView &mesh, Uint32 numInstances=1)
Draw a MeshView.
void bindMeshView(SDL_GPURenderPass *pass, const MeshView &view)
Bind a MeshView object.
void draw(SDL_GPURenderPass *pass, const Mesh &mesh, Uint32 numInstances=1)
Definition Renderer.h:100
void bindMesh(SDL_GPURenderPass *pass, const Mesh &mesh)
Bind a Mesh object.
void drawViews(SDL_GPURenderPass *pass, std::span< const MeshView > meshViews, Uint32 numInstances=1)
Render a collection of MeshView. This collection must satisfy the invariant that they all have the sa...
void bindFragmentSamplers(SDL_GPURenderPass *pass, Uint32 first_slot, std::span< const SDL_GPUTextureSamplerBinding > bindings)
Bind multiple fragment shader samplers.
Definition Renderer.h:131
void bindVertexSamplers(SDL_GPURenderPass *pass, Uint32 first_slot, std::span< const SDL_GPUTextureSamplerBinding > bindings)
Bind multiple fragment shader samplers.
Definition Renderer.h:115
constexpr NoInitT NoInit
Definition Tags.h:9
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
Tag type for non-initializing constructors (for e.g. RAII classes)
Definition Tags.h:6
bool initialized() const
Definition Renderer.h:37
Renderer(Device &&device, Window &&window, SDL_GPUTextureFormat suggested_depth_format)
Constructor with a depth format. This will create a depth texture.
Device device
Definition Renderer.h:21
SDL_GPUTextureFormat getSwapchainTextureFormat() const
Definition Renderer.h:53
SDL_GPUTextureFormat depthFormat() const
Definition Renderer.h:60
CommandBuffer acquireCommandBuffer() const
Acquire the command buffer, starting a frame.
Definition Renderer.h:40
bool acquireSwapchain(CommandBuffer &command_buffer)
Acquire GPU swapchain.
bool waitForSwapchain()
Definition Renderer.h:51
bool hasDepthTexture() const
Check if a depth texture was created.
Definition Renderer.h:58
SDL_GPUTexture * swapchain
Definition Renderer.h:23
Renderer(Device &&device, Window &&window)
Constructor without a depth format.
Window window
Definition Renderer.h:22
Texture depth_texture
Definition Renderer.h:24
Renderer(NoInitT)
Definition Renderer.h:26
void createDepthTexture(SDL_GPUTextureFormat suggested_depth_format)
Add a depth texture to the rendering context.
bool waitAndAcquireSwapchain(CommandBuffer &command_buffer)
Wait until swapchain is available, then acquire it.
RAII wrapper for the SDL_Window opaque type.
Definition Window.h:11