Create an isometric view with opengl and c++

Started by
3 comments, last by frob 2 years, 5 months ago

Hello,

I would like to create an isometric view.

I have the formulas to convert 2d points to iso and vice versa. (source: https://gamedevelopment.tutsplus.com/tutorials/creating-isometric-worlds-a-primer-for-game-developers--gamedev-6511)

I do not understand the rotations to be done to have an isometric view.

Should I use gml::ortho or glm::perspective?

I need to rotate on the view matrix or the model matrix?

I've been trying to do it for several days without success ...

Thank you

Advertisement

In the old days, you didn't have a GPU, so you didn't have the computing power to display a rotated view in real time. What they did is make weirdly shaped images that look rotated if you paint them in the correct order. For user interaction, you need to know what position was clicked with the mouse button, which resulted in those formulas.

You can still do the above in OpenGL by displaying a simple flat 2D surface, and painting the weirdly shaped images at it. Everything is 2D here, nothing needs rotation.

If you want to use 3D models and show them in an isometric way, simply rotate your camera 45 degrees relative to the surface axes of the world, at an approximate 30 degrees downward view. Wikipedia has the exact angles last time I looked, or you can compute them from your formulas if you like a nice 3D math exercise.

In the old days, lack of GPU also meant no scaling. Nearby and far away are equally large. So that means an ortho view, or equivalently a perspective view where the front and the back plane have the same size.

While on the question of angles, here's a good image.

I think another interesting question is how to bake the backgrounds in an orthogonal view. I never tried it. Would love an explanation if someone has.

If you want to go old school with pixel art — and it takes a LOT of art — the 1:2:1 or 2:1 approaches were common.

Drawing was done by sprite tiles, and the older hardware was designed for sprite tiles, so it all worked efficiently. Placement of the tiles was a simple grid of diamonds, drawn in painter's order. You could add height to a tile by simply adding a number of pixels specific to the art, layering the tiles bottom to top.

These days it is a poor approach because hardware is instead designed around point clouds, textures, materials, and shaders. Arrays of tile IDs are long gone. You can emulate the old tile behavior but it is difficult to get the performance, the naive approach generates far too many draw calls and saturates the communication on the graphics pipeline. It can be done but is far easier to use a library or engine that already implemented it.

Another easy approach is to do modern 3D, and fix the camera angle to one of those already mentioned. A plain ortho camera at the fixed angle looks similar enough, although it won't match the hand-crafted pixel art.

This topic is closed to new replies.

Advertisement