Camera spinn around cubes

This commit is contained in:
k 2025-01-12 22:33:07 -05:00
parent c639afe08b
commit e0a695c7b1

View File

@ -82,10 +82,15 @@ int main(void) {
stbi_image_free(data); stbi_image_free(data);
while (!glfwWindowShouldClose(window)) { 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 view = glm::mat4(1.0f); /*move camera*/
glm::mat4 projection = glm::perspective( const float radius = 10.0f;
glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 100.0f); /*camera settings*/ float camX = sin(glfwGetTime()) * radius;
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f)); 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); glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);