# Rendering scaled clip?

**URL:** <https://discourse.libsdl.org/t/rendering-scaled-clip/320>\
**Category:** Game Development\
**Created:** [June 25, 2016, 6:11pm UTC](https://discourse.libsdl.org/t/rendering-scaled-clip/320 "2016-06-25T18:11:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kelvin](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/k/7ba0ec/32.png) [@Kelvin](https://discourse.libsdl.org/u/Kelvin)\
**Post date:** [June 25, 2016, 6:11pm UTC](https://discourse.libsdl.org/t/rendering-scaled-clip/320/1 "2016-06-25T18:11:10Z")

</div>

So, I found SDL\_RenderCopyEx to be a lot of help with rendering flipped and rotated sprites, but I can’t find anything on scaling. I found SDL\_RenderSetScale, but that changes the scale of EVERYTHING, not just what’s being drawn, and even affects the coordinates I’m drawing to. How would I go about just drawing a scaled clip?

---

<div class="post-metadata">

**Author:** ![Kelvin](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/k/7ba0ec/32.png) [@Kelvin](https://discourse.libsdl.org/u/Kelvin)\
**Post date:** [June 25, 2016, 6:14pm UTC](https://discourse.libsdl.org/t/rendering-scaled-clip/320/2 "2016-06-25T18:14:06Z")

</div>

Also, on the note of scaling, I found how to compensate for the scale of the renderer when drawing to mouse coordinates, except that when the render area has a thinner aspect than the window, it makes a letterbox on the sides, and this letterbox still counts as an area for it to check when getting the mouse coordinates. How do I get the renderer’s actual position on the window?

I would have put this in the first post, but the forum isn’t letting me edit.

---

<div class="post-metadata">

**Author:** ![Daniel1985](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/d/a5b964/32.png) [@Daniel1985](https://discourse.libsdl.org/u/Daniel1985)\
**Post date:** [June 26, 2016, 9:53am UTC](https://discourse.libsdl.org/t/rendering-scaled-clip/320/3 "2016-06-26T09:53:27Z")

</div>

Here’s a code example on how to scale a texture, which is also clipped

```
// Pretend a texture has been successfully created

// The texture will be positioned at 200x200 and it's size will be 256x256
SDL_Rect Quad = {200, 200, 256, 256};

// The texture in my case is 768x128 in size but only 128x128 pixels of it will be rendered
SDL_Rect ClipQuad = {0, 0, 128, 128};

// The size of the texture is chosen by "Quad"'s size (256x256)
SDL_RenderCopyEx(Renderer, MyTexture, &ClipQuad, &Quad, 0.0, NULL, SDL_FLIP_NONE);

```

Hopefully this will help you understand how it’s works. Let me know if you have any more questions.

---

<div class="post-metadata">

**Author:** ![bigov](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bigov](https://discourse.libsdl.org/u/bigov)\
**Post date:** [July 7, 2016, 3:53am UTC](https://discourse.libsdl.org/t/rendering-scaled-clip/320/4 "2016-07-07T03:53:23Z")

</div>

#include \<glm/gtc/matrix\_transform.hpp\>

```
glm::mat4 glm::scale(glm::mat4 const & m, glm::vec3 const & factors);
```
