# Isometric 2:1 projection in OpenGL

This topic is 4352 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there, I am having problems getting my projection just right. I want a orthographic projection of my world such that it looks just like SimCity 2000, Transport tycoon etc. E.g. I want tiles with a 2:1 ratio on screen.
glMatrixMode(GL_PROJECTION);
glOrtho(-400, +400, -300, +300, -1000, +1000);
glRotated(-orthoAngle, 1, 0, 0);
glRotated(45, 0, 0, 1);


With the angle I calculated having to be arctangens of 2.
double PI = std::acos(-1);
double orthoAngle = (std::atan(2) * 180) / PI;


Now this is nearly correct, it the orthoAngle variable is set to about 63.43 degrees. Now this gives some artifacts in my world, such as the tiles that are being drawn are not exactly in the 2:1 ratio. An orthoAngle of about ~62.09 seems to do a better job. Obviously I don't want to have to fill in a random constant like that and I would like to get the theory right. Could anyone help me out?? The result of the original projection is as follows: CLICK! Kind regards, Mark

##### Share on other sites
Your orthoAngle should be exactly 60 degrees, calculcated by acos(0.5).

That should fix your first problem of the lines not being drawn at exactly 1/2 slope.

After that, you will probably have to scale the projection in such a way, that the vertices in 3D coordinates end up being projected into the very center of every pixel, as opposed to a varying location.

1. 1
2. 2
JoeJ
20
3. 3
frob
19
4. 4
5. 5

• 10
• 10
• 12
• 13
• 9
• ### Forum Statistics

• Total Topics
632199
• Total Posts
3004733

×