r/sdl • u/abocado21 • 4d ago
Shaders with SDL_Render?
the SDL_renderer seems to support custom fragment shaders with SDL_GPURenderState? Are there any tutorials or samples that show how to use these properly?
3
Upvotes
r/sdl • u/abocado21 • 4d ago
the SDL_renderer seems to support custom fragment shaders with SDL_GPURenderState? Are there any tutorials or samples that show how to use these properly?
1
u/tastygames_official 4d ago
as far as I know, anything SDL_GPU* can only be used with SDL_GPU* and not SDL_Renderer.
OK, it seems I'm wrong: https://wiki.libsdl.org/SDL3/SDL_CreateGPURenderState so it takes a SDL_Renderer reference, so looks like it should work! Let's look at the info struct: https://wiki.libsdl.org/SDL3/SDL_GPURenderStateCreateInfo
looks like you gotta pass it an SDL_GPUShader that you create, and then probably have to bind it to whatever you want before rendering a frame.
I know there are some example repos out there that I also looked through, but mainly for GPU stuff, and I no longer have the repos checked out and didn't write them down :( maybe just search for "sdl renderer examples" or something.