Skip to content

Commit

Permalink
Add overload print(const Mat3& modelview, const std::string& text)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Jul 17, 2024
1 parent 3cf8436 commit ec83040
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/jngl/font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ void print(const std::string& text, jngl::Vec2 position);
/// Print \a text at { \a xposition, \a yposition }
void print(const std::string& text, int xposition, int yposition);

/// Print \a text using \a modelview
void print(const Mat3& modelview, const std::string& text);

/// Get the font size used by print()
int getFontSize();

Expand Down
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ void print(const std::string& text, const int xposition, const int yposition) {
pWindow->print(text, xposition, yposition);
}

void print(const Mat3& modelview, const std::string& text) {
pWindow->print(modelview, text);
}

int getFontSize() {
return pWindow->getFontSize();
}
Expand Down
4 changes: 4 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ void Window::print(const std::string& text, const int xposition, const int yposi
getFontImpl()->print(ScaleablePixels(xposition), ScaleablePixels(yposition), text);
}

void Window::print(const Mat3& modelview, const std::string& text) {
getFontImpl()->print(modelview, text);
}

void Window::setFont(const std::string& filename) {
if (fonts_[fontSize_].find(filename) == fonts_[fontSize_].end()) {
auto font = std::make_shared<FontImpl>(filename, fontSize_, 0);
Expand Down
1 change: 1 addition & 0 deletions src/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Window {
void SetMouse(int xposition, int yposition);
void SetTitle(const std::string& title);
void print(const std::string& text, int xposition, int yposition);
void print(const Mat3& modelview, const std::string& text);
int getFontSize() const;
void setFontSize(int size);
void setFont(const std::string&);
Expand Down

0 comments on commit ec83040

Please sign in to comment.