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

Passing a Config object to Window() causes error #739

Closed
siekmanj opened this issue Dec 26, 2022 · 2 comments
Closed

Passing a Config object to Window() causes error #739

siekmanj opened this issue Dec 26, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@siekmanj
Copy link

Describe the bug
Attempting to pass a pyglet.gl.Config object to a pyglet.window.Window causes an exception:

>>> import pyglet
>>> config = pyglet.gl.Config()
>>> window = pyglet.window.Window(config=config)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[my site-packages directory]/pyglet/window/__init__.py", line 613, in __init__
    self._create()
  File "[my site-packages directory]/pyglet/window/cocoa/__init__.py", line 190, in _create
    self.context.attach(self.canvas)
  File "[my site-packages directory]/pyglet/gl/cocoa.py", line 297, in attach
    self._nscontext.setView_(canvas.nsview)
AttributeError: 'NoneType' object has no attribute 'setView_'

I ran into this while attempting to add anti-aliasing to some lines I am drawing, but simply passing an empty config also seems to trigger this.

System Information:
I am on macOS 12.0.1, with an M1.

Platform
------------------------------------------------------------------------------
platform:  macOS-12.0.1-arm64-arm-64bit
release:   21.1.0
machine:   arm64

Python
------------------------------------------------------------------------------
implementation: CPython
sys.version: 3.8.9 (default, Aug  3 2021, 19:21:54) 
[Clang 13.0.0 (clang-1300.0.29.3)]
sys.maxint: 9223372036854775807
PyObjC not available
os.getcwd(): /Users/jonah/Documents/code/games/orbit

pyglet
------------------------------------------------------------------------------
pyglet.version: 2.0.2.1
pyglet.compat_platform: darwin
pyglet.__file__: /Users/jonah/Library/Python/3.8/lib/python/site-packages/pyglet/__init__.py
pyglet.options['audio'] = ('xaudio2', 'directsound', 'openal', 'pulse', 'silent')
pyglet.options['debug_font'] = False
pyglet.options['debug_gl'] = True
pyglet.options['debug_gl_trace'] = False
pyglet.options['debug_gl_trace_args'] = False
pyglet.options['debug_gl_shaders'] = False
pyglet.options['debug_graphics_batch'] = False
pyglet.options['debug_lib'] = False
pyglet.options['debug_media'] = False
pyglet.options['debug_texture'] = False
pyglet.options['debug_trace'] = False
pyglet.options['debug_trace_args'] = False
pyglet.options['debug_trace_depth'] = 1
pyglet.options['debug_trace_flush'] = True
pyglet.options['debug_win32'] = False
pyglet.options['debug_input'] = False
pyglet.options['debug_x11'] = False
pyglet.options['shadow_window'] = True
pyglet.options['vsync'] = None
pyglet.options['xsync'] = True
pyglet.options['xlib_fullscreen_override_redirect'] = False
pyglet.options['search_local_libs'] = True
pyglet.options['win32_gdi_font'] = False
pyglet.options['headless'] = False
pyglet.options['headless_device'] = 0
pyglet.options['win32_disable_shaping'] = False

pyglet.window
------------------------------------------------------------------------------
2022-12-25 17:23:52.163 Python[3257:207349] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/59/jmwvxw1x7ldfkphg0vy4xkr00000gn/T/com.apple.python3.savedState
display: <pyglet.canvas.cocoa.CocoaDisplay object at 0x10154c4f0>
screens[0]: CocoaScreen(x=0, y=0, width=1440, height=900)
config['double_buffer'] = 1
config['stereo'] = 0
config['buffer_size'] = 32
config['aux_buffers'] = 0
config['sample_buffers'] = 0
config['samples'] = 0
config['red_size'] = 0
config['green_size'] = 0
config['blue_size'] = 0
config['alpha_size'] = 8
config['depth_size'] = 32
config['stencil_size'] = 0
config['accum_red_size'] = 0
config['accum_green_size'] = 0
config['accum_blue_size'] = 0
config['accum_alpha_size'] = 0
config['major_version'] = 3
config['minor_version'] = 2
config['forward_compatible'] = None
config['opengl_api'] = 'gl'
config['debug'] = None
context: CocoaContext(id=4312614128, share=CocoaContext(id=4323555504, share=None))

window.context._info
------------------------------------------------------------------------------
gl_info.get_version(): (4, 1)
gl_info.get_vendor(): Apple
gl_info.get_renderer(): Apple M1
gl_info.get_extensions():
   GL_APPLE_client_storage
   GL_APPLE_container_object_shareable
   GL_APPLE_flush_render
   GL_APPLE_rgb_422
   GL_APPLE_row_bytes
   GL_APPLE_texture_range
   GL_ARB_ES2_compatibility
   GL_ARB_blend_func_extended
   GL_ARB_draw_buffers_blend
   GL_ARB_draw_indirect
   GL_ARB_explicit_attrib_location
   GL_ARB_gpu_shader5
   GL_ARB_gpu_shader_fp64
   GL_ARB_instanced_arrays
   GL_ARB_internalformat_query
   GL_ARB_occlusion_query2
   GL_ARB_sample_shading
   GL_ARB_sampler_objects
   GL_ARB_separate_shader_objects
   GL_ARB_shader_bit_encoding
   GL_ARB_shader_subroutine
   GL_ARB_shading_language_include
   GL_ARB_tessellation_shader
   GL_ARB_texture_buffer_object_rgb32
   GL_ARB_texture_cube_map_array
   GL_ARB_texture_gather
   GL_ARB_texture_query_lod
   GL_ARB_texture_rgb10_a2ui
   GL_ARB_texture_storage
   GL_ARB_texture_swizzle
   GL_ARB_timer_query
   GL_ARB_transform_feedback2
   GL_ARB_transform_feedback3
   GL_ARB_vertex_attrib_64bit
   GL_ARB_vertex_type_2_10_10_10_rev
   GL_ARB_viewport_array
   GL_EXT_debug_label
   GL_EXT_debug_marker
   GL_EXT_framebuffer_multisample_blit_scaled
   GL_EXT_texture_compression_s3tc
   GL_EXT_texture_filter_anisotropic
   GL_EXT_texture_sRGB_decode
   GL_NV_texture_barrier

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

pyglet.media
------------------------------------------------------------------------------
audio driver: <pyglet.media.drivers.openal.adaptation.OpenALDriver object at 0x100f63b80>

pyglet.media.ffmpeg
------------------------------------------------------------------------------
FFmpeg not available.

pyglet.media.drivers.openal
------------------------------------------------------------------------------
Library: <CDLL '/System/Library/Frameworks/OpenAL.framework/OpenAL', handle 4b16a92b0 at 0x10659f910>
Version: 1.1
Extensions:
   ALC_EXT_CAPTURE
   ALC_ENUMERATION_EXT
   ALC_EXT_MAC_OSX
   ALC_EXT_ASA
   ALC_EXT_ASA_DISTORTION
   ALC_EXT_ASA_ROGER_BEEP

pyglet.input.wintab
------------------------------------------------------------------------------
WinTab not available.

How To Reproduce
The three lines in the description seem sufficient to produce the error for me.

@siekmanj siekmanj added the bug Something isn't working label Dec 26, 2022
@benmoran56
Copy link
Member

Thanks for opening the ticket.

There was some leftover legacy code in the Config matching path. I just pushed a fix to the master branch, so give it a try from there. You can also explicitly pass the major/minor versions in your Config, and it will prevent the crash. Ex:

config = pyglet.gl.Config(major_version=3, minor_version=3)

This fix will be in the next point release.

@benmoran56
Copy link
Member

This is fixed in the 2.0.3 release, so closing for now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants