Python pyglet.options() Examples
The following are 30
code examples of pyglet.options().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyglet
, or try the search function
.
Example #1
Source File: render.py From meshrender with Apache License 2.0 | 6 votes |
def _init_pyglet(self): import pyglet pyglet.options['shadow_window'] = False self._window = None conf = pyglet.gl.Config( depth_size=24, double_buffer=True, major_version=3, minor_version=2 ) try: self._window = pyglet.window.Window(config=conf, visible=False, resizable=False, width=1, height=1) except Exception as e: raise ValueError('Failed to initialize Pyglet window with an OpenGL >= 3+ context. ' \ 'If you\'re logged in via SSH, ensure that you\'re running your script ' \ 'with vglrun (i.e. VirtualGL). Otherwise, the internal error message was: ' \ '"{}"'.format(e.message))
Example #2
Source File: platforms.py From gqn-dataset-renderer with MIT License | 6 votes |
def init_context(self): import pyglet pyglet.options['shadow_window'] = False self._window = None conf = pyglet.gl.Config( sample_buffers=1, samples=4, depth_size=24, double_buffer=True, major_version=OPEN_GL_MAJOR, minor_version=OPEN_GL_MINOR ) try: self._window = pyglet.window.Window(config=conf, visible=False, resizable=False, width=1, height=1) except Exception as e: raise ValueError( 'Failed to initialize Pyglet window with an OpenGL >= 3+ ' 'context. If you\'re logged in via SSH, ensure that you\'re ' 'running your script with vglrun (i.e. VirtualGL). The ' 'internal error message was "{}"'.format(e) )
Example #3
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 6 votes |
def _error_handler(display, event): # By default, all errors are silently ignored: this has a better chance # of working than the default behaviour of quitting ;-) # # We've actually never seen an error that was our fault; they're always # driver bugs (and so the reports are useless). Nevertheless, set # environment variable PYGLET_DEBUG_X11 to 1 to get dumps of the error # and a traceback (execution will continue). if pyglet.options['debug_x11']: event = event.contents buf = c_buffer(1024) xlib.XGetErrorText(display, event.error_code, buf, len(buf)) print 'X11 error:', buf.value print ' serial:', event.serial print ' request:', event.request_code print ' minor:', event.minor_code print ' resource:', event.resourceid import traceback print 'Python stack trace (innermost last):' traceback.print_stack() return 0
Example #4
Source File: xlib.py From pyglet with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _error_handler(display, event): # By default, all errors are silently ignored: this has a better chance # of working than the default behaviour of quitting ;-) # # We've actually never seen an error that was our fault; they're always # driver bugs (and so the reports are useless). Nevertheless, set # environment variable PYGLET_DEBUG_X11 to 1 to get dumps of the error # and a traceback (execution will continue). import pyglet if pyglet.options['debug_x11']: event = event.contents buf = c_buffer(1024) xlib.XGetErrorText(display, event.error_code, buf, len(buf)) print('X11 error:', buf.value) print(' serial:', event.serial) print(' request:', event.request_code) print(' minor:', event.minor_code) print(' resource:', event.resourceid) import traceback print('Python stack trace (innermost last):') traceback.print_stack() return 0
Example #5
Source File: __init__.py From pyglet with BSD 3-Clause "New" or "Revised" License | 6 votes |
def set_exclusive_keyboard(self, exclusive=True): # http://developer.apple.com/mac/library/technotes/tn2002/tn2062.html # http://developer.apple.com/library/mac/#technotes/KioskMode/ # BUG: System keys like F9 or command-tab are disabled, however # pyglet also does not receive key press events for them. # This flag is queried by window delegate to determine whether # the quit menu item is active. self._is_keyboard_exclusive = exclusive if exclusive: # "Be nice! Don't disable force-quit!" # -- Patrick Swayze, Road House (1989) options = cocoapy.NSApplicationPresentationHideDock | \ cocoapy.NSApplicationPresentationHideMenuBar | \ cocoapy.NSApplicationPresentationDisableProcessSwitching | \ cocoapy.NSApplicationPresentationDisableHideApplication else: options = cocoapy.NSApplicationPresentationDefault NSApp = NSApplication.sharedApplication() NSApp.setPresentationOptions_(options)
Example #6
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 6 votes |
def _error_handler(display, event): # By default, all errors are silently ignored: this has a better chance # of working than the default behaviour of quitting ;-) # # We've actually never seen an error that was our fault; they're always # driver bugs (and so the reports are useless). Nevertheless, set # environment variable PYGLET_DEBUG_X11 to 1 to get dumps of the error # and a traceback (execution will continue). if pyglet.options['debug_x11']: event = event.contents buf = c_buffer(1024) xlib.XGetErrorText(display, event.error_code, buf, len(buf)) print 'X11 error:', buf.value print ' serial:', event.serial print ' request:', event.request_code print ' minor:', event.minor_code print ' resource:', event.resourceid import traceback print 'Python stack trace (innermost last):' traceback.print_stack() return 0
Example #7
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 6 votes |
def _error_handler(display, event): # By default, all errors are silently ignored: this has a better chance # of working than the default behaviour of quitting ;-) # # We've actually never seen an error that was our fault; they're always # driver bugs (and so the reports are useless). Nevertheless, set # environment variable PYGLET_DEBUG_X11 to 1 to get dumps of the error # and a traceback (execution will continue). if pyglet.options['debug_x11']: event = event.contents buf = c_buffer(1024) xlib.XGetErrorText(display, event.error_code, buf, len(buf)) print 'X11 error:', buf.value print ' serial:', event.serial print ' request:', event.request_code print ' minor:', event.minor_code print ' resource:', event.resourceid import traceback print 'Python stack trace (innermost last):' traceback.print_stack() return 0
Example #8
Source File: pyglet_platform.py From pyrender with MIT License | 5 votes |
def init_context(self): import pyglet pyglet.options['shadow_window'] = False try: pyglet.lib.x11.xlib.XInitThreads() except Exception: pass self._window = None conf = pyglet.gl.Config( sample_buffers=1, samples=4, depth_size=24, double_buffer=True, major_version=OPEN_GL_MAJOR, minor_version=OPEN_GL_MINOR ) try: self._window = pyglet.window.Window(config=conf, visible=False, resizable=False, width=1, height=1) except Exception as e: raise ValueError( 'Failed to initialize Pyglet window with an OpenGL >= 3+ ' 'context. If you\'re logged in via SSH, ensure that you\'re ' 'running your script with vglrun (i.e. VirtualGL). The ' 'internal error message was "{}"'.format(e) )
Example #9
Source File: core.py From geoplotlib with MIT License | 5 votes |
def start(self): #pyglet.options['debug_gl'] = False if self.geoplotlib_config.bbox is not None: self.proj.fit(self.geoplotlib_config.bbox, force_zoom=self.geoplotlib_config.requested_zoom) elif len(self.geoplotlib_config.layers) > 0: self.proj.fit(BoundingBox.from_bboxes([l.bbox() for l in self.geoplotlib_config.layers]), force_zoom=self.geoplotlib_config.requested_zoom) for l in self.geoplotlib_config.layers: l.invalidate(self.proj) pyglet.app.run()
Example #10
Source File: window.py From demosys-py with ISC License | 5 votes |
def __init__(self): """ Opens a window using pyglet, registers input callbacks and creates a moderngl context. """ super().__init__() # Disable all error checking pyglet.options['debug_gl'] = False # Set context parameters config = pyglet.gl.Config() config.double_buffer = True config.major_version = self.gl_version.major config.minor_version = self.gl_version.minor config.forward_compatible = True config.sample_buffers = 1 if self.samples > 1 else 0 config.samples = self.samples # Find monitor # Open window self.window = PygletWrapper( width=self.width, height=self.height, caption=self.title, resizable=self.resizable, vsync=self.vsync, fullscreen=self.fullscreen, ) self.window.set_mouse_visible(self.cursor) self.window.event(self.on_key_press) self.window.event(self.on_key_release) self.window.event(self.on_mouse_motion) self.window.event(self.on_resize) self.ctx = moderngl.create_context(require=self.gl_version.code) context.WINDOW = self self.fbo = self.ctx.screen self.set_default_viewport()
Example #11
Source File: __init__.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] self._vsync = vsync self.context.set_vsync(vsync)
Example #12
Source File: __init__.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] self._interval = vsync if not self._fullscreen: # Disable interval if composition is enabled to avoid conflict with DWM. if self._always_dwm or self._dwm_composition_enabled(): vsync = 0 self.context.set_vsync(vsync)
Example #13
Source File: __init__.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _create_shadow_window(): global _shadow_window import pyglet if not pyglet.options['shadow_window'] or _is_pyglet_doc_run: return from pyglet.window import Window _shadow_window = Window(width=1, height=1, visible=False) _shadow_window.switch_to() from pyglet import app app.windows.remove(_shadow_window)
Example #14
Source File: info.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def dump_ffmpeg(): """Dump FFmpeg info.""" import pyglet pyglet.options['search_local_libs'] = True import pyglet.media if pyglet.media.have_ffmpeg(): from pyglet.media.codecs.ffmpeg import get_version print('FFmpeg version:', get_version()) else: print('FFmpeg not available.')
Example #15
Source File: info.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def dump_pyglet(): """Dump pyglet version and options.""" import pyglet print('pyglet.version:', pyglet.version) print('pyglet.compat_platform:', pyglet.compat_platform) print('pyglet.__file__:', pyglet.__file__) for key, value in pyglet.options.items(): print("pyglet.options['%s'] = %r" % (key, value))
Example #16
Source File: annotations.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def skip_platform(platform): """ Skip test on the given platform(s). :param list(str) platform: A list of platform identifiers as returned by :data:`pyglet.options`. See also :class:`tests.annotations.Platform`. """ return pytest.mark.skipif(pyglet.compat_platform in platform, reason='not supported for platform: %s' % str(platform))
Example #17
Source File: annotations.py From pyglet with BSD 3-Clause "New" or "Revised" License | 5 votes |
def require_platform(platform): """ Only run the test on the given platform(s), skip on other platforms. :param list(str) platform: A list of platform identifiers as returned by :data:`pyglet.options`. See also :class:`tests.annotations.Platform`. """ return pytest.mark.skipif(pyglet.compat_platform not in platform, reason='requires platform: %s' % str(platform))
Example #18
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] if wgl_info.have_extension('WGL_EXT_swap_control'): wglext_arb.wglSwapIntervalEXT(int(vsync)) else: warnings.warn('Could not set vsync; unsupported extension.')
Example #19
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] self._vsync = vsync # _recreate depends on this swap = c_long(int(vsync)) agl.aglSetInteger(self._agl_context, agl.AGL_SWAP_INTERVAL, byref(swap))
Example #20
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def _create_shadow_window(): global _shadow_window import pyglet if not pyglet.options['shadow_window'] or _is_epydoc: return from pyglet.window import Window _shadow_window = Window(width=1, height=1, visible=False) _shadow_window.switch_to() from pyglet import app app.windows.remove(_shadow_window)
Example #21
Source File: info.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def dump_pyglet(): '''Dump pyglet version and options.''' import pyglet print 'pyglet.version:', pyglet.version print 'pyglet.__file__:', pyglet.__file__ for key, value in pyglet.options.items(): print "pyglet.options['%s'] = %r" % (key, value)
Example #22
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] if wgl_info.have_extension('WGL_EXT_swap_control'): wglext_arb.wglSwapIntervalEXT(int(vsync)) else: warnings.warn('Could not set vsync; unsupported extension.')
Example #23
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] self._vsync = vsync # _recreate depends on this swap = c_long(int(vsync)) agl.aglSetInteger(self._agl_context, agl.AGL_SWAP_INTERVAL, byref(swap))
Example #24
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def _create_shadow_window(): global _shadow_window import pyglet if not pyglet.options['shadow_window'] or _is_epydoc: return from pyglet.window import Window _shadow_window = Window(width=1, height=1, visible=False) _shadow_window.switch_to() from pyglet import app app.windows.remove(_shadow_window)
Example #25
Source File: info.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def dump_pyglet(): '''Dump pyglet version and options.''' import pyglet print 'pyglet.version:', pyglet.version print 'pyglet.__file__:', pyglet.__file__ for key, value in pyglet.options.items(): print "pyglet.options['%s'] = %r" % (key, value)
Example #26
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] if wgl_info.have_extension('WGL_EXT_swap_control'): wglext_arb.wglSwapIntervalEXT(int(vsync)) else: warnings.warn('Could not set vsync; unsupported extension.')
Example #27
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def set_vsync(self, vsync): if pyglet.options['vsync'] is not None: vsync = pyglet.options['vsync'] self._vsync = vsync # _recreate depends on this swap = c_long(int(vsync)) agl.aglSetInteger(self._agl_context, agl.AGL_SWAP_INTERVAL, byref(swap))
Example #28
Source File: __init__.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def _create_shadow_window(): global _shadow_window import pyglet if not pyglet.options['shadow_window'] or _is_epydoc: return from pyglet.window import Window _shadow_window = Window(width=1, height=1, visible=False) _shadow_window.switch_to() from pyglet import app app.windows.remove(_shadow_window)
Example #29
Source File: info.py From flappy-bird-py with GNU General Public License v2.0 | 5 votes |
def dump_pyglet(): '''Dump pyglet version and options.''' import pyglet print 'pyglet.version:', pyglet.version print 'pyglet.__file__:', pyglet.__file__ for key, value in pyglet.options.items(): print "pyglet.options['%s'] = %r" % (key, value)
Example #30
Source File: __init__.py From pyglet with BSD 3-Clause "New" or "Revised" License | 4 votes |
def get_audio_driver(): """Get the preferred audio driver for the current platform. Currently pyglet supports DirectSound, PulseAudio and OpenAL drivers. If the platform supports more than one of those audio drivers, the application can give its preference with :data:`pyglet.options` ``audio`` keyword. See the Programming guide, section :doc:`/programming_guide/media`. Returns: AbstractAudioDriver : The concrete implementation of the preferred audio driver for this platform. """ global _audio_driver if _audio_driver: return _audio_driver _audio_driver = None for driver_name in pyglet.options['audio']: try: if driver_name == 'pulse': from . import pulse _audio_driver = pulse.create_audio_driver() break elif driver_name == 'openal': from . import openal _audio_driver = openal.create_audio_driver() break elif driver_name == 'directsound': from . import directsound _audio_driver = directsound.create_audio_driver() break elif driver_name == 'silent': from . import silent _audio_driver = silent.create_audio_driver() break except Exception: if _debug: print('Error importing driver %s:' % driver_name) import traceback traceback.print_exc() return _audio_driver