0
\$\begingroup\$

I'm currently working on a project in which I render pictures raw. That is I use simple IMG_LoadTexture(), SDL_RenderCopy(). I want the program to be able to zoom in/out and textures to be scaled to screenwidth/height. I googled it but most of the answers for this question was outdated. Can I achieve this in SDL2. If not what's the way of doing this.

\$\endgroup\$
1

1 Answer 1

2
\$\begingroup\$

By using SDL_RenderCopy you can do all the zoom in/out or scaling stuff, by using non null values for the srcrect and dstrect parameters.

Here is the prototype of the function :

int SDL_RenderCopy(SDL_Renderer*   renderer,
                   SDL_Texture*    texture,
                   const SDL_Rect* srcrect,
                   const SDL_Rect* dstrect)

So you just need to create two SDL_Rect and setup them accordingly.

\$\endgroup\$
1
  • \$\begingroup\$ Src rectangle represents the area in your image that you want to show on screen. Dst rectangle is the screen area where you want to show it. Whenever src rect is smaller than your image size you are zooming in. Just test it / read the doc... \$\endgroup\$ Aug 29, 2015 at 10:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .