Skip to content

Commit

Permalink
Add option to include UI in framedumps
Browse files Browse the repository at this point in the history
  • Loading branch information
scarletcafe committed Sep 16, 2019
1 parent b8cea80 commit 9d89ab6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions eldstar_server/src/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,22 @@ bool menu_control(eldstar::window& w, resource_manager& r, gl::perspective_camer
}
);
}),
menu_option("Framedump", [&w](void* ptr){
menu* m = reinterpret_cast<menu*>(ptr);
m->set_submenu(
"Framedump settings",
{
menu_option("Record with UI", [&w](void* ptr) {
w.recording_has_ui = true;
w.status("Framedumps will now include UI");
}),
menu_option("Record without UI", [&w](void* ptr) {
w.recording_has_ui = false;
w.status("Framedumps will now NOT include UI");
}),
}
);
}),
menu_option("Exit", [&w](void* ptr) { w.close(); }),
},
[&w]() { w.active_menu.reset(); }
Expand Down
5 changes: 4 additions & 1 deletion eldstar_server/src/entrypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int main(int argc, char** argv) {
world->render(*resources, window->color_mode, model_color, model_matrix, color_mode);
}

if (swapped && window->recording)
if (swapped && window->recording && !window->recording_has_ui)
eldstar::gl::dump_png("framedump/" + std::to_string(world->frame) + ".png", window->gl_window);

} else {
Expand Down Expand Up @@ -199,6 +199,9 @@ int main(int argc, char** argv) {
else
resources->opensans.render_utf8_bordered("Press [M] to open the menu", glm::vec2(20.0f, window_top));

if (world && swapped && window->recording && window->recording_has_ui)
eldstar::gl::dump_png("framedump/" + std::to_string(world->frame) + ".png", window->gl_window);

// If this was a dry run, exit successfully.
if (dry_run) {
std::cout << "dry run completed successfully" << std::endl;
Expand Down
7 changes: 6 additions & 1 deletion eldstar_server/src/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class window {
*/

public:
window() : gl_window(1184, 800, "Eldstar", true), start_time(glfwGetTime()), last_time(start_time), wireframe(false), mirror_game_camera(false), recording(false), color_mode(0) {
window()
: gl_window(1184, 800, "Eldstar", true),
start_time(glfwGetTime()), last_time(start_time),
wireframe(false), mirror_game_camera(false), recording(false), recording_has_ui(false), color_mode(0)
{
// Enable depth-testing and set the blend function
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
Expand Down Expand Up @@ -104,6 +108,7 @@ class window {
bool wireframe;
bool mirror_game_camera;
bool recording;
bool recording_has_ui;
int color_mode;

std::unique_ptr<menu> active_menu;
Expand Down

0 comments on commit 9d89ab6

Please sign in to comment.