Suggestion for SDL3 - RenderTextureQuad

I see there’s a RenderTextureAffine function, but I wish there were an option to adjust all four corners of the destination rectangle with perspective correction—without having to set up an OpenGL context or use GPU with shaders directly. This is a function I could make use of.

so you have this struct with a tex_coord member:

then you can use:

less ideal suggestion

hey, would you benefit from this:

SDL3/SDL_RenderGeometryRaw - SDL Wiki

I never used this function, but its const float *uv parameter is very suggestive

So far I have tried SDL_RenderGeometry but have not found a way to avoid distortion. I will give SDL_RenderGeometryRAW a shot. It seems like it might work if I create a rectangle out of 4 triangles that meet in the center with some manual calculations. Thanks for the suggestion.

There’s no z index in SDL_RenderGeometry so you can’t use it to render a quad with correct rasterization. For 3D you should use GPU API. I believe 2D API will not get anything 3D relate-ish like this.

If performance is not critical you can split your quad to N triangles to get somewhat bearable distortion.

2 Likes

I see my error, thanks