Added objects

This commit is contained in:
Robert 2021-01-22 01:29:50 +01:00
parent f86fcad89f
commit 107e207a83
5 changed files with 53 additions and 10 deletions

View file

@ -65,7 +65,7 @@ int main(int argc, char** argv)
};
// Make a square
oglu::VertexArray square = oglu::MakeVertexArray(vertices, sizeof(vertices), indices, sizeof(indices), topology, sizeof(topology));
oglu::Object square(vertices, sizeof(vertices), indices, sizeof(indices), topology, sizeof(topology));
// Create a shader
oglu::Shader shader;
@ -83,17 +83,12 @@ int main(int argc, char** argv)
oglu::Texture crate = oglu::MakeTexture("assets/crate.jpg");
oglu::Texture opengl = oglu::MakeTexture("assets/opengl.png");
oglu::Transformable model;
//model.SetRotation(-55.0f, 0.0f, 0.0f);
glm::mat4 view = glm::mat4(1.0f);
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
glm::mat4 projection;
projection = glm::perspective(glm::radians(45.f), 1.0f, 0.1f, 100.0f);
glm::mat4 test = glm::make_mat4(model.GetMatrix());
// Window loop
while (!glfwWindowShouldClose(window))
{
@ -101,16 +96,16 @@ int main(int argc, char** argv)
oglu::ClearScreen(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, oglu::Color(0.29f, 0.13f, 0.23f));
model.Rotate(6.0f, 0.0f, 0.0f);
square.Rotate(6.0f, 0.0f, 0.0f);
shader->Use();
shader->SetUniform("texture1", crate, 0);
shader->SetUniform("texture2", opengl, 1);
shader->SetUniformMatrix4fv("model", 1, GL_FALSE, model.GetMatrix());
shader->SetUniformMatrix4fv("model", 1, GL_FALSE, square.GetMatrix());
shader->SetUniformMatrix4fv("view", 1, GL_FALSE, glm::value_ptr(view));
shader->SetUniformMatrix4fv("projection", 1, GL_FALSE, glm::value_ptr(projection));
square->BindAndDraw();
square.Render();
glfwSwapBuffers(window);
glfwPollEvents();