From fb5d791d7f8964292de98bfe4b5f557a027c3e78 Mon Sep 17 00:00:00 2001 From: Joey de Vries Date: Fri, 22 May 2020 18:01:40 +0200 Subject: [PATCH] Add face culling exercise1 to repo. --- .../face_culling_exercise1.cpp | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/4.advanced_opengl/4.face_culling_exercise1/face_culling_exercise1.cpp diff --git a/src/4.advanced_opengl/4.face_culling_exercise1/face_culling_exercise1.cpp b/src/4.advanced_opengl/4.face_culling_exercise1/face_culling_exercise1.cpp new file mode 100644 index 0000000..74f0cee --- /dev/null +++ b/src/4.advanced_opengl/4.face_culling_exercise1/face_culling_exercise1.cpp @@ -0,0 +1,49 @@ +float vertices[] = { + // back face + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, // bottom-left + 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, // bottom-right + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, // top-right + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, // top-right + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, // top-left + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, // bottom-left + // front face + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, // bottom-left + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, // top-right + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, // bottom-right + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, // top-right + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, // bottom-left + -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, // top-left + // left face + -0.5f, 0.5f, 0.5f, 1.0f, 0.0f, // top-right + -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, // bottom-left + -0.5f, 0.5f, -0.5f, 1.0f, 1.0f, // top-left + -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, // bottom-left + -0.5f, 0.5f, 0.5f, 1.0f, 0.0f, // top-right + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, // bottom-right + // right face + 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, // top-left + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, // top-right + 0.5f, -0.5f, -0.5f, 0.0f, 1.0f, // bottom-right + 0.5f, -0.5f, -0.5f, 0.0f, 1.0f, // bottom-right + 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, // bottom-left + 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, // top-left + // bottom face + -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, // top-right + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, // bottom-left + 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, // top-left + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, // bottom-left + -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, // top-right + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, // bottom-right + // top face + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, // top-left + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, // top-right + 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, // bottom-right + 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, // bottom-right + -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, // bottom-left + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f // top-left +}; + +/* Also make sure to add a call to OpenGL to specify that triangles defined by a clockwise ordering + are now 'front-facing' triangles so the cube is rendered as normal: + glFrontFace(GL_CW); +*/ \ No newline at end of file