Skip to content

Commit

Permalink
add windowRequestsClose()
Browse files Browse the repository at this point in the history
  • Loading branch information
nmwsharp committed Mar 28, 2024
1 parent b6a6bd9 commit 8cd6179
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/polyscope/polyscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ void frameTick();
// Do shutdown work and de-initialize Polyscope
void shutdown();

// Returns true if the user has tried to exit the window at the OS level, e.g clicking the close button. Useful for
// deciding when to exit your control loop when using frameTick()
bool windowRequestsClose();

// === Global variables ===
namespace state {

Expand Down
8 changes: 8 additions & 0 deletions src/polyscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,14 @@ void show(size_t forFrames) {

void unshow() { unshowRequested = true; }

bool windowRequestsClose() {
if (render::engine && render::engine->windowRequestsClose()) {
return true;
}

return false;
}

void shutdown() {

// TODO should we make an effort to destruct everything here?
Expand Down

0 comments on commit 8cd6179

Please sign in to comment.