The solution from Ibrahim CS works.
Let me expand this solution and provide code. Another thing to note is to compute the new position (x, y) with the top left to produce a scaled texture.
I do it like this
// calculate new x and y int new_x = (x + texture->w/2) - (texture->w/2 * new_scale); int new_y = (y + texture->h/2) - (texture->h/2 * new_scale); // form new destination rect SDL_Rect dest_rect = { new_x, new_y, texture->w * scale, texture->h * scale }; // render SDL_RenderCopy(renderer, texture, NULL, &dest_rect);
Suppose texture is SDL_Texture and renderer is SDL_Renderer and you are completely SDL_Renderer from the input texture to the destination.
haxpor
source share