Fix cube rendering
This commit is contained in:
parent
1dca5470f6
commit
4c3b956787
1 changed files with 11 additions and 9 deletions
|
@ -80,6 +80,7 @@ void render_cube_face(
|
|||
const double p2[3],
|
||||
const double p3[3])
|
||||
{
|
||||
glColor3dv(color);
|
||||
glVertex3dv(p0);
|
||||
glColor3dv(color);
|
||||
glVertex3dv(p1);
|
||||
|
@ -91,7 +92,6 @@ void render_cube_face(
|
|||
glVertex3dv(p3);
|
||||
glColor3dv(color);
|
||||
glVertex3dv(p0);
|
||||
glColor3dv(color);
|
||||
}
|
||||
|
||||
// Render one single cube
|
||||
|
@ -125,14 +125,14 @@ void cube_system::render_cube()
|
|||
*/
|
||||
|
||||
const double vertices[8][3] = {
|
||||
{-1.0, -1.0, 1.0},
|
||||
{ 1.0, -1.0, 1.0},
|
||||
{ 1.0, 1.0, 1.0},
|
||||
{-1.0, 1.0, 1.0},
|
||||
{-1.0, -1.0, -1.0},
|
||||
{ 1.0, -1.0, -1.0},
|
||||
{ 1.0, 1.0, -1.0},
|
||||
{-1.0, 1.0, -1.0}
|
||||
{-1.0, -1.0, 1.0}, // 1
|
||||
{ 1.0, -1.0, 1.0}, // 2
|
||||
{ 1.0, 1.0, 1.0}, // 3
|
||||
{-1.0, 1.0, 1.0}, // 4
|
||||
{-1.0, -1.0, -1.0}, // 5
|
||||
{ 1.0, -1.0, -1.0}, // 6
|
||||
{ 1.0, 1.0, -1.0}, // 7
|
||||
{-1.0, 1.0, -1.0} // 8
|
||||
};
|
||||
|
||||
const double colors[6][3] = {
|
||||
|
@ -144,12 +144,14 @@ void cube_system::render_cube()
|
|||
{0.0, 1.0, 1.0},
|
||||
};
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
render_cube_face(colors[0], vertices[0], vertices[1], vertices[2], vertices[3]);
|
||||
render_cube_face(colors[1], vertices[1], vertices[5], vertices[6], vertices[2]);
|
||||
render_cube_face(colors[2], vertices[5], vertices[4], vertices[7], vertices[6]);
|
||||
render_cube_face(colors[3], vertices[4], vertices[0], vertices[3], vertices[7]);
|
||||
render_cube_face(colors[4], vertices[4], vertices[5], vertices[1], vertices[0]);
|
||||
render_cube_face(colors[5], vertices[6], vertices[7], vertices[3], vertices[2]);
|
||||
glEnd();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue