Skip to content

Commit 6653a6e

Browse files
authored
Take hardware scaling level into account (#1206)
1 parent 08cec4c commit 6653a6e

File tree

4 files changed

+52
-50
lines changed

4 files changed

+52
-50
lines changed

Apps/package-lock.json

Lines changed: 42 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Apps/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"getNightly": "node scripts/getNightly.js"
77
},
88
"dependencies": {
9-
"babylonjs": "^5.42.2",
10-
"babylonjs-gui": "^5.42.2",
11-
"babylonjs-loaders": "^5.42.2",
12-
"babylonjs-materials": "^5.42.2",
9+
"babylonjs": "^5.48.1",
10+
"babylonjs-gui": "^5.48.1",
11+
"babylonjs-loaders": "^5.48.1",
12+
"babylonjs-materials": "^5.48.1",
1313
"chai": "^4.3.4",
1414
"jsc-android": "^241213.1.0",
1515
"mocha": "^9.2.2",

Core/Graphics/Source/FrameBuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ namespace Babylon::Graphics
4747

4848
uint16_t FrameBuffer::Width() const
4949
{
50-
return (m_width == 0 ? static_cast<uint16_t>(m_context.GetWidth()) : m_width);
50+
return (m_width == 0 ? static_cast<uint16_t>(m_context.GetWidth() / m_context.GetHardwareScalingLevel()) : m_width);
5151
}
5252

5353
uint16_t FrameBuffer::Height() const
5454
{
55-
return (m_height == 0 ? static_cast<uint16_t>(m_context.GetHeight()) : m_height);
55+
return (m_height == 0 ? static_cast<uint16_t>(m_context.GetHeight() / m_context.GetHardwareScalingLevel()) : m_height);
5656
}
5757

5858
bool FrameBuffer::DefaultBackBuffer() const

Plugins/NativeEngine/Source/NativeEngine.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <stb/stb_image_resize.h>
2222
#include <bx/math.h>
2323

24+
#include <cmath>
25+
2426
namespace Babylon
2527
{
2628
namespace
@@ -1613,12 +1615,12 @@ namespace Babylon
16131615

16141616
Napi::Value NativeEngine::GetRenderWidth(const Napi::CallbackInfo& info)
16151617
{
1616-
return Napi::Value::From(info.Env(), m_graphicsContext.GetWidth());
1618+
return Napi::Value::From(info.Env(), std::floor(m_graphicsContext.GetWidth() / m_graphicsContext.GetHardwareScalingLevel()));
16171619
}
16181620

16191621
Napi::Value NativeEngine::GetRenderHeight(const Napi::CallbackInfo& info)
16201622
{
1621-
return Napi::Value::From(info.Env(), m_graphicsContext.GetHeight());
1623+
return Napi::Value::From(info.Env(), std::floor(m_graphicsContext.GetHeight() / m_graphicsContext.GetHardwareScalingLevel()));
16221624
}
16231625

16241626
Napi::Value NativeEngine::GetHardwareScalingLevel(const Napi::CallbackInfo& info)

0 commit comments

Comments
 (0)