Skip to content

Commit ffa3579

Browse files
authored
Merge pull request #105 from resibots/fix_text
[gui]: fix text display
2 parents 06a88cf + 5ee467c commit ffa3579

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/robot_dart/gui/magnum/gs/camera.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,20 @@ namespace robot_dart {
309309
std::tie(mesh, rectangle) = Magnum::Text::Renderer2D::render(*debug_data.font, *debug_data.cache, 28.f, text->text, *debug_data.text_vertices, *debug_data.text_indices, Magnum::GL::BufferUsage::StaticDraw, Magnum::Text::Alignment(text->alignment));
310310

311311
auto viewport = Magnum::Vector2{_camera->viewport()};
312-
auto big = viewport.max();
313-
auto text_scaling = Magnum::Matrix3::scaling(Magnum::Vector2{big / 1024.f});
312+
auto sc = Magnum::Vector2{viewport.max() / 1024.f};
313+
auto text_scaling = Magnum::Matrix3::scaling(sc);
314314
auto extra_tr = Magnum::Matrix3(Magnum::Math::IdentityInit);
315315
if ((text->alignment & Magnum::Text::Implementation::AlignmentVertical) == Magnum::Text::Implementation::AlignmentLine) // if line (bottom) alignment, push the text a bit above
316-
extra_tr = Magnum::Matrix3::translation({0.f, 0.25f * rectangle.sizeY()});
316+
extra_tr = Magnum::Matrix3::translation({0.f, sc[1] * 0.25f * rectangle.sizeY()});
317317

318318
auto text_tr = Magnum::Matrix3(Magnum::Matrix3d(text->transformation));
319319

320320
if (text->draw_background) {
321-
auto bg_scaling = Magnum::Matrix3::scaling(Magnum::Vector2{viewport[0], rectangle.sizeY()});
321+
auto bg_scaling = Magnum::Matrix3::scaling(Magnum::Vector2{viewport[0], rectangle.sizeY() * sc[1]});
322322

323323
// draw the background
324324
(*debug_data.background_shader)
325-
.setTransformationProjectionMatrix(Magnum::Matrix3::projection(viewport) * text_tr * text_scaling * bg_scaling)
325+
.setTransformationProjectionMatrix(Magnum::Matrix3::projection(viewport) * text_tr * bg_scaling)
326326
.setColor(Magnum::Vector4(Magnum::Vector4d(text->background_color)))
327327
.draw(*debug_data.background_mesh);
328328
}

0 commit comments

Comments
 (0)