Skip to content

Commit

Permalink
[DebugOverlay] Use Shift+F3 to show OpenGL-related info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed May 23, 2021
1 parent 127d200 commit d738e0c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
16 changes: 14 additions & 2 deletions source/client/hud/DebugOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ DebugOverlay::DebugOverlay(const ClientPlayer &player, const ClientWorld &world)
m_positionText.setColor(gk::Color::White);
}

void DebugOverlay::update() {
void DebugOverlay::update(bool printOpenGLInfo) {
s32 px = std::floor(m_player.x());
s32 py = std::floor(m_player.y());
s32 pz = std::floor(m_player.z());
Expand Down Expand Up @@ -101,7 +101,19 @@ void DebugOverlay::update() {
u16 minute = GameTime::getCurrentMinute();
stream << "Day " << day << " ";
stream << (hour < 10 ? "0" : "") << hour << ":";
stream << (minute < 10 ? "0" : "") << minute;
stream << (minute < 10 ? "0" : "") << minute << '\n';

if (printOpenGLInfo) {
GLint major, minor;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);

stream << "GL Vendor: " << glGetString(GL_VENDOR) << '\n';
stream << "GL Renderer: " << glGetString(GL_RENDERER) << '\n';
stream << "GL Version (string): " << glGetString(GL_VERSION) << '\n';
stream << "GL Version (integer): " << major << "." << minor << '\n';
stream << "GLSL Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << '\n';
}

m_positionText.setString(stream.str());
}
Expand Down
2 changes: 1 addition & 1 deletion source/client/hud/DebugOverlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DebugOverlay : public gk::Transformable, public gk::Drawable {
public:
DebugOverlay(const ClientPlayer &player, const ClientWorld &world);

void update();
void update(bool printOpenGLInfo);

private:
void draw(gk::RenderTarget &target, gk::RenderStates states) const override;
Expand Down
6 changes: 4 additions & 2 deletions source/client/hud/HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ void HUD::setup() {
}

void HUD::onEvent(const SDL_Event &event) {
if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_F3)
if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_F3) {
m_isDebugOverlayVisible ^= 1;
m_printOpenGLInfo = event.key.keysym.mod & KMOD_SHIFT;
}

if (Config::isHotbarVisible)
m_hotbar.onEvent(event);
Expand Down Expand Up @@ -100,7 +102,7 @@ void HUD::update() {
m_blockCursor.update(m_hotbar);

if (m_isDebugOverlayVisible)
m_debugOverlay.update();
m_debugOverlay.update(m_printOpenGLInfo);

if (Config::isBlockInfoWidgetEnabled) {
m_blockInfoWidget.update();
Expand Down
1 change: 1 addition & 0 deletions source/client/hud/HUD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class HUD : public gk::Transformable, public gk::Drawable {

DebugOverlay m_debugOverlay;
bool m_isDebugOverlayVisible = false;
bool m_printOpenGLInfo = false;

BlockInfoWidget m_blockInfoWidget;

Expand Down

0 comments on commit d738e0c

Please sign in to comment.