diff --git a/common/lc_view.cpp b/common/lc_view.cpp index aa8ef01a..3972d83b 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -1150,9 +1150,13 @@ void lcView::DrawBackground(int CurrentTileRow, int TotalTileRows, int CurrentTi void lcView::DrawViewport() const { + float Scale = GetUIScale(); + float Width = mWidth / Scale; + float Height = mHeight / Scale; + mContext->SetWorldMatrix(lcMatrix44Identity()); mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0))); - mContext->SetProjectionMatrix(lcMatrix44Ortho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f)); + mContext->SetProjectionMatrix(lcMatrix44Ortho(0.0f, Width, 0.0f, Height, -1.0f, 1.0f)); mContext->SetLineWidth(1.0f); mContext->SetDepthWrite(false); @@ -1165,7 +1169,7 @@ void lcView::DrawViewport() const else mContext->SetColor(lcVector4FromColor(lcGetPreferences().mInactiveViewColor)); - float Verts[8] = { 0.0f, 0.0f, mWidth - 1.0f, 0.0f, mWidth - 1.0f, mHeight - 1.0f, 0.0f, mHeight - 1.0f }; + float Verts[8] = { 0.0f, 0.0f, Width - 1.0f, 0.0f, Width - 1.0f, Height - 1.0f, 0.0f, Height - 1.0f }; mContext->SetVertexBufferPointer(Verts); mContext->SetVertexFormatPosition(2); @@ -1181,7 +1185,7 @@ void lcView::DrawViewport() const mContext->EnableColorBlend(true); - gTexFont.PrintText(mContext, 3.0f, (float)mHeight - 1.0f - 6.0f, 0.0f, GetUIScale(), CameraName.toLatin1().constData()); + gTexFont.PrintText(mContext, 3.0f, (float)Height - 1.0f - 6.0f, 0.0f, CameraName.toLatin1().constData()); mContext->EnableColorBlend(false); } @@ -1243,26 +1247,28 @@ void lcView::DrawAxes() const }; lcMatrix44 TranslationMatrix; + float Scale = GetUIScale(); switch (Preferences.mAxisIconLocation) { default: case lcAxisIconLocation::BottomLeft: - TranslationMatrix = lcMatrix44Translation(lcVector3(32, 32, 0.0f)); + TranslationMatrix = lcMatrix44Translation(lcVector3(32, 32, 0.0f) / Scale); break; case lcAxisIconLocation::BottomRight: - TranslationMatrix = lcMatrix44Translation(lcVector3(mWidth - 36, 32, 0.0f)); + TranslationMatrix = lcMatrix44Translation(lcVector3(mWidth - 36, 32, 0.0f) / Scale); break; case lcAxisIconLocation::TopLeft: - TranslationMatrix = lcMatrix44Translation(lcVector3(32, mHeight - 36, 0.0f)); + TranslationMatrix = lcMatrix44Translation(lcVector3(32, mHeight - 36, 0.0f) / Scale); break; case lcAxisIconLocation::TopRight: - TranslationMatrix = lcMatrix44Translation(lcVector3(mWidth - 36, mHeight - 36, 0.0f)); + TranslationMatrix = lcMatrix44Translation(lcVector3(mWidth - 36, mHeight - 36, 0.0f) / Scale); break; } + lcMatrix44 WorldViewMatrix = mCamera->mWorldView; WorldViewMatrix.SetTranslation(lcVector3(0, 0, 0)); @@ -1270,7 +1276,7 @@ void lcView::DrawAxes() const mContext->SetMaterial(lcMaterialType::UnlitVertexColor); mContext->SetWorldMatrix(lcMatrix44Identity()); mContext->SetViewMatrix(lcMul(WorldViewMatrix, TranslationMatrix)); - mContext->SetProjectionMatrix(lcMatrix44Ortho(0, mWidth, 0, mHeight, -50, 50)); + mContext->SetProjectionMatrix(lcMatrix44Ortho(0, mWidth / Scale, 0, mHeight / Scale, -50, 50)); mContext->SetVertexBufferPointer(Verts); mContext->SetVertexFormat(0, 3, 0, 0, 4, false); @@ -1720,7 +1726,8 @@ float lcView::GetOverlayScale() const lcVector3 Point = UnprojectPoint(ScreenPos); lcVector3 Dist(Point - WorldMatrix.GetTranslation()); - return Dist.Length() * 5.0f; + + return Dist.Length() * 5.0f * GetUIScale(); } void lcView::BeginDrag(lcDragState DragState) diff --git a/common/lc_viewmanipulator.cpp b/common/lc_viewmanipulator.cpp index 6b5f83f3..2a154162 100644 --- a/common/lc_viewmanipulator.cpp +++ b/common/lc_viewmanipulator.cpp @@ -896,7 +896,7 @@ void lcViewManipulator::DrawRotate(lcTrackButton TrackButton, lcTrackTool TrackT gTexFont.GetStringDimensions(&cx, &cy, buf); Context->SetColor(0.8f, 0.8f, 0.0f, 1.0f); - gTexFont.PrintText(Context, ScreenPos[0] - (cx / 2), ScreenPos[1] + (cy / 2), 0.0f, mView->GetUIScale(), buf); + gTexFont.PrintText(Context, ScreenPos[0] - (cx / 2), ScreenPos[1] + (cy / 2), 0.0f, buf); Context->EnableColorBlend(false); } diff --git a/common/lc_viewsphere.cpp b/common/lc_viewsphere.cpp index fd83801c..dcfc941a 100644 --- a/common/lc_viewsphere.cpp +++ b/common/lc_viewsphere.cpp @@ -183,9 +183,10 @@ void lcViewSphere::Draw() return; lcContext* Context = mView->mContext; + const float UIScale = mView->GetUIScale(); const int Width = mView->GetWidth(); const int Height = mView->GetHeight(); - const int ViewportSize = mSize; + const int ViewportSize = mSize * UIScale; const int Left = (mLocation == lcViewSphereLocation::BottomLeft || mLocation == lcViewSphereLocation::TopLeft) ? 0 : Width - ViewportSize; const int Bottom = (mLocation == lcViewSphereLocation::BottomLeft || mLocation == lcViewSphereLocation::BottomRight) ? 0 : Height - ViewportSize; Context->SetViewport(Left, Bottom, ViewportSize, ViewportSize); @@ -240,7 +241,7 @@ void lcViewSphere::Draw() Context->EnableCullFace(false); Context->SetDepthFunction(lcDepthFunction::LessEqual); - Context->SetViewport(0, 0, Width, Height); + Context->SetViewport(0, 0, mView->GetWidth(), mView->GetHeight()); } bool lcViewSphere::OnLeftButtonDown() @@ -323,9 +324,10 @@ bool lcViewSphere::IsDragging() const std::bitset<6> lcViewSphere::GetIntersectionFlags(lcVector3& Intersection) const { + const float UIScale = mView->GetUIScale(); const int Width = mView->GetWidth(); const int Height = mView->GetHeight(); - const int ViewportSize = mSize; + const int ViewportSize = mSize * UIScale; const int Left = (mLocation == lcViewSphereLocation::BottomLeft || mLocation == lcViewSphereLocation::TopLeft) ? 0 : Width - ViewportSize; const int Bottom = (mLocation == lcViewSphereLocation::BottomLeft || mLocation == lcViewSphereLocation::BottomRight) ? 0 : Height - ViewportSize; const int x = mView->GetMouseX() - Left; diff --git a/common/lc_viewwidget.cpp b/common/lc_viewwidget.cpp index 6f92a937..e3bc292d 100644 --- a/common/lc_viewwidget.cpp +++ b/common/lc_viewwidget.cpp @@ -77,11 +77,8 @@ void lcViewWidget::initializeGL() void lcViewWidget::resizeGL(int Width, int Height) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - const float Scale = devicePixelRatioF(); -#else - const int Scale = devicePixelRatio(); -#endif + const float Scale = GetDeviceScale(); + mView->SetSize(Width * Scale, Height * Scale); } diff --git a/common/texfont.cpp b/common/texfont.cpp index 97d740fd..01bbe9d7 100644 --- a/common/texfont.cpp +++ b/common/texfont.cpp @@ -162,7 +162,7 @@ void TexFont::GetStringDimensions(int* cx, int* cy, const char* Text) const } } -void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, float Scale, const char* Text) const +void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, const char* Text) const { const size_t Length = strlen(Text); @@ -175,8 +175,8 @@ void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, floa while (*Text) { int ch = *Text; - float Right = Left + mGlyphs[ch].width * Scale; - float Bottom = Top - mFontHeight * Scale; + float Right = Left + mGlyphs[ch].width; + float Bottom = Top - mFontHeight; *CurVert++ = Left; *CurVert++ = Top; diff --git a/common/texfont.h b/common/texfont.h index 297d034f..9dddf466 100644 --- a/common/texfont.h +++ b/common/texfont.h @@ -18,7 +18,7 @@ public: bool Initialize(lcContext* Context); void Reset(); - void PrintText(lcContext* Context, float Left, float Top, float Z, float Scale, const char* Text) const; + void PrintText(lcContext* Context, float Left, float Top, float Z, const char* Text) const; void GetTriangles(const lcMatrix44& Transform, const char* Text, float* Buffer) const; void GetGlyphTriangles(float Left, float Top, float Z, int Glyph, float* Buffer) const; void GetStringDimensions(int* cx, int* cy, const char* Text) const;