I am attempting to recreate my simple RTS game from libGDX in SDL3. I have been messing around with setting a background texture the size of my world and then using a SDL_FRect as a viewport. So far this approach works out but whenever the viewport pans over the texture, the texture starts to stretch and becomes distorted. I know im missing something but I cant quite figure it out. I realized that libGDX did a lot of the leg-work when it comes to window and viewport rendering compared to SDL3.
Camera
Camera(int pWidth, int pHeight, int pWorldWidth, int pWorldHeight)
{
mWorldWidth = pWorldWidth;
mWorldHeight = pWorldHeight;
mViewport = {0, 0, (float)pWidth, (float)pHeight};
}
Where camera and the world texture are rendered
void renderWorld()
{
SDL_FRect dst = {0,0,WORLD_WIDTH, WORLD_HEIGHT};
SDL_RenderTexture(mRenderer, mWorldTexture, &mCamera->getViewport(),&dst);
}
I apologize if this is a duplicate question, I honestly could not find a thread that wasnt “heres how to have the camera follow the player”.