Skip to content

Commit 5c1d326

Browse files
authored
Use contentScaleFactor instead of scale (#237)
1 parent 8a1b8e8 commit 5c1d326

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Modules/@babylonjs/react-native/ios/BabylonNativeInterop.mm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ + (void)onBridgeWillInvalidate:(NSNotification*)notification
5555
}
5656

5757
+ (void)updateView:(MTKView*)mtkView {
58-
const int width = static_cast<int>(mtkView.bounds.size.width * UIScreen.mainScreen.scale);
59-
const int height = static_cast<int>(mtkView.bounds.size.height * UIScreen.mainScreen.scale);
58+
const CGFloat scale = mtkView.contentScaleFactor;
59+
const int width = static_cast<int>(mtkView.bounds.size.width * scale);
60+
const int height = static_cast<int>(mtkView.bounds.size.height * scale);
6061
if (width != 0 && height != 0) {
6162
Babylon::UpdateView((__bridge void*)mtkView, width, height);
6263
}
@@ -81,7 +82,7 @@ + (bool)isXRActive {
8182
+ (void)reportTouchEvent:(MTKView*)mtkView touches:(NSSet<UITouch*>*)touches event:(UIEvent*)event {
8283
for (UITouch* touch in touches) {
8384
if (touch.view == mtkView) {
84-
const CGFloat scale = UIScreen.mainScreen.scale;
85+
const CGFloat scale = mtkView.contentScaleFactor;
8586
const CGPoint pointerPosition = [touch locationInView:mtkView];
8687
const uint32_t x = static_cast<uint32_t>(pointerPosition.x * scale);
8788
const uint32_t y = static_cast<uint32_t>(pointerPosition.y * scale);

0 commit comments

Comments
 (0)