Skip to content

Commit fafcc9b

Browse files
committed
Make sky color configurable
1 parent 53e059c commit fafcc9b

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

include/core/Config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct Config {
1212
float fov{glm::radians(90.0f)}; // Vertical fov in radians
1313
float near{10.0f};
1414
float far{100000.0f};
15+
glm::vec3 sky_color{0.0f};
1516

1617
// camera
1718
CameraController::Type camera_controller_type{CameraController::Type::UNITY};

src/core/Serializer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ nlohmann::json Serializer::serialize(Config const& source) const
6161
target["fov"] = source.fov;
6262
target["near"] = source.near;
6363
target["far"] = source.far;
64+
target["sky_color"] = source.sky_color;
6465
target["camera_controller_type"] = source.camera_controller_type;
6566
target["movement_speed"] = source.movement_speed;
6667
target["rotation_speed"] = source.rotation_speed;
@@ -129,6 +130,7 @@ Config Serializer::deserialize_config(nlohmann::json& source) const
129130
.fov = source["fov"],
130131
.near = source["near"],
131132
.far = source["far"],
133+
.sky_color = source["sky_color"],
132134
.camera_controller_type = source["camera_controller_type"],
133135
.movement_speed = source["movement_speed"],
134136
.rotation_speed = source["rotation_speed"],

src/renderer/Camera.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ void Camera::draw(ViewingMode mode,
155155
shader.use();
156156

157157
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.id);
158+
159+
auto& sky_color = Project::get_current()->config.sky_color;
160+
glClearColor(sky_color.r, sky_color.g, sky_color.b, 0.0f);
158161
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
162+
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
163+
159164
glViewport(0, 0, framebuffer.width, framebuffer.height);
160165

161166
// view/projection transformations

src/ui/SettingsPane.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void SettingsPane::render()
7373
ImGui::SeparatorText("Textures");
7474

7575
ImGui::ColorEdit3("Fallback Texture Color", &config.fallback_color[0]);
76+
ImGui::ColorEdit3("Sky Color", &config.sky_color[0]);
7677
}
7778
ImGui::End();
7879
}

0 commit comments

Comments
 (0)