Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/renderer/include/renderer/camera_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class CameraController {
glm::vec2 GetPosition() const;
void SetPosition(const glm::vec2& position);

float GetYaw() const { return camera_.GetYaw(); }
void SetYaw(float yaw);

private:
static constexpr float initial_orbit_distance = 10.0f;
static constexpr float default_orbit_zoom_speed = 2.0f;
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/include/renderer/renderable/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Canvas : public OpenGlObject {

void AddBackgroundImage(const std::string& image_path,
const glm::vec3& origin, float resolution);
glm::vec2 GetBackgroundImageSize() const;

// Clear all points from the canvas
void Clear();
Expand Down Expand Up @@ -162,6 +163,7 @@ class Canvas : public OpenGlObject {
};

// Background image texture
glm::vec2 background_image_size_{0.0f, 0.0f};
std::mutex background_mutex_;
std::atomic<uint32_t> background_texture_{0};

Expand Down
19 changes: 16 additions & 3 deletions src/renderer/src/camera_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,22 @@ glm::vec2 CameraController::GetPosition() const {

void CameraController::SetPosition(const glm::vec2& position) {
glm::vec3 pos = camera_.GetPosition();
pos.x = position.x;
pos.z = position.y; // Use Y for Z in 2D view
camera_.SetPosition(pos);
if (mode_ == Mode::kTopDown) {
pos.x = position.x;
pos.z = -position.y; // Use Y for Z in 2D view
camera_.SetPosition(pos);
}
// do nothing in other modes
}

void CameraController::SetYaw(float yaw) {
if (mode_ == Mode::kTopDown) {
// In TopDown mode, we set the yaw directly
top_down_rotation_ = yaw;
camera_.SetYaw(yaw);
} else {
camera_.SetYaw(yaw);
}
}

void CameraController::ProcessKeyboard(
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/src/renderable/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,20 @@ void Canvas::AddBackgroundImage(const std::string& image_path,
}
}

glm::vec2 Canvas::GetBackgroundImageSize() const {
return background_image_size_;
}

void Canvas::SetupBackgroundImage(int width, int height, int channels,
unsigned char* data) {
if (!data) {
std::cerr << "ERROR::CANVAS::BACKGROUND_IMAGE_DATA_NULL" << std::endl;
return;
}

background_image_size_.x = static_cast<float>(width);
background_image_size_.y = static_cast<float>(height);

// Setup the background shader if it hasn't been compiled yet
try {
Shader background_vertex_shader(background_vertex_shader_source.c_str(),
Expand Down