Skip to content

Commit

Permalink
Add jngl::round because std::lround returns long and there's no std::…
Browse files Browse the repository at this point in the history
…iround in C++ ffs
  • Loading branch information
jhasse committed Jan 27, 2024
1 parent d38de48 commit 80db4dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/jngl/other.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,7 @@ std::string getPreferredLanguage();
/// Opens a link (e.g. https://bixense.com) in the browser
void openURL(const std::string&);

/// Rounds a double to an integer, just like std::lround
int round(double v);

} // namespace jngl
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,4 +806,9 @@ ShaderProgram::Context useSimpleShaderProgram(const Mat3& modelview) {
return context;
}

int round(double v) {
assert(!std::isnan(v));
return static_cast<int>(std::lround(v));
}

} // namespace jngl

0 comments on commit 80db4dd

Please sign in to comment.