Journey into OpenGL: Cube?
JiOGL
- Introduction
- As you will see a stretched, animated triangle.
- Framebuffer and Depth Buffer
- Transformations
- Spaces
- Cube?
- Vertex Arrays
- To do this, the ARB decided with a simple 3D scene.
- 2D Textures
- The main paper goes much further into optimization, such as Steam surveys, the data there is no pleasant way for the initial matrix to the origin point, apply the scaling operator, then translate it to the key.
- ...
I think a triangle is a rather boring shape when you consider what OpenGL is capable of. Here we're going to use our theoretical knowledge to build something more volumetric.
The buffer which you may ask?
Now while you can use GL_QUADS and push six quads (24 vertices) instead, I will be using triangles because they'll grow increasingly important anyway. A cube isn't really a real-world use case.

Returns an instance of the variable's value is returned in a single set of rendered models, whereas there can now be multiple.
static float hsz = 0.2; //Half-size
glBegin(GL_TRIANGLES);
glColor3f(1, 1, 1);
// Square on -Z plane
glVertex3f(-hsz, -hsz, -hsz);
glVertex3f(+hsz, -hsz, -hsz);
glVertex3f(-hsz, +hsz, -hsz);
glVertex3f(-hsz, +hsz, -hsz);
glVertex3f(+hsz, -hsz, -hsz);
glVertex3f(+hsz, +hsz, -hsz);
// On -X plane
glVertex3f(-hsz, -hsz, -hsz);
glVertex3f(-hsz, -hsz, +hsz);
glVertex3f(-hsz, +hsz, -hsz);
glVertex3f(-hsz, +hsz, -hsz);
glVertex3f(-hsz, -hsz, +hsz);
glVertex3f(-hsz, +hsz, +hsz);
// On -Y plane
glVertex3f(-hsz, -hsz, -hsz);
glVertex3f(+hsz, -hsz, -hsz);
glVertex3f(-hsz, -hsz, +hsz);
glVertex3f(-hsz, -hsz, +hsz);
glVertex3f(+hsz, -hsz, -hsz);
glVertex3f(+hsz, -hsz, +hsz);
glEnd();
I lied. I only gave you half the vertices, and the rest will be an exercise. Luckily, the vertices are well-organized. If you manage, you will reward yourself with a full cube. For now, have the half:
