fix: rotation

This commit is contained in:
2025-10-13 20:12:46 +02:00
parent cf725c4c69
commit c1a5be6d90
2 changed files with 18 additions and 4 deletions

View File

@@ -27,10 +27,22 @@ Buffer::Buffer(const std::vector<Vertex>& 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<void*>(0));
glEnableVertexAttribArray(0);
// Attribute 1: color (vec3)
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<void*>(sizeof(glm::vec3)));
glEnableVertexAttribArray(1);
// Attribute 2: tex_coord (vec2)
glVertexAttribPointer(
2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<void*>(sizeof(glm::vec3) * 2));
glEnableVertexAttribArray(2);
Logger::info(sstr("Buffer created with ", vertices.size(),
" vertices and ", indices.size(), " indices"));
}

View File

@@ -144,7 +144,7 @@ void Engine::setup()
// Create camera
camera_ = std::make_shared<Camera>();
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<Model>(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<Model>(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");