group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
Boilerplate.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <SDL3/SDL.h>
4#include <SDL3/SDL_gpu.h>
5
6#include <backends/imgui_impl_sdlgpu3.h>
7#include <cstddef>
8#include <vector>
9
10namespace Boilerplate
11{
13{
14 const char* path = nullptr;
15 SDL_GPUShaderStage stage = SDL_GPU_SHADERSTAGE_VERTEX;
16 Uint32 samplerCount = 0;
20};
21
23{
24 Uint32 vertexPitch = 0;
25 std::vector<SDL_GPUVertexAttribute> attributes;
26};
27
29{
30 SDL_GPUBuffer* buffer = nullptr;
31 const void* data = nullptr;
32 size_t size = 0;
33};
34
35ImGui_ImplSDLGPU3_InitInfo createImGuiInfo(SDL_GPUDevice* device, SDL_Window* window);
36
37SDL_GPUVertexAttribute
38makeAttribute(Uint32 location, SDL_GPUVertexElementFormat format, Uint32 offset, Uint32 bufferSlot = 0);
39
40SDL_GPUColorTargetInfo makeColorTarget(SDL_GPUTexture* texture, SDL_FColor clearColor);
41
42SDL_GPUDepthStencilTargetInfo makeDepthTarget(SDL_GPUTexture* texture);
43
44SDL_GPUTextureSamplerBinding makeTextureSamplerBinding(SDL_GPUTexture* texture, SDL_GPUSampler* sampler);
45
46SDL_GPUShaderFormat selectShaderFormat(SDL_GPUDevice* device);
47
48SDL_GPUShader* loadShader(SDL_GPUDevice* device,
49 const char* path,
50 SDL_GPUShaderFormat format,
51 SDL_GPUShaderStage stage,
52 Uint32 samplerCount,
53 Uint32 uniformBufferCount,
54 Uint32 storageBufferCount,
55 Uint32 storageTextureCount);
56
57SDL_GPUShader* loadShader(SDL_GPUDevice* device, const ShaderInfo& shaderInfo, SDL_GPUShaderFormat format);
58
59SDL_GPUGraphicsPipeline* createGraphicsPipeline(SDL_GPUDevice* device,
60 SDL_Window* window,
61 SDL_GPUShaderFormat shaderFormat,
62 const ShaderInfo& vertexShaderInfo,
63 const ShaderInfo& fragmentShaderInfo,
64 const VertexInputLayout& vertexInputLayout,
65 bool enableDepth = true);
66
67SDL_GPUBuffer* createBuffer(SDL_GPUDevice* device, size_t bufferSize, SDL_GPUBufferUsageFlags usage);
68
69SDL_GPUTransferBuffer* createTransferBuffer(SDL_GPUDevice* device, size_t transferBufferSize, bool upload);
70
71SDL_GPUTransferBuffer* createUploadBuffer(SDL_GPUDevice* device, size_t transferBufferSize);
72
73void uploadBuffers(SDL_GPUDevice* device, SDL_GPUCommandBuffer* cmd, const std::vector<BufferUpload>& uploads);
74
75SDL_GPUTexture* createTextureRGBA8(SDL_GPUDevice* device, Uint32 width, Uint32 height, const void* data);
76
77SDL_GPUTexture* loadTexture(SDL_GPUDevice* device, const char* path);
78
79SDL_GPUTexture* createDepthTexture(SDL_GPUDevice* device, Uint32 width, Uint32 height);
80
81SDL_GPUSampler* createLinearRepeatSampler(SDL_GPUDevice* device);
82
83} // namespace Boilerplate
Definition Boilerplate.cpp:7
SDL_GPUColorTargetInfo makeColorTarget(SDL_GPUTexture *texture, SDL_FColor clearColor)
Definition Boilerplate.cpp:28
SDL_GPUTexture * createTextureRGBA8(SDL_GPUDevice *device, Uint32 width, Uint32 height, const void *data)
Definition Boilerplate.cpp:263
SDL_GPUShader * loadShader(SDL_GPUDevice *device, const char *path, SDL_GPUShaderFormat format, SDL_GPUShaderStage stage, Uint32 samplerCount, Uint32 uniformBufferCount, Uint32 storageBufferCount, Uint32 storageTextureCount)
Definition Boilerplate.cpp:75
void uploadBuffers(SDL_GPUDevice *device, SDL_GPUCommandBuffer *cmd, const std::vector< BufferUpload > &uploads)
Definition Boilerplate.cpp:212
SDL_GPUTransferBuffer * createUploadBuffer(SDL_GPUDevice *device, size_t transferBufferSize)
Definition Boilerplate.cpp:207
SDL_GPUSampler * createLinearRepeatSampler(SDL_GPUDevice *device)
Definition Boilerplate.cpp:364
SDL_GPUGraphicsPipeline * createGraphicsPipeline(SDL_GPUDevice *device, SDL_Window *window, SDL_GPUShaderFormat shaderFormat, const ShaderInfo &vertexShaderInfo, const ShaderInfo &fragmentShaderInfo, const VertexInputLayout &vertexInputLayout, bool enableDepth)
Definition Boilerplate.cpp:132
SDL_GPUVertexAttribute makeAttribute(Uint32 location, SDL_GPUVertexElementFormat format, Uint32 offset, Uint32 bufferSlot)
Definition Boilerplate.cpp:18
SDL_GPUBuffer * createBuffer(SDL_GPUDevice *device, size_t bufferSize, SDL_GPUBufferUsageFlags usage)
Definition Boilerplate.cpp:189
SDL_GPUTexture * loadTexture(SDL_GPUDevice *device, const char *path)
Definition Boilerplate.cpp:323
SDL_GPUTransferBuffer * createTransferBuffer(SDL_GPUDevice *device, size_t transferBufferSize, bool upload)
Definition Boilerplate.cpp:198
SDL_GPUDepthStencilTargetInfo makeDepthTarget(SDL_GPUTexture *texture)
Definition Boilerplate.cpp:38
SDL_GPUTextureSamplerBinding makeTextureSamplerBinding(SDL_GPUTexture *texture, SDL_GPUSampler *sampler)
Definition Boilerplate.cpp:52
ImGui_ImplSDLGPU3_InitInfo createImGuiInfo(SDL_GPUDevice *device, SDL_Window *window)
Definition Boilerplate.cpp:8
SDL_GPUShaderFormat selectShaderFormat(SDL_GPUDevice *device)
Definition Boilerplate.cpp:60
SDL_GPUTexture * createDepthTexture(SDL_GPUDevice *device, Uint32 width, Uint32 height)
Definition Boilerplate.cpp:345
Definition Boilerplate.hpp:29
SDL_GPUBuffer * buffer
Definition Boilerplate.hpp:30
const void * data
Definition Boilerplate.hpp:31
size_t size
Definition Boilerplate.hpp:32
Definition Boilerplate.hpp:13
SDL_GPUShaderStage stage
Definition Boilerplate.hpp:15
Uint32 uniformBufferCount
Definition Boilerplate.hpp:17
Uint32 storageBufferCount
Definition Boilerplate.hpp:18
const char * path
Definition Boilerplate.hpp:14
Uint32 storageTextureCount
Definition Boilerplate.hpp:19
Uint32 samplerCount
Definition Boilerplate.hpp:16
Definition Boilerplate.hpp:23
std::vector< SDL_GPUVertexAttribute > attributes
Definition Boilerplate.hpp:25
Uint32 vertexPitch
Definition Boilerplate.hpp:24