Am I using SDL_RenderGeometry correctly?

SDL_RenderGeometry() does whatever the underlying hardware does, which is all but guaranteed to be perspective-correct these days.

The problem the OP was having was trying to get a 3D perspective effect using only 2D vertices. The result they were seeing was correct for each 2D triangle. Now, if they were supplying 3D vertices, and SDL was using a perspective projection matrix, and the OP was still getting the results they got then the issue would be that the underlying hardware only supported affine texture mapping.

Basically, SDL_RenderGeometry() isn’t for 3D, it’s for 2D triangles.

Hi,

would you please share the code for this projections using RenderGeometry API?

Sorry to necro this thread but I think SDL3 can do this with SDL_RenderTextureAffine now.

Unfortunately, I think this still doesn’t give you the functionality you need. Affine transformations are the same as linear transformations plus a translation. Thus the affine transformation is defined by the user providing the destination of the top-left, top-right, and bottom-left corners of the texture quad (called origin, right and down in the description of SDL_RenderTextureAffine). Hence, it can map a triangle to a triangle, but you’d need to be able to specify the destination of the fourth corner in order to map a quad to a quad, which is what we need here.