google-code-export / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Having opened fullscreen twice, unable to draw to screen #431

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1) Open a pyglet window in fullscreen, draw something
2) Close window & exit app.
3) Run new app in fullscreen, draw something -> nothing shows up!

Run (tested WinXP/x86/Pyglet 1.1.3, downloaded the latest .msi):
import pyglet

def close(key,mod):
    window.close()
    pyglet.app.exit()
def draw():
    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').draw()
window = pyglet.window.Window(fullscreen=True)
window.on_key_press = close
window.on_draw = draw

pyglet.app.run()
print "Done"

window = pyglet.window.Window(fullscreen=True)
window.on_key_press = close
window.on_draw = draw
pyglet.app.run()
print "Done"

pyglet.info:
Python
------------------------------------------------------------------------------
sys.version: 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)]
sys.platform: win32
os.getcwd(): C:\

pyglet
------------------------------------------------------------------------------
pyglet.version: 1.1.3
pyglet.__file__: C:\Program
Files\Python26\lib\site-packages\pyglet\__init__.pyc
pyglet.options['debug_trace_depth'] = 1
pyglet.options['font'] = ('gdiplus', 'win32')
pyglet.options['xsync'] = True
pyglet.options['debug_trace_flush'] = True
pyglet.options['debug_win32'] = False
pyglet.options['debug_gl_trace'] = False
pyglet.options['debug_x11'] = False
pyglet.options['shadow_window'] = True
pyglet.options['debug_font'] = False
pyglet.options['debug_media'] = False
pyglet.options['debug_trace'] = False
pyglet.options['debug_lib'] = False
pyglet.options['graphics_vbo'] = True
pyglet.options['vsync'] = None
pyglet.options['debug_trace_args'] = False
pyglet.options['debug_gl'] = True
pyglet.options['debug_graphics_batch'] = False
pyglet.options['audio'] = ('directsound', 'openal', 'alsa', 'silent')
pyglet.options['debug_texture'] = False
pyglet.options['debug_gl_trace_args'] = False

pyglet.window
------------------------------------------------------------------------------
platform: <pyglet.window.win32.Win32Platform object at 0x00E55230>
display: <pyglet.window.win32.Win32Display object at 0x00E551B0>
screens[0]: Win32Screen(x=0, y=0, width=1680, height=1050)
screens[1]: Win32Screen(x=1680, y=0, width=1280, height=1024)
config['double_buffer'] = True
config['stereo'] = False
config['buffer_size'] = 32
config['aux_buffers'] = 4
config['sample_buffers'] = 0
config['samples'] = 0
config['red_size'] = 8
config['green_size'] = 8
config['blue_size'] = 8
config['alpha_size'] = 0
config['depth_size'] = 24
config['stencil_size'] = 0
config['accum_red_size'] = 16
config['accum_green_size'] = 16
config['accum_blue_size'] = 16
config['accum_alpha_size'] = 16
context: Win32Context()

pyglet.gl.gl_info
------------------------------------------------------------------------------
gl_info.get_version(): 3.0.0
gl_info.get_vendor(): NVIDIA Corporation
gl_info.get_renderer(): GeForce 8600 GT/PCI/SSE2/3DNOW!
gl_info.get_extensions():
   GL_ARB_color_buffer_float
   GL_ARB_depth_buffer_float
   GL_ARB_depth_texture
   GL_ARB_draw_buffers
   GL_ARB_draw_instanced
   GL_ARB_fragment_program
   GL_ARB_fragment_program_shadow
   GL_ARB_fragment_shader
   GL_ARB_framebuffer_object
   GL_ARB_geometry_shader4
   GL_ARB_half_float_pixel
   GL_ARB_half_float_vertex
   GL_ARB_imaging
   GL_ARB_map_buffer_range
   GL_ARB_multisample
   GL_ARB_multitexture
   GL_ARB_occlusion_query
   GL_ARB_pixel_buffer_object
   GL_ARB_point_parameters
   GL_ARB_point_sprite
   GL_ARB_shader_objects
   GL_ARB_shading_language_100
   GL_ARB_shadow
   GL_ARB_texture_border_clamp
   GL_ARB_texture_buffer_object
   GL_ARB_texture_compression
   GL_ARB_texture_cube_map
   GL_ARB_texture_env_add
   GL_ARB_texture_env_combine
   GL_ARB_texture_env_dot3
   GL_ARB_texture_float
   GL_ARB_texture_mirrored_repeat
   GL_ARB_texture_non_power_of_two
   GL_ARB_texture_rectangle
   GL_ARB_texture_rg
   GL_ARB_transpose_matrix
   GL_ARB_vertex_array_object
   GL_ARB_vertex_buffer_object
   GL_ARB_vertex_program
   GL_ARB_vertex_shader
   GL_ARB_window_pos
   GL_ATI_draw_buffers
   GL_ATI_texture_float
   GL_ATI_texture_mirror_once
   GL_EXTX_framebuffer_mixed_formats
   GL_EXT_Cg_shader
   GL_EXT_abgr
   GL_EXT_bgra
   GL_EXT_bindable_uniform
   GL_EXT_blend_color
   GL_EXT_blend_equation_separate
   GL_EXT_blend_func_separate
   GL_EXT_blend_minmax
   GL_EXT_blend_subtract
   GL_EXT_compiled_vertex_array
   GL_EXT_depth_bounds_test
   GL_EXT_direct_state_access
   GL_EXT_draw_buffers2
   GL_EXT_draw_instanced
   GL_EXT_draw_range_elements
   GL_EXT_fog_coord
   GL_EXT_framebuffer_blit
   GL_EXT_framebuffer_multisample
   GL_EXT_framebuffer_object
   GL_EXT_framebuffer_sRGB
   GL_EXT_geometry_shader4
   GL_EXT_gpu_program_parameters
   GL_EXT_gpu_shader4
   GL_EXT_multi_draw_arrays
   GL_EXT_packed_depth_stencil
   GL_EXT_packed_float
   GL_EXT_packed_pixels
   GL_EXT_pixel_buffer_object
   GL_EXT_point_parameters
   GL_EXT_rescale_normal
   GL_EXT_secondary_color
   GL_EXT_separate_specular_color
   GL_EXT_shadow_funcs
   GL_EXT_stencil_two_side
   GL_EXT_stencil_wrap
   GL_EXT_texture3D
   GL_EXT_texture_array
   GL_EXT_texture_buffer_object
   GL_EXT_texture_compression_latc
   GL_EXT_texture_compression_rgtc
   GL_EXT_texture_compression_s3tc
   GL_EXT_texture_cube_map
   GL_EXT_texture_edge_clamp
   GL_EXT_texture_env_add
   GL_EXT_texture_env_combine
   GL_EXT_texture_env_dot3
   GL_EXT_texture_filter_anisotropic
   GL_EXT_texture_integer
   GL_EXT_texture_lod
   GL_EXT_texture_lod_bias
   GL_EXT_texture_mirror_clamp
   GL_EXT_texture_object
   GL_EXT_texture_sRGB
   GL_EXT_texture_shared_exponent
   GL_EXT_texture_swizzle
   GL_EXT_timer_query
   GL_EXT_vertex_array
   GL_EXT_vertex_array_bgra
   GL_IBM_rasterpos_clip
   GL_IBM_texture_mirrored_repeat
   GL_KTX_buffer_region
   GL_NVX_conditional_render
   GL_NV_blend_square
   GL_NV_conditional_render
   GL_NV_copy_depth_to_color
   GL_NV_depth_buffer_float
   GL_NV_depth_clamp
   GL_NV_explicit_multisample
   GL_NV_fence
   GL_NV_float_buffer
   GL_NV_fog_distance
   GL_NV_fragment_program
   GL_NV_fragment_program2
   GL_NV_fragment_program_option
   GL_NV_framebuffer_multisample_coverage
   GL_NV_geometry_shader4
   GL_NV_gpu_program4
   GL_NV_half_float
   GL_NV_light_max_exponent
   GL_NV_multisample_coverage
   GL_NV_multisample_filter_hint
   GL_NV_occlusion_query
   GL_NV_packed_depth_stencil
   GL_NV_parameter_buffer_object
   GL_NV_pixel_data_range
   GL_NV_point_sprite
   GL_NV_primitive_restart
   GL_NV_register_combiners
   GL_NV_register_combiners2
   GL_NV_texgen_reflection
   GL_NV_texture_compression_vtc
   GL_NV_texture_env_combine4
   GL_NV_texture_expand_normal
   GL_NV_texture_rectangle
   GL_NV_texture_shader
   GL_NV_texture_shader2
   GL_NV_texture_shader3
   GL_NV_transform_feedback
   GL_NV_vertex_array_range
   GL_NV_vertex_array_range2
   GL_NV_vertex_program
   GL_NV_vertex_program1_1
   GL_NV_vertex_program2
   GL_NV_vertex_program2_option
   GL_NV_vertex_program3
   GL_S3_s3tc
   GL_SGIS_generate_mipmap
   GL_SGIS_texture_lod
   GL_SGIX_depth_texture
   GL_SGIX_shadow
   GL_SUN_slice_accum
   GL_WIN_swap_hint
   WGL_EXT_swap_control

pyglet.gl.glu_info
------------------------------------------------------------------------------
glu_info.get_version(): 1.2.2.0 Microsoft Corporation
glu_info.get_extensions():
   GL_EXT_bgra

pyglet.gl.glx_info
------------------------------------------------------------------------------
GLX not available.

pyglet.media
------------------------------------------------------------------------------
driver: pyglet.media.drivers.directsound

pyglet.media.avbin
------------------------------------------------------------------------------
Library: <CDLL 'avbin', handle 6e440000 at f913b0>
AVbin version: 5
FFmpeg revision: 13661

pyglet.media.drivers.openal
------------------------------------------------------------------------------
OpenAL not available.

Original issue reported on code.google.com by sam.m.bi...@gmail.com on 26 Jul 2009 at 10:59

GoogleCodeExporter commented 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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
It works when it's not fullscreen

Original comment by sam.m.bi...@gmail.com on 23 Aug 2009 at 11:40

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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:

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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:

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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:

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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