10#include <SDL3/SDL_gpu.h>
32 SDL_GPUTextureFormat suggested_depth_format);
90 void drawViews(SDL_GPURenderPass *pass, std::span<const MeshView> meshViews,
91 Uint32 numInstances = 1);
101 inline void draw(SDL_GPURenderPass *pass,
const Mesh &mesh,
102 Uint32 numInstances = 1) {
112 Uint32 numInstances = 1);
117 std::span<const SDL_GPUTextureSamplerBinding> bindings) {
118 SDL_BindGPUVertexSamplers(pass, first_slot, bindings.data(),
119 Uint32(bindings.size()));
125 SDL_GPURenderPass *pass, Uint32 first_slot,
126 std::initializer_list<SDL_GPUTextureSamplerBinding> sampler_bindings) {
133 std::span<const SDL_GPUTextureSamplerBinding> bindings) {
134 SDL_BindGPUFragmentSamplers(pass, first_slot, bindings.data(),
135 Uint32(bindings.size()));
141 SDL_GPURenderPass *pass, Uint32 first_slot,
142 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
Definition RenderContext.h:68
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 RenderContext.h:101
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 RenderContext.h:132
void bindVertexSamplers(SDL_GPURenderPass *pass, Uint32 first_slot, std::span< const SDL_GPUTextureSamplerBinding > bindings)
Bind multiple fragment shader samplers.
Definition RenderContext.h:116
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
Device device
Definition RenderContext.h:21
CommandBuffer acquireCommandBuffer() const
Acquire the command buffer, starting a frame.
Definition RenderContext.h:41
void destroy() noexcept
Definition RenderContext.h:65
Texture depth_texture
Definition RenderContext.h:24
RenderContext(NoInitT)
Definition RenderContext.h:26
bool waitAndAcquireSwapchain(CommandBuffer &command_buffer)
Wait until swapchain is available, then acquire it.
Window window
Definition RenderContext.h:22
bool initialized() const
Definition RenderContext.h:38
void createDepthTexture(SDL_GPUTextureFormat suggested_depth_format)
Add a depth texture to the rendering context.
RenderContext(Device &&device, Window &&window, SDL_GPUTextureFormat suggested_depth_format)
Constructor with a depth format. This will create a depth texture.
SDL_GPUTexture * swapchain
Definition RenderContext.h:23
~RenderContext() noexcept
SDL_GPUTextureFormat depthFormat() const
Definition RenderContext.h:61
SDL_GPUTextureFormat getSwapchainTextureFormat() const
Definition RenderContext.h:54
bool waitForSwapchain()
Definition RenderContext.h:52
bool acquireSwapchain(CommandBuffer &command_buffer)
Acquire GPU swapchain.
bool hasDepthTexture() const
Check if a depth texture was created.
Definition RenderContext.h:59
RenderContext(Device &&device, Window &&window)
Constructor without a depth format.
RAII wrapper for the SDL_Window opaque type.
Definition Window.h:11