fixed some stuff (cannot compile yet though)
This commit is contained in:
parent
ae99c30c6a
commit
42db40144e
|
@ -16,6 +16,16 @@ set(CMAKE_CXX_STANDARD 17) # request C++17
|
|||
set(CMAKE_CXX_STANDARD_REQUIRED ON) # enforce requested standard
|
||||
set(CMAKE_CXX_EXTENSIONS OFF) # disable compiler specific extensions
|
||||
|
||||
|
||||
# add extra include directories
|
||||
include_directories($ENV{OPENGL_LIBS}/glm)
|
||||
include_directories($ENV{OPENGL_LIBS}/glad/include)
|
||||
include_directories($ENV{OPENGL_LIBS}/glfw/include)
|
||||
|
||||
# add extra lib directories
|
||||
include_directories($ENV{OPENGL_LIBS}/glfw/lib)
|
||||
|
||||
|
||||
# helper function to simplify definition of projects
|
||||
function(target name)
|
||||
file(GLOB_RECURSE SRC "${name}/*") # recursively collect all files in sub-folder for project
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "util/camera/camera.h"
|
||||
#include "object/game_object.h"
|
||||
|
||||
// TODO: Replace current rendering with he GameObject
|
||||
// Continue: https://learnopengl.com/Lighting/Colors
|
||||
// Chapter: A lighting scene
|
||||
//
|
||||
|
@ -35,8 +34,7 @@
|
|||
typedef glm::mat4 mat4;
|
||||
typedef glm::vec3 vec3;
|
||||
|
||||
vec3 cameraPosition = vec3(0.0f, 0.0f, 3.0f);
|
||||
Camera cam(cameraPosition);
|
||||
Camera cam(glm::vec3(0.0f, 0.0f, 3.0f));
|
||||
|
||||
float deltaTime = 0.0f, lastFrameTime = 0.0f;
|
||||
float mouseLastX = WINDOW_WIDTH / 2, mouseLastY = WINDOW_HEIGHT / 2;
|
||||
|
@ -119,7 +117,7 @@ int main()
|
|||
|
||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||
{
|
||||
std::cerr << "ERROR::GLAD::INITILISE";
|
||||
std::cerr << "ERROR::GLAD::INITIALISE";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -188,7 +186,7 @@ int main()
|
|||
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, since it reuses vertices;
|
||||
// VBO == all vertices; EBO == connection of vertices (faces) and is optional, although it is a bit more efficient than using VBOs, since it reuses vertices;
|
||||
// VAO == collection of VBOs/EBOs used for rendering
|
||||
GLuint vertexBufferObject, elementBufferObject, vertexArrayObject;
|
||||
glGenVertexArrays(1, &vertexArrayObject);
|
||||
|
@ -235,7 +233,7 @@ int main()
|
|||
// main loop
|
||||
while(!glfwWindowShouldClose(window))
|
||||
{
|
||||
float currentFrameTime = glfwGetTime();
|
||||
float currentFrameTime = (float)glfwGetTime();
|
||||
deltaTime = currentFrameTime - lastFrameTime;
|
||||
lastFrameTime = currentFrameTime;
|
||||
|
||||
|
@ -244,35 +242,29 @@ int main()
|
|||
|
||||
ProcessInput(window);
|
||||
|
||||
mat4 viewMatrix = cam.GetViewMatrix();
|
||||
mat4 projectionMatrix = glm::perspective(glm::radians(cam.Fov), 800.0f / 600.0f, 0.1f, 100.0f);
|
||||
|
||||
shader->Use();
|
||||
shader->SetInt("ourTexture1", 0);
|
||||
shader->SetInt("ourTexture2", 1);
|
||||
shader->SetMatrix("viewMatrix", viewMatrix); // more or less the camera
|
||||
shader->SetMatrix("viewMatrix", cam.GetViewMatrix()); // more or less the camera
|
||||
shader->SetMatrix("projectionMatrix", projectionMatrix);
|
||||
|
||||
containerImage.BindTexture();
|
||||
faceImage.BindTexture(GL_TEXTURE0 + 1); // GL_TEXTURE0 + 1 == GL_TEXTURE1, this means looping over multiple texture units is easily possible
|
||||
|
||||
glBindVertexArray(vertexArrayObject);
|
||||
|
||||
for (int i = 1; i < 10; i++)
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
mat4 model = mat4(1.0f);
|
||||
model = glm::translate(model, cubePositions[i]);
|
||||
cube.Position = cubePositions[i];
|
||||
mat4 model = cube.GetModelMatrix();
|
||||
float angle = (20.0f * i);
|
||||
if (i % 3 == 0)
|
||||
angle = currentFrameTime * 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
|
||||
cube.Draw();
|
||||
}
|
||||
shader->SetMatrix("modelMatrix", cube.GetModelMatrix());
|
||||
cube.Draw();
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
|
|
Loading…
Reference in New Issue
Block a user