I am attempting to rotate the sprites in my game, but they get stretched whenever it happens. I know that it is due to the screen not being square, but I can not figure out the correct way to compensate for that.
The left was taken from a non square screen, and the right is from a square screen. I need to scale it in a way that it will be normal again. The code that I am using to move and rotate the sprites is below:
glm::mat4 temp = glm::mat4(1.0f); float angle = glm::radians(45.0f); temp = glm::scale(temp, glm::vec3(xScale,yScale, zScale)); temp = glm::rotate(temp, angle, glm::vec3(0f, 0f, 0f)); temp = glm::translate(temp, glm::vec3(coor, coor, 0.0f)); trans = temp;
coor is just the new coordinate to move the sprite to. What is an equation that can get me the X,Y,and Z Scale? I have access to the screen aspect ratio, and I know it has something to do with it. I tried multiplying it by the screen ratio, but that didn't work. I multiplied them by the sin and cos of the angle, but that didn't work either. What is an equation that works?