diff --git a/Step 3/cmake-build-release/.ninja_deps b/Step 3/cmake-build-release/.ninja_deps index 6b05635..c6bde02 100644 Binary files a/Step 3/cmake-build-release/.ninja_deps and b/Step 3/cmake-build-release/.ninja_deps differ diff --git a/Step 3/cmake-build-release/.ninja_log b/Step 3/cmake-build-release/.ninja_log index 15fb571..2a9b906 100644 --- a/Step 3/cmake-build-release/.ninja_log +++ b/Step 3/cmake-build-release/.ninja_log @@ -34,3 +34,10 @@ 1310 1378 1668324206276041556 Step_3 f055ce2b85635598 1 1298 1668324222400504969 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d 1298 1369 1668324222472507037 Step_3 f055ce2b85635598 +1 1075 1668324349212149162 CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o 330ad35a6abf06c3 +1 1305 1668324349440155714 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1305 1374 1668324349508157669 Step_3 f055ce2b85635598 +1 1177 1668326424977049673 CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o 330ad35a6abf06c3 +1 1405 1668326425205056279 CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o ce988de97a5cb51d +1 1911 1668326425713070995 CMakeFiles/Step_3.dir/src/engine/main.cpp.o 641dce3f86933e2e +1912 2024 1668326425821074124 Step_3 f055ce2b85635598 diff --git a/Step 3/cmake-build-release/2022-11-13 2:25:52.png b/Step 3/cmake-build-release/2022-11-13 2:25:52.png new file mode 100644 index 0000000..76b3c54 Binary files /dev/null and b/Step 3/cmake-build-release/2022-11-13 2:25:52.png differ diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o index 9fb8ee5..474ee0a 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/gl/gl.cpp.o differ diff --git a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o index 9a4d347..f9a9a37 100644 Binary files a/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o and b/Step 3/cmake-build-release/CMakeFiles/Step_3.dir/src/graphics/graphics.cpp.o differ diff --git a/Step 3/cmake-build-release/Step_3 b/Step 3/cmake-build-release/Step_3 index 46e8c55..9784512 100755 Binary files a/Step 3/cmake-build-release/Step_3 and b/Step 3/cmake-build-release/Step_3 differ diff --git a/Step 3/cmake-build-release/Testing/Temporary/LastTest.log b/Step 3/cmake-build-release/Testing/Temporary/LastTest.log index 44696f6..1f6769f 100644 --- a/Step 3/cmake-build-release/Testing/Temporary/LastTest.log +++ b/Step 3/cmake-build-release/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Nov 13 02:23 EST +Start testing: Nov 13 03:00 EST ---------------------------------------------------------- -End testing: Nov 13 02:23 EST +End testing: Nov 13 03:00 EST diff --git a/Step 3/include/graphics/gl/gl.h b/Step 3/include/graphics/gl/gl.h index ef218e8..937e459 100644 --- a/Step 3/include/graphics/gl/gl.h +++ b/Step 3/include/graphics/gl/gl.h @@ -83,6 +83,7 @@ class VAO { explicit VAO(const std::vector &triangles); VAO(const std::vector& verts, const std::vector& uvs, const std::vector& indices); + VAO(const std::vector& verts, const std::vector& uvs); void bind() const; void unbind(); diff --git a/Step 3/src/graphics/gl/gl.cpp b/Step 3/src/graphics/gl/gl.cpp index db6e469..7501f30 100644 --- a/Step 3/src/graphics/gl/gl.cpp +++ b/Step 3/src/graphics/gl/gl.cpp @@ -223,6 +223,21 @@ VAO::~VAO() { } glDeleteBuffers(1, &instanceVBO); } +VAO::VAO(const std::vector& verts, const std::vector& uvs): VaoID(createVAO()) { + this->drawCount = (int)verts.size(); + glBindVertexArray(VaoID); + // enable the attributes, prevents us from having to do this later. + glEnableVertexAttribArray(0); + glEnableVertexAttribArray(1); + glEnableVertexAttribArray(2); + // store vertex data + storeData(0, 3, 3 * sizeof(float), 0, (int)verts.size(), verts.data()); + // store texture UV data + storeData(1, 2, 2 * sizeof(float), 0, (int)uvs.size(), uvs.data()); + // store normal data + //storeData(2, 3, 3 * sizeof(float), 0, (int)normals.size(), normals.data()); + unbind(); +} Texture::Texture(){ diff --git a/Step 3/src/graphics/graphics.cpp b/Step 3/src/graphics/graphics.cpp index d58c62b..5ede7b0 100644 --- a/Step 3/src/graphics/graphics.cpp +++ b/Step 3/src/graphics/graphics.cpp @@ -13,25 +13,144 @@ extern bool* pauseRaytracing; extern bool* haltRaytracing; namespace Raytracing { + + struct cubeVertexBuilder { + std::vector cubeVerticesRaw = { + -0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, 0.5f, -0.5f, + 0.5f, 0.5f, -0.5f, + -0.5f, 0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + + -0.5f, -0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + -0.5f, -0.5f, 0.5f, + + -0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + + -0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, -0.5f, -0.5f, + + -0.5f, 0.5f, -0.5f, + 0.5f, 0.5f, -0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, -0.5f, + }; + static cubeVertexBuilder getCubeExtends(float xRadius, float yRadius, float zRadius) { + cubeVertexBuilder builder; + builder.cubeVerticesRaw = { + -0.5f, -0.5f, -zRadius, + 0.5f, -0.5f, -zRadius, + 0.5f, 0.5f, -zRadius, + 0.5f, 0.5f, -zRadius, + -0.5f, 0.5f, -zRadius, + -0.5f, -0.5f, -zRadius, + + -0.5f, -0.5f, zRadius, + 0.5f, -0.5f, zRadius, + 0.5f, 0.5f, zRadius, + 0.5f, 0.5f, zRadius, + -0.5f, 0.5f, zRadius, + -0.5f, -0.5f, zRadius, + + -xRadius, 0.5f, 0.5f, + -xRadius, 0.5f, -0.5f, + -xRadius, -0.5f, -0.5f, + -xRadius, -0.5f, -0.5f, + -xRadius, -0.5f, 0.5f, + -xRadius, 0.5f, 0.5f, -// const std::vector vertices = { -// 1.0f, 1.0f, 0.0f, // top right -// 1.0f, 0.0f, 0.0f, // bottom right -// 0.0f, 0.0f, 0.0f, // bottom left -// 0.0f, 1.0f, 0.0f // top left -// }; -// -// const std::vector indices = { -// 3, 1, 0, // first triangle -// 3, 2, 1 // second triangle -// }; -// -// const std::vector texCoords = { -// 1.0f, 1.0f, // top right -// 1.0f, 0.0f, // bottom right -// 0.0f, 0.0f, // bottom left -// 0.0f, 1.0f // top left -// }; + xRadius, 0.5f, 0.5f, + xRadius, 0.5f, -0.5f, + xRadius, -0.5f, -0.5f, + xRadius, -0.5f, -0.5f, + xRadius, -0.5f, 0.5f, + xRadius, 0.5f, 0.5f, + + -0.5f, -yRadius, -0.5f, + 0.5f, -yRadius, -0.5f, + 0.5f, -yRadius, 0.5f, + 0.5f, -yRadius, 0.5f, + -0.5f, -yRadius, 0.5f, + -0.5f, -yRadius, -0.5f, + + -0.5f, yRadius, -0.5f, + 0.5f, yRadius, -0.5f, + 0.5f, yRadius, 0.5f, + 0.5f, yRadius, 0.5f, + -0.5f, yRadius, 0.5f, + -0.5f, yRadius, -0.5f, + }; + return builder; + } + }; + + std::vector cubeUVs = { + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 0.0f, + 0.0f, 0.0f, + 0.0f, 1.0f, + + 0.0f, 1.0f, + 1.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 0.0f, + 0.0f, 0.0f, + 0.0f, 1.0f + }; + const std::vector vertices = { 1.0f, 1.0f, 0.0f, // top right 1.0f, -1.0f, 0.0f, // bottom right