-
Notifications
You must be signed in to change notification settings - Fork 7
Construction mode
Construction mode allows the player to add blocks to his own territory.
Picking mode is based on colors. That is, to identify the block that the player clicked on, I draw the nearest 3x3x3 chunks in a special way. Instead of using the textures mapped on the faces of the cubes, a unique color is used for each face. After drawing this, the pixel is read at the mouse coordinate, and the color can be translated into data used to identify the block and the face of the block.
As there is no call to glfwSwapBuffers(), the colored blocks will never be shown to the player. Instead, the buffer is cleared immediately again, and the proper View::chunk is drawn. As there are two different versions of the view::chunk (one with textures and one with unique colors), there is a stack where the View::chunk content can be pushed, to make it quick and easy to pop it back again.