From e0a695c7b16cf2c20bcf5edeb9c23c258531fb3d Mon Sep 17 00:00:00 2001 From: k Date: Sun, 12 Jan 2025 22:33:07 -0500 Subject: [PATCH] Camera spinn around cubes --- src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1718f09..4f8667d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,10 +82,15 @@ int main(void) { stbi_image_free(data); while (!glfwWindowShouldClose(window)) { + glm::mat4 projection = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, + 0.1f, 100.0f); /*camera settings*/ glm::mat4 view = glm::mat4(1.0f); /*move camera*/ - glm::mat4 projection = glm::perspective( - glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 100.0f); /*camera settings*/ - view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f)); + const float radius = 10.0f; + float camX = sin(glfwGetTime()) * radius; + float camZ = cos(glfwGetTime()) * radius; + view = glm::lookAt(glm::vec3(camX, 0.0, camZ), glm::vec3(0.0, 0.0, 0.0), + glm::vec3(0.0, 1.0, 0.0)); + glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);