Skip to content

Commit

Permalink
[HUD] FPS counter added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jan 27, 2020
1 parent 7ce3321 commit 73e682b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/include/hud/HUD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class HUD : public gk::Transformable, public gk::Drawable {
bool m_isDebugOverlayVisible = false;

BlockInfoWidget m_blockInfoWidget;

Text m_fpsText;
};

#endif // HUD_HPP_
7 changes: 7 additions & 0 deletions client/source/hud/HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
#include <glm/gtc/matrix_transform.hpp>

#include <gk/core/GameClock.hpp>

#include "ClientPlayer.hpp"
#include "Config.hpp"
#include "HUD.hpp"
Expand Down Expand Up @@ -41,6 +43,8 @@ void HUD::setup() {

m_blockInfoWidget.setPosition(SCREEN_WIDTH / getScale().x / 2 - m_blockInfoWidget.width() / 2, 2, 0);

m_fpsText.setPosition(SCREEN_WIDTH / getScale().x - 36, 2);

m_crosshair.setup();
}

Expand All @@ -56,6 +60,8 @@ void HUD::update() {
// FIXME: Shouldn't be called every tick
m_hotbar.update();

m_fpsText.setText(std::to_string(gk::GameClock::getFpsAverage()) + " FPS");

m_blockCursor.update(m_hotbar, false);

if (m_isDebugOverlayVisible)
Expand Down Expand Up @@ -84,6 +90,7 @@ void HUD::draw(gk::RenderTarget &target, gk::RenderStates states) const {

target.draw(m_blockInfoWidget, states);
target.draw(m_hotbar, states);
target.draw(m_fpsText, states);

states.transform = gk::Transform::Identity;

Expand Down

0 comments on commit 73e682b

Please sign in to comment.