SDL Forum Index
SDL
Simple DirectMedia Layer Forums
Reply to topic
Rendering scaled clip?
Kelvin


Joined: 31 Mar 2016
Posts: 4
Reply with quote
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?
View user's profileSend private messageVisit poster's website
Kelvin


Joined: 31 Mar 2016
Posts: 4
Reply with quote
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.
View user's profileSend private messageVisit poster's website
Naith


Joined: 03 Jul 2014
Posts: 158
Reply with quote
Here's a code example on how to scale a texture, which is also clipped

Code:

// 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.
View user's profileSend private message
bigov


Joined: 03 Jul 2016
Posts: 7
Reply with quote
Code:

#include <glm/gtc/matrix_transform.hpp>

glm::mat4 glm::scale(glm::mat4 const & m, glm::vec3 const & factors);
View user's profileSend private message
Rendering scaled clip?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic