Skip to content

Commit

Permalink
Some tidy ups
Browse files Browse the repository at this point in the history
  • Loading branch information
wivlaro committed Dec 15, 2024
1 parent 0269877 commit 076e2a9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/MagnumGameApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ namespace MagnumGame {

MagnumGameApp::MagnumGameApp(const Arguments &arguments)
: Platform::Application(arguments, NoCreate)
, _pointerDrag{}
, controllerKeysHeld{}
{
/* Try 8x MSAA, fall back to zero samples if not possible. Enable only 2x
MSAA if we have enough DPI. */
Expand Down
2 changes: 1 addition & 1 deletion src/MagnumGameApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace MagnumGame {

void setupTextRenderer();

void renderTextBuffer(const Matrix3 & matrix3, const Color3& color3, const Color3& outline_colour, GL::Mesh &mesh);
void renderTextBuffer(const Matrix3 & matrix3, const Color3& color3, const Color3& outlineColour, GL::Mesh &mesh);

UnsignedInt pickObjectIdAt(Vector2 eventPosition);
};
Expand Down
7 changes: 3 additions & 4 deletions src/MagnumGameApp_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace MagnumGame {
}
}


_tweakables->addDebugMode("Font", 0, {
Tweakables::TweakableValue{"Smoothness", &fontSmoothness},
Tweakables::TweakableValue{"Outline start", &fontOutlineStart},
Expand Down Expand Up @@ -127,7 +126,7 @@ namespace MagnumGame {

void MagnumGameApp::renderDebugText() {
auto debugText= _tweakables->getDebugText();
if (_debugTextRenderer && debugText.size() > 0) {
if (_debugTextRenderer && !debugText.empty()) {

std::tie(_textMesh, std::ignore) =
Text::Renderer2D::render(*_font, _fontGlyphCache, fontSmallSize, debugText, _textVertexBuffer, _textIndexBuffer, GL::BufferUsage::DynamicDraw, Text::Alignment::BottomLeft);
Expand All @@ -136,11 +135,11 @@ namespace MagnumGame {
}
}

void MagnumGameApp::renderTextBuffer(const Matrix3 &textMatrix, const Color3 &color, const Color3 &outline_colour, GL::Mesh &mesh) {
void MagnumGameApp::renderTextBuffer(const Matrix3 &textMatrix, const Color3 &color, const Color3 &outlineColour, GL::Mesh &mesh) {
_textShader
.setTransformationProjectionMatrix( Matrix3::projection(Vector2{windowSize()}) * textMatrix)
.setColor(color)
.setOutlineColor(outline_colour)
.setOutlineColor(outlineColour)
.setOutlineRange(fontOutlineStart, fontOutlineEnd)
.setSmoothness(fontSmoothness)
.bindVectorTexture(_fontGlyphCache.texture())
Expand Down
9 changes: 5 additions & 4 deletions src/Tweakables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ namespace MagnumGame {
}

void Tweakables::DebugMode::printTweakables(std::ostringstream &os) const {
Corrade::Utility::Debug debug{&os};
Debug debug{&os};
debug << modeName;
for (size_t tweakableIndex = 0; tweakableIndex < tweakableValues.size(); tweakableIndex++) {
auto &tweakableValue = tweakableValues[tweakableIndex];
debug << Corrade::Utility::Debug::newline << tweakableValue.name << tweakableValue.get();
debug << Debug::newline << tweakableValue.name << tweakableValue.get();
debug << (tweakableIndex == getCurrentTweakableIndex() ? "<-CURRENT" : "");
}
}


void Tweakables::addDebugMode(const char *modeName, size_t initialIndex,
std::initializer_list<TweakableValue> tweakableValues) {
arrayAppend(_debugModes, InPlaceInit, modeName, initialIndex, std::move(tweakableValues));
arrayAppend(_debugModes, InPlaceInit, modeName, initialIndex, tweakableValues);
}

std::string Tweakables::getDebugText() const {
Expand All @@ -60,6 +60,7 @@ namespace MagnumGame {
}

void Tweakables::changeDebugModeIndex(int delta) {
_currentDebugModeIndex = (_currentDebugModeIndex + delta + _debugModes.size()) % _debugModes.size();
auto numDebugModes = _debugModes.size();
_currentDebugModeIndex = (_currentDebugModeIndex + delta + numDebugModes) % numDebugModes;
}
}

0 comments on commit 076e2a9

Please sign in to comment.