Stretched Drawing in OpenGL ES - iOS?

The code you are showing will draw a perfect circle in world co-ordinates. What you need to consider is how those world co-ordinates transform into window co-ordinates i.e. Pixels If the glViewport is set to always match the window then it's the aspect ratio of the window that will determine what you see using the code sample you have shown.

If the window is square it will work i.e. You will see a perfect circle. If the window is taller than it is wide then the circle will be stretched vertically To preserve the perfect circle you can use a projection matrix that gives you a viewing volume of the same aspect ratio as the viewport/window.

I noticed that before your first edit you had a call to glOrthof in there. Set the aspect ratio to match there and that will do the job for you. If you want a perspective projection instead of an orthographic projection then use glFrustum.

The code you are showing will draw a perfect circle in world co-ordinates. What you need to consider is how those world co-ordinates transform into window co-ordinates i.e. Pixels.

If the glViewport is set to always match the window then it's the aspect ratio of the window that will determine what you see using the code sample you have shown. If the window is square it will work i.e. You will see a perfect circle.

If the window is taller than it is wide then the circle will be stretched vertically. To preserve the perfect circle you can use a projection matrix that gives you a viewing volume of the same aspect ratio as the viewport/window. I noticed that before your first edit you had a call to glOrthof in there.

Set the aspect ratio to match there and that will do the job for you. If you want a perspective projection instead of an orthographic projection then use glFrustum.

Thanks. I combined your solution with the one I got at stackoverflow. Com/questions/1067833/… and it helped me.

Although I could not get the glViewPort/glOrthof thing working, I created a new matrix with values (as below) and loaded it: GLfloat aspectRatio = self.view.bounds.size. Height/self.view.bounds.size. Width; float m16 = { aspectRatio, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; glMatrixMode(GL_PROJECTION); glLoadMatrixf(m); It's crazy -> it works, but I don't understand how.

– Ravi Aug 9 at 21:17.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions