# How to draw a Minecraft-like world with Open GL

I recently completed the this Open GL tutorial. The tutorial shows how to set up a window and shaders, and teaches you how to draw a single cube in the middle of the screen, which all makes sense to me (I think).

I'd like to make just a simple flat world made of cubes like Minecraft, but I have no idea how to turn my single giant cube into a bunch of smaller cubes, or how to get the smaller cubes to be arranged in the proper way.

Mostly what doesn't make sense to me is the coordinate system being from 1 to -1 and trying to draw a bunch of cubes in that space. Is there a way to adjust that coordinate space to be more world-like, where each unit of coordinate space is roughly equivalent to a meter or something?

• I neglected to mention the use of generic and/or reusable geometry, a technique called "Instancing". There are countless existing and useful answers about it here so I I focused on what "mostly doesn't make sense". Instancing allows you to draw the same cube over and over swapping in the world matrices and textures for each instance.
– Jon
Commented Mar 15, 2016 at 20:05
• @Jon however you're unlikely to want to do that in this case. A block world generally contains of one mesh per chunk with only the visible edges part of the mesh Commented Mar 16, 2016 at 6:51

You start with "Object Space" which is unique to each piece of geometry. Each piece of geometry you load might be at a different scale, with (0,0) at seemingly random places. It is entirely arbitrary.

The World Matrix rotates, scales, and translates each of those coordinates into a common coordinate system, "World Space". After the world transform, all objects are measurable in world-units (feet/meters/furlongs/whatever).

The View Matrix is the camera's World Matrix, inverted. The view matrix actually "un-moves" the entire world as a single model. After the view transform, the camera becomes (0,0) and all coordinates become relative directions "away from" the camera. View-space units are usually the same as world-space units.

The Projection Matrix defines the dimensions of view-space visible at the nearplane and how those dimensions change as scene-depth increases. Orthogonal projection defines a cube of view-space while perspective projection defines a truncated pyramid shape. During projection, the shape is squished into a cube, altering view-space as necessary. Since orthogonal projection is already a cube, no squishing is performed. Perspective is usually wider at the farplane and, so, distant objects appear smaller.

The final result of projection is a universal coordinate system called Normalized Device Coordinates, or NDC, where (-1,-1) is the lower-left corner of any screen and (1,1) is the upper-right corner.

You need to read about coordinate/space transformations, in that site is explained well. You can't go far without understanding that.

https://open.gl/transformations

Without using any transformation, you are basically bounded by the OpenGL clip-space which is contained in a cube with opposite vertices (1,1,1) and (-1,-1,-1) , as you stated correctly.

I recently found a great tutorial of drawing Minecraft's graphics by drawing it in RT in Unity 4 but 5 is still compatible with the code. It's a basic tutorial and it can be made into a cube and the top has more- cubes on it but they're at different places like 3 down, 1 up you get the point basically a big cube but with smaller ones at the top. Here's the tutorial have fun (It does not include the sky but comes with pre-made sky assets) the title is misleading and it's quality with simplicity. Hope it helps http://in2gpu.com/2014/07/27/build-minecraft-unity-part-1/ and its all RNG. Although it's not OpenGL but it's the best I could find tutorial wise.

Think of it as a SimCity with treasure hunts and lost-in-the-jungle adventures of infinite potentialities. First-time players of Minecraft enter a blank “natural” landscape of trees. Discovering that the sun can shortly set and darkness is nigh, they need to gather wood and build a shelter or risk being destroyed by the monsters of the night. because the name of the sport suggests, players mine the surroundings for materials then craft things like pickaxes, fishing rods, even chocolate-chip cookies. (When Conan O’Brien reviewed Minecraft recently as a part of his series “Clueless Gamer,” he said: “Taking things out of the bottom then building things. … thus it’s like we’re in Wales within the nineteenth century and we’re urgently poor. What a fun game for youths.”) How to Draw Tutorials Once that task is perfect, different opportunities beckon: Mine for diamonds, tame cats, stock chests with found objects, produce glass windows by building kilns and gathering sand, create bows and arrows out of spiderwebs (but be careful—vanquish those spiders first!), lay out railroad-like roller coasters, style wonderlands for friends to go to. there's without stopping to the choices.