-
Notifications
You must be signed in to change notification settings - Fork 147
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
layer size is a quarter of the window size on Mac #303
Comments
Hello, yousiku Is that image from a demo_grid_effects.py without any changes in the code ? That mac has a retina display ? Can you try this pure pyglet script? It should show the string '---o---' with the 'o' at the screen center. """shows the string '---o---', screen center should be on the 'o'
"""
from pyglet.gl import *
import pyglet
from pyglet.window import key
window = pyglet.window.Window(640, 480)
@window.event
def on_key_press(symbol, modifiers):
if symbol == key.ESCAPE:
window.has_exit = True
@window.event
def on_draw():
window.clear()
label.draw()
def update(dt):
pass
pyglet.clock.schedule_interval(update, 1/30.)
label = pyglet.text.Label('---o---',
font_size=14,
x=window.width // 2, y=window.height // 2,
anchor_x='center')
if __name__ == '__main__':
pyglet.app.run() |
@ccanepa |
To support the high resolution in Retina displays sometimes a software layer do a "behind your back" "double the widths and heights", so it may be related. But if pyglet displays ok, then we can make cocos to perform ok. I don't have access to a mac so I need to collect some info. |
Also, which pyglet version are you running? |
The line prints 640 480, and the pyglet version is 1.3.0 It seems that the problem is the Retina display, everything worked perfectly after applied this patch file from https://bitbucket.org/pyglet/pyglet/issues/45/retina-display-scaling-on-os-x Thank you so much! |
Hello, I am having the same issue on Macs with HiDPI screen resolutions (not just macbooks). One solution is to detect HiDPI resolutions and increase the window size values accordingly. This can be done in Director.scaled_resize_window and Director.unscaled_resize_window as per the patch attached below. Bear in mind however that I do not know enough about cocos or pyglet to know if this is a terribly inefficient way to go about it or not... I should add that this change requires pyglet.window.Window.get_viewport_size() which was introduced only fairly recently. |
Thanks for fixing this! I've met the same problem today, and after the path everything's cool now. 👍 |
The patch provided above seems to have a bug which causes a crash when you resize the window. I have a fix that could be merged and works even when resizing the window. I've posted it here as PR #340 for review and have some extra pairs of eyes looking at it. |
I fixed the issue in my original PR that was preventing the unit tests from completing. This is still probably mostly relevant for macOS but at least other architectures that provide get_viewport_size() on pyglet.Window should work too. New PR is #346 |
I almost have the same problem but the link you listed above is not available now. |
Whats the current fix for this? |
The patch by Didier Malenfant is on master. Release is lagging due to python 3.12 compatibility issues; one has been fixed, pyglet/pyglet#964 , theres an import one in cocos that should be not hard but I'm missing the time to look at.. |


My enviroment:
macOS 10.12.6
python 3.6.3
cocos2d 0.6.5
it's the same result running any of the samples on my computer.
When I print director.get_window_size() it returns (640, 480)
but when I set label.postion = 320, 240, it's obviously not in the center of window, and the layer's size is always a quarter of the window. why?
The text was updated successfully, but these errors were encountered: