finished coordinate system section
This commit is contained in:
parent
6485de44cd
commit
178fb8a9bf
|
@ -11,8 +11,8 @@
|
||||||
#include "textures/Texture2D.h"
|
#include "textures/Texture2D.h"
|
||||||
#include "util/stb_image.h"
|
#include "util/stb_image.h"
|
||||||
|
|
||||||
// Continue: https://learnopengl.com/Getting-started/Coordinate-Systems
|
// Continue: https://learnopengl.com/Getting-started/Camera
|
||||||
// Chapter: More Cubes!
|
// Chapter: Not started
|
||||||
//
|
//
|
||||||
// TODO: look at project->properties->VC++ Directories-> change everything to the Environment var
|
// 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
|
// For the "real" Nebulix Engine setup everything so it can be compiled/used with VSCode/CLion and not just VS
|
||||||
|
@ -128,6 +128,18 @@ int main()
|
||||||
0, 1, 3,
|
0, 1, 3,
|
||||||
1, 2, 3
|
1, 2, 3
|
||||||
};
|
};
|
||||||
|
vec3 cubePositions[] = {
|
||||||
|
vec3(0.0f, 0.0f, 0.0f),
|
||||||
|
vec3(2.0f, 5.0f, -15.0f),
|
||||||
|
vec3(-1.5f, -2.2f, -2.5f),
|
||||||
|
vec3(-3.8f, -2.0f, -12.3f),
|
||||||
|
vec3(2.4f, -0.4f, -3.5f),
|
||||||
|
vec3(-1.7f, 3.0f, -7.5f),
|
||||||
|
vec3(1.3f, -2.0f, -2.5f),
|
||||||
|
vec3(1.5f, 2.0f, -2.5f),
|
||||||
|
vec3(1.5f, 0.2f, -1.5f),
|
||||||
|
vec3(-1.3f, 1.0f, -1.5f)
|
||||||
|
};
|
||||||
|
|
||||||
// VBO == all verticies; EBO == connection of vertices (faces) and is optional although it is a bit more efficient than using VBOs;
|
// VBO == all verticies; EBO == connection of vertices (faces) and is optional although it is a bit more efficient than using VBOs;
|
||||||
// VAO == collection of VBOs/EBOs used for rendering
|
// VAO == collection of VBOs/EBOs used for rendering
|
||||||
|
@ -171,8 +183,6 @@ int main()
|
||||||
Texture2D containerImage("images/container.jpg");
|
Texture2D containerImage("images/container.jpg");
|
||||||
Texture2D faceImage("images/awesomeface.png", 0, GL_RGBA);
|
Texture2D faceImage("images/awesomeface.png", 0, GL_RGBA);
|
||||||
|
|
||||||
mat4 modelMatrix = mat4(1.0f);
|
|
||||||
modelMatrix = glm::rotate(modelMatrix, glm::radians(-55.0f), vec3(1.0f, 0, 0));
|
|
||||||
mat4 viewMatrix = mat4(1.0f);
|
mat4 viewMatrix = mat4(1.0f);
|
||||||
viewMatrix = glm::translate(viewMatrix, vec3(0, 0, -3.0f));
|
viewMatrix = glm::translate(viewMatrix, vec3(0, 0, -3.0f));
|
||||||
mat4 projectionMatrix = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 100.0f);
|
mat4 projectionMatrix = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 100.0f);
|
||||||
|
@ -186,23 +196,33 @@ int main()
|
||||||
|
|
||||||
ProcessInput(window);
|
ProcessInput(window);
|
||||||
|
|
||||||
float time = glfwGetTime();
|
|
||||||
|
|
||||||
modelMatrix = glm::rotate(modelMatrix, time * (time - timeLastFrame) + 0.001f * glm::radians(50.0f), glm::vec3(0.5f, 1.0f, 0.0f));
|
|
||||||
|
|
||||||
shader->Use();
|
shader->Use();
|
||||||
shader->SetInt("ourTexture1", 0);
|
shader->SetInt("ourTexture1", 0);
|
||||||
shader->SetInt("ourTexture2", 1);
|
shader->SetInt("ourTexture2", 1);
|
||||||
shader->SetMatrix("modelMatrix", modelMatrix);
|
shader->SetMatrix("viewMatrix", viewMatrix); // more or less the camera
|
||||||
shader->SetMatrix("viewMatrix", viewMatrix);
|
|
||||||
shader->SetMatrix("projectionMatrix", projectionMatrix);
|
shader->SetMatrix("projectionMatrix", projectionMatrix);
|
||||||
|
|
||||||
containerImage.BindTexture();
|
containerImage.BindTexture();
|
||||||
faceImage.BindTexture(GL_TEXTURE0 + 1); // GL_TEXTURE0 + 1 == GL_TEXTURE1, this means looping over multiple units is easily possible
|
faceImage.BindTexture(GL_TEXTURE0 + 1); // GL_TEXTURE0 + 1 == GL_TEXTURE1, this means looping over multiple texture units is easily possible
|
||||||
|
|
||||||
glBindVertexArray(vertexArrayObject);
|
glBindVertexArray(vertexArrayObject);
|
||||||
//glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); // for EBOs
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 36); // for VAOs
|
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);
|
||||||
|
if (i % 3 == 0)
|
||||||
|
angle = time * 25;
|
||||||
|
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
|
||||||
|
shader->SetMatrix("modelMatrix", model);
|
||||||
|
|
||||||
|
//glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); // for EBOs
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 36); // for VAOs
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user