diff --git a/project/x64/Debug/Practica3D.tlog/CL.command.1.tlog b/project/x64/Debug/Practica3D.tlog/CL.command.1.tlog index 249d67a..9b38967 100644 Binary files a/project/x64/Debug/Practica3D.tlog/CL.command.1.tlog and b/project/x64/Debug/Practica3D.tlog/CL.command.1.tlog differ diff --git a/project/x64/Debug/Practica3D.tlog/CL.read.1.tlog b/project/x64/Debug/Practica3D.tlog/CL.read.1.tlog index e1f5135..dbae3fb 100644 Binary files a/project/x64/Debug/Practica3D.tlog/CL.read.1.tlog and b/project/x64/Debug/Practica3D.tlog/CL.read.1.tlog differ diff --git a/project/x64/Debug/Practica3D.tlog/CL.write.1.tlog b/project/x64/Debug/Practica3D.tlog/CL.write.1.tlog index ea6e483..929fd60 100644 Binary files a/project/x64/Debug/Practica3D.tlog/CL.write.1.tlog and b/project/x64/Debug/Practica3D.tlog/CL.write.1.tlog differ diff --git a/project/x64/Debug/Practica3D.tlog/link.read.1.tlog b/project/x64/Debug/Practica3D.tlog/link.read.1.tlog index c6fb7b3..098e912 100644 Binary files a/project/x64/Debug/Practica3D.tlog/link.read.1.tlog and b/project/x64/Debug/Practica3D.tlog/link.read.1.tlog differ diff --git a/project/x64/Debug/ugine3d.log b/project/x64/Debug/ugine3d.log index 8281ef2..0ccfb81 100644 --- a/project/x64/Debug/ugine3d.log +++ b/project/x64/Debug/ugine3d.log @@ -1,3 +1,2 @@  main.cpp -LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library ugine3d.vcxproj -> C:\Users\rabil\git\utad-programacion3d\project\x64\Debug\Practica3D.exe diff --git a/src/buffer.cpp b/src/buffer.cpp index 7d51f1c..1e53907 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -1,6 +1,7 @@ #include "buffer.h" #include +#include #include "../lib/glew/GL/glew.h" #include "../lib/glfw/glfw3.h" @@ -9,7 +10,7 @@ Buffer::Buffer(const std::vector& vertices, const std::vector& indices) { - index_count_ = indices.size(); + index_count_ = static_cast(indices.size()); glGenVertexArrays(1, &vao_); glGenBuffers(1, &vbo_); diff --git a/src/main.cpp b/src/main.cpp index 617f07f..3fe5037 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,9 +56,9 @@ int main() { // Logic std::vector vertices = { - {{-0.5f, -0.5f, 0.0f}}, - {{0.5f, -0.5f, 0.0f}}, - {{0.0f, 0.5f, 0.0f}} + {{0.0f, 0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}}, + {{-0.5f, -0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}}, + {{0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}} }; std::vector indices = { 0, 1, 2 }; @@ -69,21 +69,23 @@ int main() { } glm::mat4 projection = glm::perspective(glm::radians(45.0f), static_cast(SCREEN_WIDTH) / SCREEN_HEIGHT, 0.1f, 100.0f); - glm::mat4 view = glm::translate(glm::mat4(1.0f), glm::vec3(0, 0, 6)); + //glm::mat4 view = glm::translate(glm::mat4(1.0f), glm::vec3(0, 0, 6)); + glm::mat4 view = glm::lookAt(glm::vec3(0, 0, 6), glm::vec3(0, 0, 0), glm::vec3(0, 1, 0)); // main loop - double angle = 0; + double angle = 0.0; double lastTime = glfwGetTime(); while (!glfwWindowShouldClose(win) && !glfwGetKey(win, GLFW_KEY_ESCAPE)) { // Delta double delta_time = glfwGetTime() - lastTime; + lastTime = glfwGetTime(); // Reset window int screenWidth, screenHeight; glfwGetWindowSize(win, &screenWidth, &screenHeight); glViewport(0, 0, screenWidth, screenHeight); - glClearColor(0.3f, 0.3f, 0.3f, 1.0f); + glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shader.Use(); @@ -91,21 +93,22 @@ int main() { // Logic angle += 32.0 * delta_time; - glm::mat4 model = glm::translate(glm::mat4(1.0), glm::vec3(-3.0f + 0.0f * 3.0f, 0.0f, -0.0f * 3.0f)); - model = glm::rotate(model, glm::radians(static_cast(angle)), glm::vec3(0, 1, 0)); + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) { + glm::mat4 model = glm::translate(glm::mat4(1.0), glm::vec3(-3.0f + static_cast(col) * 3.0f, 0.0f, static_cast(-row) * 3.0f)); + model = glm::rotate(model, glm::radians(static_cast(angle)), glm::vec3(0, 1, 0)); - glm::mat4 mvp = projection * view * model; + glm::mat4 mvp = projection * view * model; - Shader::setMat4(shader.getLocation("mvp"), mvp); + Shader::setMat4(shader.getLocation("mvp"), mvp); - buffer.Draw(shader); + buffer.Draw(shader); + } + } // Refresh screen glfwSwapBuffers(win); glfwPollEvents(); - - // Delta - lastTime = glfwGetTime(); } // Shutdown diff --git a/src/shader.cpp b/src/shader.cpp index a4b07d6..e9452b4 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -112,6 +112,7 @@ std::string Shader::ReadShaderFile(const std::string& filename) uint32_t Shader::CompileShader(uint32_t type, const std::string& source_path) { std::string source = ReadShaderFile(source_path); + //std::cout << "SHADER FILE: " << source << "\n"; if (source.empty()) return 0;