vendredi 6 mars 2015

Rotating a Spirte Rectangle 90 degrees doesn't repect aspect ratio in iOS


am working in a OpenGL ES 2.0 game, in iOS platform using basically C++. And I wanted to implement both both portrait and landscape orientation doing a 90 degrees rotation.


The problem I have is very simple. I have one sprite that is in one rectangle and if I do a rotation of 90 degrees and expected to see the same figure rotated.


The problem I have is that is a noticeable difference in the figure, both in aspect ratio and size.


In one orientation: 8.4 cm x 5.0 cm


The other: 7.6 cm x 5.4 cm


I wonder if it that is posible be casued by errors caused by float machine representation? Has someone had also that problem?


In the first test I do:



glm::mat4 ProjModelViewMatrix = glm::ortho<float>(-1.0, +1.0, -1.5f, 1.5f);

/// DRAW CODE


In the second test I ONLY add a rotation matrix:



glm::mat4 rotation = glm::rotate(glm::mat4(1.0), -PI_F / 2.0f, glm::vec3(0.0f,0.0f,1.0f));

glm::mat4 ProjModelViewMatrix = glm::ortho<float>(-1.0, +1.0, -1.5f, 1.5f) * rotation;

/// DRAW CODE


Just in case: ALL THE vertices are in the plane z=0. The sprite is mapped in a rectangle.




Aucun commentaire:

Enregistrer un commentaire