Closed GoogleCodeExporter closed 9 years ago
In the given example, you're calling the draw method on a label that is created
"on the fly" during the draw
call. This will slow things a lot and is not the right way to do it. Please try
the following example to check if
you got same problems:
Import pyglet
window = pyglet.window.Window(fullscreen=True)
label = pyglet.text.Label('Pyglet!',
font_name='Arial',
font_size=36,
x=window.width//2, y=window.height//2,
color = (255,255,255,255),
anchor_x='center', anchor_y='center')
@window.event
def on_draw():
window.clear()
label.draw()
pyglet.app.run()
print "Done"
window = pyglet.window.Window(fullscreen=True)
label = pyglet.text.Label('Pyglet!',
font_name='Arial',
font_size=36,
x=window.width//2, y=window.height//2,
color = (255,255,255,255),
anchor_x='center', anchor_y='center')
@window.event
def on_draw():
window.clear()
label.draw()
pyglet.app.run()
print "Done"
Original comment by Nicolas.Rougier@gmail.com
on 16 Aug 2009 at 8:07
Yes, I think I am. The first screen shows "Pyglet!," I press escape, it closes,
and
the next screen comes up black.
Original comment by sam.m.bi...@gmail.com
on 16 Aug 2009 at 5:07
Can you try without fullscreen in both window, then only first, then only
second and post results ?
Original comment by Nicolas.Rougier@gmail.com
on 16 Aug 2009 at 5:18
It works when it's not fullscreen
Original comment by sam.m.bi...@gmail.com
on 23 Aug 2009 at 11:40
When the first one is not fullscreen, and the second is, only the first
displays.
When the first display is fullscreen, and the second isn't, they both work.
And as above, when neither are fullscreen they both work.
Original comment by sam.m.bi...@gmail.com
on 25 Aug 2009 at 6:58
I have no windows access to test.
Can anybody test the program under windows to confirm the bug ?
Original comment by Nicolas.Rougier@gmail.com
on 27 Aug 2009 at 7:15
For those looking to reproduce the bug, here is the code and the zip of a
windows
binary to reproduce the error with two subsequent fullscreen displays (although
it
also works for me not-fullscreen -> fullscreen). To test (the binary), run
pygletbug.py (.exe), and press escape each time a black screen shows up. For me,
'Pyglet!' only appears the first time.
Original comment by sam.m.bi...@gmail.com
on 28 Aug 2009 at 6:22
Attachments:
Not sure if this helps but calling on_resize() allows the label to be drawn to
the center of the screen.
Original comment by benjamin.debski@gmail.com
on 5 Jun 2011 at 2:32
I can confirm the defect with the .py posted at comment 7 , for win xp sp3,
python 2.6.6, pyglet 1.2dev changeset: 2618:625e1e191389 , on ati hardware.
Additionaly to 1st screen with text and second screen without, I got tracebacks
in 3/3 runs, see attachment.
Original comment by ccanepacc@gmail.com
on 7 Nov 2011 at 5:25
Attachments:
Running Nicolas's code with tip the second screen comes up blank but the label
gets drawn if there is an event e.g. pressing a key. Can anyone confirm this is
the same with their setup please?
Original comment by Adam.JT...@gmail.com
on 19 Jul 2013 at 11:54
Tests done with pyglet from repo default at changeset: 2766:eb6ff34e1ce8
(2013 07 20)
I modified the test pygletbug.py by using different text in each window
instance (to ascertain that what is seen in the second window is draw by the
second window)
From the visual side it work as expected: initially a full screen all black
with the first centered, after escape a new fullscreen black with the second
text centered.
Also I see a traceback:
D:\tmp\pyglet_fullscreen_bug>py -2.6 pygletbug.py
Done with window 1
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 295, in 'calling callback function'
File "D:\hg_externals\pyglet_dev\pyglet\window\win32\__init__.py", line 614, i
n _wnd_proc
result = event_handler(msg, wParam, lParam)
File "D:\hg_externals\pyglet_dev\pyglet\window\win32\__init__.py", line 909, i
n _event_move
self._reset_exclusive_mouse_screen()
File "D:\hg_externals\pyglet_dev\pyglet\window\win32\__init__.py", line 408, i
n _reset_exclusive_mouse_screen
_user32.GetClientRect(self._view_hwnd, byref(rect))
AttributeError: 'Win32Window' object has no attribute '_view_hwnd'
Done with window 2
The same result seen in two testbeds:
winxp sp3 , python 2.6, intel 945G integrated video
win7 32 bits, python 2.6, gpu ati radeon 6320M
Original comment by ccanepacc@gmail.com
on 20 Jul 2013 at 8:13
Running the code in #1 I get a fullscreen black window with Pyglet! label,
press ESC, and I get again a fullscreen black window with Pyglet! label. This
is with pyglet 1.1.4 and Linux, so it works for me.
In my experience with Pyglet 1.2 alpha1 there's a difference between passing
fullscreen=True when creating the window and using set_fullscreen. In the first
case on_resize is called once, on the second twice (with different width and
height values). Looks like on_resize is not called when creating the second
window, and that might be your problem.
Your code could be something like this:
import pyglet
window = pyglet.window.Window()
label = pyglet.text.Label('Pyglet!',
font_name='Arial',
font_size=36,
color = (255,255,255,255),
anchor_x='center', anchor_y='center')
@window.event
def on_resize(width, height):
print width, height
label.x = width//2
label.y = height//2
@window.event
def on_draw():
window.clear()
label.draw()
window.set_fullscreen(True)
pyglet.app.run()
print "Done"
window = pyglet.window.Window()
label = pyglet.text.Label('Pyglet!',
font_name='Arial',
font_size=36,
color = (255,255,255,255),
anchor_x='center', anchor_y='center')
@window.event
def on_resize(width, height):
print width, height
label.x = width//2
label.y = height//2
@window.event
def on_draw():
window.clear()
label.draw()
window.set_fullscreen(True)
pyglet.app.run()
print "Done"
##
Can you try it? If you get two calls to on_resize, it may solve your problem!
I don't know if this is a bug in Pyglet, it is possible. When the app is
terminated the event_loop or any state variable may be left behind and it is
preventing on_resize to be called again.
Original comment by useboxnet
on 20 Jul 2013 at 8:24
Tried the suggestion in #12 , it runs with no traceback, visible behavior is
correct, like in #11
Output is:
D:\tmp\pyglet_fullscreen_bug>py -2.6 pyglet_431_#12.py
640 480
1024 768
1024 768
1024 768
1024 768
Done window 1
1024 768
1024 768
1024 768
1024 768
Done window 2
Test done in the xp / intel rig
Attached test script for convenience
Original comment by ccanepacc@gmail.com
on 20 Jul 2013 at 8:54
Attachments:
Thanks Claudio, I should have attached the script myself.
To be honest, I don't know if ending the app and starting a new one is the
right way of doing this (is it supported at all?). I would try to subclass
Window an open/close windows without leaving the app loop (in theory, I've
never done anything like that).
I've been investigating why the second window is not receiving the on_resize
event with no results. The set_fullscreen works because explicitly generates
the on_resize event.
If that works for the OP, I'd vote to close the issue.
Original comment by useboxnet
on 20 Jul 2013 at 9:00
OK, I'm closing this issue. Please re-open it if the provided solution doesn't
fix your problem.
Original comment by useboxnet
on 21 Sep 2013 at 10:35
Original issue reported on code.google.com by
sam.m.bi...@gmail.com
on 26 Jul 2009 at 10:59