Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If we are on a HiDPI display, we adjust the viewport size. #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

If we are on a HiDPI display, we adjust the viewport size. #346

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 15, 2021

This seems only relevant on macOS but a test for get_viewport_size() is added to try and make sure it doesn’t affect other archs too. This addresses #303 on macOS.

This seems only relevant on macOS but a test for get_viewport_size() is added to try and make sure it doesn’t affect other archs too.
@ccanepa
Copy link
Contributor

ccanepa commented Jul 15, 2021

@DidierMalenfant thanks for taking the time for this PR

Probably you have done it, but, can you confirn that the following interactive tests work as expected?

  • test/test_aspect_4_3_to_fullscreen.py
  • test/test_aspect_16_9_to_fullscreen.py
  • test/test_aspect_ratio_on_resize.py
  • test/test_coords.py
  • test/test_unscaled_win_resize.py

(I dont have access to a retina display)

@ghost
Copy link
Author

ghost commented Jul 16, 2021

Thanks @ccanepa I had checked the unit tests but not the interactive ones. Off to do that now and make sure everything is good on that end too.

@qingzhu521
Copy link

I think your solution is a wrong solution. It didnot solve the problem.

@Alan3344
Copy link

I checked the documentation, but I couldn't find an API for how to adjust the size of the scene
image

Thanks
Just add this patch,it get ok

diff --git a/cocos/director.py b/cocos/director.py
index 516fb8b..34aad7e 100644
--- a/cocos/director.py
+++ b/cocos/director.py
@@ -595,6 +595,12 @@ def scaled_resize_window(self, width, height):
         """
         # physical view size
         pw, ph = width, height
+        # Are we on HiDPI display?
+        viewportw, viewporth = self.window.get_viewport_size()
+        if viewportw > pw:
+            # yes
+            pw = viewportw
+            ph = viewporth
         # virtual (desired) view size
         vw, vh = self.get_window_size()
         # desired aspect ratio
@@ -642,6 +648,12 @@ def unscaled_resize_window(self, width, height):
         """
         self._usable_width = width
         self._usable_height = height
+        # Are we on HiDPI display?
+        viewportw, viewporth = self.window.get_viewport_size()
+        if viewportw > width:
+            # yes
+            self._usable_width = viewportw
+            self._usable_height = viewporth
 
         if self._resize_no_events:
             # setting viewport geometry, not handling an event

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants