diff options
| author | grm <grm@eyesin.space> | 2026-03-14 02:29:15 +0200 |
|---|---|---|
| committer | grm <grm@eyesin.space> | 2026-03-14 02:29:15 +0200 |
| commit | 650e5afde271d22b3653832daf339e1bd09a10d6 (patch) | |
| tree | cc5e536b0150de1109daa43a055547d2266e60dd /lib/imgui-1.92.6/backends/sdlgpu3 | |
| parent | 20e64711ce2a09b657fb79d59cb824e9e34d2b07 (diff) | |
| download | cgame-master.tar.gz cgame-master.tar.bz2 cgame-master.zip | |
Diffstat (limited to 'lib/imgui-1.92.6/backends/sdlgpu3')
| -rw-r--r-- | lib/imgui-1.92.6/backends/sdlgpu3/build_instructions.txt | 42 | ||||
| -rw-r--r-- | lib/imgui-1.92.6/backends/sdlgpu3/shader.frag | 15 | ||||
| -rw-r--r-- | lib/imgui-1.92.6/backends/sdlgpu3/shader.vert | 24 |
3 files changed, 81 insertions, 0 deletions
diff --git a/lib/imgui-1.92.6/backends/sdlgpu3/build_instructions.txt b/lib/imgui-1.92.6/backends/sdlgpu3/build_instructions.txt new file mode 100644 index 0000000..79a0920 --- /dev/null +++ b/lib/imgui-1.92.6/backends/sdlgpu3/build_instructions.txt @@ -0,0 +1,42 @@ + +Instructions to rebuild imgui_impl_sdlgpu3_shaders.h +(You don't need to copy this folder if you are using the backend as-is) + +1) Compile the raw shader files to SPIRV: + + glslc -o vertex.spv -c shader.vert + glslc -o fragment.spv -c shader.frag + + +2) Build SDL_shadercross (https://github.com/libsdl-org/SDL_shadercross) + + +3-A) Compiling for the Vulkan Driver: + + Nothing to do, you just need the previous vertex.spv/fragment.spv, proceed to step 4 + + +3-B) Compiling for the DirectX 12 Driver: + + ./shadercross vertex.spv -s SPIRV -d DXBC -t vertex -e main -o vertex.dxbc + ./shadercross fragment.spv -s SPIRV -d DXBC -t fragment -e main -o fragment.dxbc + + Proceed to step 4 + + +3-C) Compiling for Metal (On windows you'll need the Metal Developer Tools for Windows, on linux you might use wine, but I never tested it): + + ./shadercross vertex.spv -s SPIRV -d MSL -t vertex -e main -o vertex.metal + ./shadercross fragment.spv -s SPIRV -d MSL -t fragment -e main -o fragment.metal + + xcrun -sdk macosx metal -o vertex.ir -c vertex.metal + xcrun -sdk macosx metal -o fragment.ir -c fragment.metal + xcrun -sdk macosx metallib -o vertex.metallib -c vertex.ir + xcrun -sdk macosx metallib -o fragment.metallib -c fragment.ir + + note: use .metal outputs for updating msl_vertex / msl_fragment variables, and use .metallib outputs for metallib_vertex / metallib_fragment variables + + Proceed to step 4 + + +4) Use a tool like https://notisrac.github.io/FileToCArray/ or misc/fonts/binary_to_compressed_c.cpp in imgui repository to convert the file to a uint8_t array. diff --git a/lib/imgui-1.92.6/backends/sdlgpu3/shader.frag b/lib/imgui-1.92.6/backends/sdlgpu3/shader.frag new file mode 100644 index 0000000..ab9ce18 --- /dev/null +++ b/lib/imgui-1.92.6/backends/sdlgpu3/shader.frag @@ -0,0 +1,15 @@ +#version 450 core +layout(location = 0) out vec4 fColor; + +layout(set=2, binding=0) uniform sampler2D sTexture; + +layout(location = 0) in struct +{ + vec4 Color; + vec2 UV; +} In; + +void main() +{ + fColor = In.Color * texture(sTexture, In.UV.st); +} diff --git a/lib/imgui-1.92.6/backends/sdlgpu3/shader.vert b/lib/imgui-1.92.6/backends/sdlgpu3/shader.vert new file mode 100644 index 0000000..3a85a90 --- /dev/null +++ b/lib/imgui-1.92.6/backends/sdlgpu3/shader.vert @@ -0,0 +1,24 @@ +#version 450 core +layout(location = 0) in vec2 aPos; +layout(location = 1) in vec2 aUV; +layout(location = 2) in vec4 aColor; + +layout(set=1,binding=0) uniform UBO +{ + vec2 uScale; + vec2 uTranslate; +} ubo; + +layout(location = 0) out struct +{ + vec4 Color; + vec2 UV; +} Out; + +void main() +{ + Out.Color = aColor; + Out.UV = aUV; + gl_Position = vec4(aPos * ubo.uScale + ubo.uTranslate, 0, 1); + gl_Position.y *= -1.0f; +} |
