started section "Camera"
This commit is contained in:
parent
178fb8a9bf
commit
6a51a7a0ae
|
@ -12,7 +12,7 @@
|
|||
#include "util/stb_image.h"
|
||||
|
||||
// Continue: https://learnopengl.com/Getting-started/Camera
|
||||
// Chapter: Not started
|
||||
// Chapter: Walk around
|
||||
//
|
||||
// TODO: look at project->properties->VC++ Directories-> change everything to the Environment var
|
||||
// For the "real" Nebulix Engine setup everything so it can be compiled/used with VSCode/CLion and not just VS
|
||||
|
@ -183,8 +183,18 @@ int main()
|
|||
Texture2D containerImage("images/container.jpg");
|
||||
Texture2D faceImage("images/awesomeface.png", 0, GL_RGBA);
|
||||
|
||||
mat4 viewMatrix = mat4(1.0f);
|
||||
viewMatrix = glm::translate(viewMatrix, vec3(0, 0, -3.0f));
|
||||
|
||||
vec3 cameraPosition = vec3(0.0f, 0, 3.0f);
|
||||
|
||||
vec3 cameraTarget = vec3(0.0f, 0.0f, 0.0f);
|
||||
vec3 cameraDirection = glm::normalize(cameraPosition - cameraTarget);
|
||||
|
||||
vec3 worldUp = vec3(0.0f, 1.0f, 0.0f);
|
||||
vec3 cameraRight = glm::normalize(glm::cross(worldUp, cameraDirection)); // vector pointing to the right of the camera
|
||||
|
||||
vec3 cameraUp = glm::cross(cameraDirection, cameraRight);
|
||||
|
||||
//mat4 viewMatrix = glm::lookAt(cameraPosition, cameraTarget, worldUp);
|
||||
mat4 projectionMatrix = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 100.0f);
|
||||
|
||||
float timeLastFrame = glfwGetTime();
|
||||
|
@ -196,6 +206,11 @@ int main()
|
|||
|
||||
ProcessInput(window);
|
||||
|
||||
const float radius = 10.0f;
|
||||
float camX = sin(glfwGetTime()) * radius;
|
||||
float camZ = cos(glfwGetTime()) * radius;
|
||||
mat4 viewMatrix = glm::lookAt(vec3(camX, 0, camZ), cameraTarget, worldUp);
|
||||
|
||||
shader->Use();
|
||||
shader->SetInt("ourTexture1", 0);
|
||||
shader->SetInt("ourTexture2", 1);
|
||||
|
@ -210,7 +225,6 @@ int main()
|
|||
float time = glfwGetTime();
|
||||
for (int i = 0; i < 10; i++) // somehow cubePositions->length() does not return the correct number?
|
||||
{
|
||||
std::cout << i << ": " << i % 3;
|
||||
mat4 model = mat4(1.0f);
|
||||
model = glm::translate(model, cubePositions[i]);
|
||||
float angle = (20.0f * i);
|
||||
|
@ -221,7 +235,6 @@ int main()
|
|||
|
||||
//glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); // for EBOs
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36); // for VAOs
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
|
|
Loading…
Reference in New Issue
Block a user