diff --git a/src/buffer.cpp b/src/buffer.cpp index fad961a..3bdede9 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -27,10 +27,22 @@ Buffer::Buffer(const std::vector& vertices, glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(uint16_t), indices.data(), GL_STATIC_DRAW); + // Attribute 0: position (vec3) glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), - nullptr); + reinterpret_cast(0)); glEnableVertexAttribArray(0); + // Attribute 1: color (vec3) + glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), + reinterpret_cast(sizeof(glm::vec3))); + glEnableVertexAttribArray(1); + + // Attribute 2: tex_coord (vec2) + glVertexAttribPointer( + 2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), + reinterpret_cast(sizeof(glm::vec3) * 2)); + glEnableVertexAttribArray(2); + Logger::info(sstr("Buffer created with ", vertices.size(), " vertices and ", indices.size(), " indices")); } diff --git a/src/engine.cpp b/src/engine.cpp index 437aa13..9552592 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -144,7 +144,7 @@ void Engine::setup() // Create camera camera_ = std::make_shared(); - camera_->set_position(glm::vec3(0.0f, 1.0f, 10.0f)); + camera_->set_position(glm::vec3(0.0f, 4.0f, 12.0f)); camera_->set_rotation(glm::vec3(glm::radians(-20.0f), 0.0f, 0.0f)); camera_->set_projection( glm::perspective(glm::radians(45.0f), @@ -160,7 +160,7 @@ void Engine::setup() auto box_stack_mesh = Mesh::load("data/models/box_stack.obj"); if (box_stack_mesh) { auto box_stack_model = std::make_shared(box_stack_mesh); - box_stack_model->set_position(glm::vec3(-2.0f, 0.0f, 0.0f)); + box_stack_model->set_position(glm::vec3(-2.0f, -1.25f, 0.0f)); models_.push_back(box_stack_model); world_->add_entity(box_stack_model); Logger::info("Box stack model loaded and added to world"); @@ -172,7 +172,9 @@ void Engine::setup() auto gunslinger_model = std::make_shared(gunslinger_mesh); gunslinger_model->set_position(glm::vec3(2.0f, 0.0f, 0.0f)); - gunslinger_model->set_scale(glm::vec3(0.5f, 0.5f, 0.5f)); + gunslinger_model->set_rotation( + glm::vec3(0.0f, glm::radians(-30.0f), 0.0f)); + gunslinger_model->set_scale(glm::vec3(0.1f, 0.1f, 0.1f)); models_.push_back(gunslinger_model); world_->add_entity(gunslinger_model); Logger::info("Gunslinger model loaded and added to world");