pyglet 2.1.12__py3-none-any.whl → 3.0.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyglet/__init__.py +67 -61
- pyglet/__init__.pyi +15 -8
- pyglet/app/__init__.py +22 -13
- pyglet/app/async_app.py +212 -0
- pyglet/app/base.py +2 -1
- pyglet/app/{xlib.py → linux.py} +3 -3
- pyglet/config/__init__.py +101 -0
- pyglet/config/gl/__init__.py +30 -0
- pyglet/config/gl/egl.py +120 -0
- pyglet/config/gl/macos.py +262 -0
- pyglet/config/gl/windows.py +267 -0
- pyglet/config/gl/x11.py +142 -0
- pyglet/customtypes.py +43 -2
- pyglet/display/__init__.py +8 -6
- pyglet/display/base.py +3 -63
- pyglet/display/cocoa.py +12 -17
- pyglet/display/emscripten.py +39 -0
- pyglet/display/headless.py +23 -30
- pyglet/display/wayland.py +157 -0
- pyglet/display/win32.py +4 -17
- pyglet/display/xlib.py +19 -27
- pyglet/display/xlib_vidmoderestore.py +2 -2
- pyglet/enums.py +183 -0
- pyglet/event.py +0 -1
- pyglet/experimental/geoshader_sprite.py +15 -13
- pyglet/experimental/hidraw.py +6 -15
- pyglet/experimental/multitexture_sprite.py +31 -19
- pyglet/experimental/particles.py +13 -35
- pyglet/font/__init__.py +251 -85
- pyglet/font/base.py +116 -61
- pyglet/font/dwrite/__init__.py +349 -204
- pyglet/font/dwrite/dwrite_lib.py +27 -5
- pyglet/font/fontconfig.py +14 -6
- pyglet/font/freetype.py +138 -87
- pyglet/font/freetype_lib.py +19 -0
- pyglet/font/group.py +179 -0
- pyglet/font/harfbuzz/__init__.py +3 -3
- pyglet/font/pyodide_js.py +310 -0
- pyglet/font/quartz.py +319 -126
- pyglet/font/ttf.py +45 -3
- pyglet/font/user.py +14 -19
- pyglet/font/win32.py +45 -21
- pyglet/graphics/__init__.py +8 -787
- pyglet/graphics/allocation.py +115 -1
- pyglet/graphics/api/__init__.py +77 -0
- pyglet/graphics/api/base.py +299 -0
- pyglet/graphics/api/gl/__init__.py +58 -0
- pyglet/graphics/api/gl/base.py +24 -0
- pyglet/graphics/{vertexbuffer.py → api/gl/buffer.py} +104 -159
- pyglet/graphics/api/gl/cocoa/context.py +76 -0
- pyglet/graphics/api/gl/context.py +391 -0
- pyglet/graphics/api/gl/default_shaders.py +0 -0
- pyglet/graphics/api/gl/draw.py +627 -0
- pyglet/graphics/api/gl/egl/__init__.py +0 -0
- pyglet/graphics/api/gl/egl/context.py +92 -0
- pyglet/graphics/api/gl/enums.py +76 -0
- pyglet/graphics/api/gl/framebuffer.py +315 -0
- pyglet/graphics/api/gl/gl.py +5463 -0
- pyglet/graphics/api/gl/gl_info.py +188 -0
- pyglet/graphics/api/gl/global_opengl.py +226 -0
- pyglet/{gl → graphics/api/gl}/lib.py +34 -18
- pyglet/graphics/api/gl/shader.py +1476 -0
- pyglet/graphics/api/gl/shapes.py +55 -0
- pyglet/graphics/api/gl/sprite.py +102 -0
- pyglet/graphics/api/gl/state.py +219 -0
- pyglet/graphics/api/gl/text.py +190 -0
- pyglet/graphics/api/gl/texture.py +1526 -0
- pyglet/graphics/{vertexarray.py → api/gl/vertexarray.py} +11 -13
- pyglet/graphics/api/gl/vertexdomain.py +751 -0
- pyglet/graphics/api/gl/win32/__init__.py +0 -0
- pyglet/graphics/api/gl/win32/context.py +108 -0
- pyglet/graphics/api/gl/win32/wgl_info.py +24 -0
- pyglet/graphics/api/gl/xlib/__init__.py +0 -0
- pyglet/graphics/api/gl/xlib/context.py +174 -0
- pyglet/{gl → graphics/api/gl/xlib}/glx_info.py +26 -31
- pyglet/graphics/api/gl1/__init__.py +0 -0
- pyglet/{gl → graphics/api/gl1}/gl_compat.py +3 -2
- pyglet/graphics/api/gl2/__init__.py +0 -0
- pyglet/graphics/api/gl2/buffer.py +320 -0
- pyglet/graphics/api/gl2/draw.py +600 -0
- pyglet/graphics/api/gl2/global_opengl.py +122 -0
- pyglet/graphics/api/gl2/shader.py +200 -0
- pyglet/graphics/api/gl2/shapes.py +51 -0
- pyglet/graphics/api/gl2/sprite.py +79 -0
- pyglet/graphics/api/gl2/text.py +175 -0
- pyglet/graphics/api/gl2/vertexdomain.py +364 -0
- pyglet/graphics/api/webgl/__init__.py +233 -0
- pyglet/graphics/api/webgl/buffer.py +302 -0
- pyglet/graphics/api/webgl/context.py +234 -0
- pyglet/graphics/api/webgl/draw.py +590 -0
- pyglet/graphics/api/webgl/enums.py +76 -0
- pyglet/graphics/api/webgl/framebuffer.py +360 -0
- pyglet/graphics/api/webgl/gl.py +1537 -0
- pyglet/graphics/api/webgl/gl_info.py +130 -0
- pyglet/graphics/api/webgl/shader.py +1346 -0
- pyglet/graphics/api/webgl/shapes.py +92 -0
- pyglet/graphics/api/webgl/sprite.py +102 -0
- pyglet/graphics/api/webgl/state.py +227 -0
- pyglet/graphics/api/webgl/text.py +187 -0
- pyglet/graphics/api/webgl/texture.py +1227 -0
- pyglet/graphics/api/webgl/vertexarray.py +54 -0
- pyglet/graphics/api/webgl/vertexdomain.py +616 -0
- pyglet/graphics/api/webgl/webgl_js.pyi +307 -0
- pyglet/{image → graphics}/atlas.py +33 -32
- pyglet/graphics/base.py +10 -0
- pyglet/graphics/buffer.py +245 -0
- pyglet/graphics/draw.py +578 -0
- pyglet/graphics/framebuffer.py +26 -0
- pyglet/graphics/instance.py +178 -69
- pyglet/graphics/shader.py +267 -1553
- pyglet/graphics/state.py +83 -0
- pyglet/graphics/texture.py +703 -0
- pyglet/graphics/vertexdomain.py +695 -538
- pyglet/gui/ninepatch.py +10 -10
- pyglet/gui/widgets.py +120 -10
- pyglet/image/__init__.py +20 -1973
- pyglet/image/animation.py +12 -12
- pyglet/image/base.py +730 -0
- pyglet/image/codecs/__init__.py +9 -0
- pyglet/image/codecs/bmp.py +53 -30
- pyglet/image/codecs/dds.py +53 -31
- pyglet/image/codecs/gdiplus.py +38 -14
- pyglet/image/codecs/gdkpixbuf2.py +0 -2
- pyglet/image/codecs/js_image.py +99 -0
- pyglet/image/codecs/ktx2.py +161 -0
- pyglet/image/codecs/pil.py +1 -1
- pyglet/image/codecs/png.py +1 -1
- pyglet/image/codecs/wic.py +11 -2
- pyglet/info.py +26 -24
- pyglet/input/__init__.py +8 -0
- pyglet/input/base.py +163 -105
- pyglet/input/controller.py +13 -19
- pyglet/input/controller_db.py +39 -24
- pyglet/input/emscripten/__init__.py +18 -0
- pyglet/input/emscripten/gamepad_js.py +397 -0
- pyglet/input/linux/__init__.py +11 -5
- pyglet/input/linux/evdev.py +10 -11
- pyglet/input/linux/x11_xinput.py +2 -2
- pyglet/input/linux/x11_xinput_tablet.py +1 -1
- pyglet/input/macos/__init__.py +7 -2
- pyglet/input/macos/darwin_gc.py +559 -0
- pyglet/input/win32/__init__.py +1 -1
- pyglet/input/win32/directinput.py +34 -29
- pyglet/input/win32/xinput.py +11 -61
- pyglet/lib.py +3 -3
- pyglet/libs/__init__.py +1 -1
- pyglet/{gl → libs/darwin}/agl.py +1 -1
- pyglet/libs/darwin/cocoapy/__init__.py +2 -2
- pyglet/libs/darwin/cocoapy/cocoahelpers.py +181 -0
- pyglet/libs/darwin/cocoapy/cocoalibs.py +31 -0
- pyglet/libs/darwin/cocoapy/cocoatypes.py +27 -0
- pyglet/libs/darwin/cocoapy/runtime.py +81 -45
- pyglet/libs/darwin/coreaudio.py +4 -4
- pyglet/{gl → libs/darwin}/lib_agl.py +9 -8
- pyglet/libs/darwin/quartzkey.py +1 -3
- pyglet/libs/egl/__init__.py +2 -0
- pyglet/libs/egl/egl_lib.py +576 -0
- pyglet/libs/egl/eglext.py +51 -5
- pyglet/libs/linux/__init__.py +0 -0
- pyglet/libs/linux/egl/__init__.py +0 -0
- pyglet/libs/linux/egl/eglext.py +22 -0
- pyglet/libs/linux/glx/__init__.py +0 -0
- pyglet/{gl → libs/linux/glx}/glx.py +13 -14
- pyglet/{gl → libs/linux/glx}/glxext_arb.py +408 -192
- pyglet/{gl → libs/linux/glx}/glxext_mesa.py +1 -1
- pyglet/{gl → libs/linux/glx}/glxext_nv.py +345 -164
- pyglet/{gl → libs/linux/glx}/lib_glx.py +3 -2
- pyglet/libs/linux/wayland/__init__.py +0 -0
- pyglet/libs/linux/wayland/client.py +1068 -0
- pyglet/libs/linux/wayland/lib_wayland.py +207 -0
- pyglet/libs/linux/wayland/wayland_egl.py +38 -0
- pyglet/libs/{wayland → linux/wayland}/xkbcommon.py +26 -0
- pyglet/libs/{x11 → linux/x11}/xf86vmode.py +4 -4
- pyglet/libs/{x11 → linux/x11}/xinerama.py +2 -2
- pyglet/libs/{x11 → linux/x11}/xinput.py +10 -10
- pyglet/libs/linux/x11/xrandr.py +0 -0
- pyglet/libs/{x11 → linux/x11}/xrender.py +1 -1
- pyglet/libs/shared/__init__.py +0 -0
- pyglet/libs/shared/spirv/__init__.py +0 -0
- pyglet/libs/shared/spirv/lib_shaderc.py +85 -0
- pyglet/libs/shared/spirv/lib_spirv_cross.py +126 -0
- pyglet/libs/win32/__init__.py +27 -5
- pyglet/libs/win32/constants.py +59 -48
- pyglet/libs/win32/context_managers.py +20 -3
- pyglet/libs/win32/dinput.py +105 -88
- pyglet/{gl → libs/win32}/lib_wgl.py +52 -26
- pyglet/libs/win32/types.py +58 -23
- pyglet/{gl → libs/win32}/wgl.py +32 -25
- pyglet/{gl → libs/win32}/wglext_arb.py +364 -2
- pyglet/media/__init__.py +9 -10
- pyglet/media/codecs/__init__.py +12 -1
- pyglet/media/codecs/base.py +99 -96
- pyglet/media/codecs/ffmpeg.py +2 -2
- pyglet/media/codecs/ffmpeg_lib/libavformat.py +3 -8
- pyglet/media/codecs/webaudio_pyodide.py +111 -0
- pyglet/media/drivers/__init__.py +9 -4
- pyglet/media/drivers/base.py +4 -4
- pyglet/media/drivers/openal/__init__.py +1 -1
- pyglet/media/drivers/openal/adaptation.py +3 -3
- pyglet/media/drivers/pulse/__init__.py +1 -1
- pyglet/media/drivers/pulse/adaptation.py +3 -3
- pyglet/media/drivers/pyodide_js/__init__.py +8 -0
- pyglet/media/drivers/pyodide_js/adaptation.py +288 -0
- pyglet/media/drivers/xaudio2/adaptation.py +3 -3
- pyglet/media/player.py +276 -193
- pyglet/media/player_worker_thread.py +1 -1
- pyglet/model/__init__.py +39 -29
- pyglet/model/codecs/base.py +4 -4
- pyglet/model/codecs/gltf.py +3 -3
- pyglet/model/codecs/obj.py +71 -43
- pyglet/resource.py +129 -78
- pyglet/shapes.py +147 -177
- pyglet/sprite.py +47 -164
- pyglet/text/__init__.py +44 -54
- pyglet/text/caret.py +12 -7
- pyglet/text/document.py +19 -17
- pyglet/text/formats/html.py +2 -2
- pyglet/text/formats/structured.py +10 -40
- pyglet/text/layout/__init__.py +20 -13
- pyglet/text/layout/base.py +176 -287
- pyglet/text/layout/incremental.py +9 -10
- pyglet/text/layout/scrolling.py +7 -95
- pyglet/window/__init__.py +183 -172
- pyglet/window/cocoa/__init__.py +62 -51
- pyglet/window/cocoa/pyglet_delegate.py +2 -25
- pyglet/window/cocoa/pyglet_view.py +9 -8
- pyglet/window/dialog/__init__.py +184 -0
- pyglet/window/dialog/base.py +99 -0
- pyglet/window/dialog/darwin.py +121 -0
- pyglet/window/dialog/linux.py +72 -0
- pyglet/window/dialog/windows.py +194 -0
- pyglet/window/emscripten/__init__.py +779 -0
- pyglet/window/headless/__init__.py +44 -28
- pyglet/window/key.py +2 -0
- pyglet/window/mouse.py +2 -2
- pyglet/window/wayland/__init__.py +377 -0
- pyglet/window/win32/__init__.py +101 -46
- pyglet/window/xlib/__init__.py +104 -66
- {pyglet-2.1.12.dist-info → pyglet-3.0.dev1.dist-info}/METADATA +2 -3
- pyglet-3.0.dev1.dist-info/RECORD +322 -0
- {pyglet-2.1.12.dist-info → pyglet-3.0.dev1.dist-info}/WHEEL +1 -1
- pyglet/gl/__init__.py +0 -208
- pyglet/gl/base.py +0 -499
- pyglet/gl/cocoa.py +0 -309
- pyglet/gl/gl.py +0 -4625
- pyglet/gl/gl.pyi +0 -2320
- pyglet/gl/gl_compat.pyi +0 -3097
- pyglet/gl/gl_info.py +0 -190
- pyglet/gl/headless.py +0 -166
- pyglet/gl/wgl_info.py +0 -36
- pyglet/gl/wglext_nv.py +0 -1096
- pyglet/gl/win32.py +0 -268
- pyglet/gl/xlib.py +0 -295
- pyglet/image/buffer.py +0 -274
- pyglet/image/codecs/s3tc.py +0 -354
- pyglet/libs/x11/xrandr.py +0 -166
- pyglet-2.1.12.dist-info/RECORD +0 -234
- /pyglet/{libs/wayland → graphics/api/gl/cocoa}/__init__.py +0 -0
- /pyglet/libs/{egl → linux/egl}/egl.py +0 -0
- /pyglet/libs/{egl → linux/egl}/lib.py +0 -0
- /pyglet/libs/{ioctl.py → linux/ioctl.py} +0 -0
- /pyglet/libs/{wayland → linux/wayland}/gbm.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/__init__.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/cursorfont.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xlib.py +0 -0
- /pyglet/libs/{x11 → linux/x11}/xsync.py +0 -0
- {pyglet-2.1.12.dist-info/licenses → pyglet-3.0.dev1.dist-info}/LICENSE +0 -0
pyglet/display/headless.py
CHANGED
|
@@ -2,15 +2,16 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Literal
|
|
4
4
|
|
|
5
|
-
import pyglet
|
|
6
5
|
import warnings
|
|
6
|
+
from ctypes import byref
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import pyglet
|
|
9
9
|
|
|
10
|
+
from .base import Display, Screen
|
|
11
|
+
from pyglet.libs import egl
|
|
12
|
+
from pyglet.util import debug_print
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
from pyglet.libs.egl import egl
|
|
13
|
-
from pyglet.libs.egl import eglext
|
|
14
|
+
_debug = debug_print('debug_api')
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class HeadlessDisplay(Display):
|
|
@@ -21,21 +22,27 @@ class HeadlessDisplay(Display):
|
|
|
21
22
|
self._screens = [HeadlessScreen(self, 0, 0, 1920, 1080)]
|
|
22
23
|
|
|
23
24
|
num_devices = egl.EGLint()
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if headless_device < 0 or headless_device >= num_devices.value:
|
|
28
|
-
raise ValueError(f'Invalid EGL device id: {headless_device}')
|
|
29
|
-
devices = (eglext.EGLDeviceEXT * num_devices.value)()
|
|
30
|
-
eglext.eglQueryDevicesEXT(num_devices.value, devices, byref(num_devices))
|
|
31
|
-
self._display_connection = eglext.eglGetPlatformDisplayEXT(
|
|
32
|
-
eglext.EGL_PLATFORM_DEVICE_EXT, devices[headless_device], None)
|
|
33
|
-
else:
|
|
25
|
+
try:
|
|
26
|
+
egl.eglQueryDevicesEXT(0, None, byref(num_devices))
|
|
27
|
+
except pyglet.libs.egl.eglext.MissingFunctionException:
|
|
34
28
|
warnings.warn('No device available for EGL device platform. Using native display type.')
|
|
35
29
|
display = egl.EGLNativeDisplayType()
|
|
36
30
|
self._display_connection = egl.eglGetDisplay(display)
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
if num_devices.value > 0:
|
|
33
|
+
headless_device = pyglet.options.headless_device
|
|
34
|
+
if headless_device < 0 or headless_device >= num_devices.value:
|
|
35
|
+
raise ValueError(f'Invalid EGL device id: {headless_device}')
|
|
36
|
+
devices = (egl.EGLDeviceEXT * num_devices.value)()
|
|
37
|
+
egl.eglQueryDevicesEXT(num_devices.value, devices, byref(num_devices))
|
|
38
|
+
self._display_connection = egl.eglGetPlatformDisplayEXT(
|
|
39
|
+
egl.EGL_PLATFORM_DEVICE_EXT, devices[headless_device], None,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
majorver = egl.EGLint()
|
|
43
|
+
minorver = egl.EGLint()
|
|
44
|
+
egl.eglInitialize(self._display_connection, majorver, minorver)
|
|
45
|
+
assert _debug(f"EGL version: {majorver.value}.{minorver.value}")
|
|
39
46
|
|
|
40
47
|
def get_screens(self):
|
|
41
48
|
return self._screens
|
|
@@ -44,24 +51,10 @@ class HeadlessDisplay(Display):
|
|
|
44
51
|
egl.eglTerminate(self._display_connection)
|
|
45
52
|
|
|
46
53
|
|
|
47
|
-
class HeadlessCanvas(Canvas):
|
|
48
|
-
def __init__(self, display, egl_surface):
|
|
49
|
-
super().__init__(display)
|
|
50
|
-
self.egl_surface = egl_surface
|
|
51
|
-
|
|
52
|
-
|
|
53
54
|
class HeadlessScreen(Screen):
|
|
54
55
|
def __init__(self, display, x, y, width, height):
|
|
55
56
|
super().__init__(display, x, y, width, height)
|
|
56
57
|
|
|
57
|
-
def get_matching_configs(self, template):
|
|
58
|
-
canvas = HeadlessCanvas(self.display, None)
|
|
59
|
-
configs = template.match(canvas)
|
|
60
|
-
# XXX deprecate
|
|
61
|
-
for config in configs:
|
|
62
|
-
config.screen = self
|
|
63
|
-
return configs
|
|
64
|
-
|
|
65
58
|
def get_modes(self):
|
|
66
59
|
pass
|
|
67
60
|
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections import namedtuple
|
|
4
|
+
from threading import Event
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
from pyglet.libs.linux.egl import egl, eglext
|
|
8
|
+
from pyglet.libs.linux.wayland.client import Client
|
|
9
|
+
|
|
10
|
+
from .base import Display, Screen, ScreenMode
|
|
11
|
+
|
|
12
|
+
ModeInfo = namedtuple('ModeInfo', 'width, height, depth, rate, current, primary')
|
|
13
|
+
Geometry = namedtuple('Geometry', 'x, y, physical_width, physical_height, make, model, transform')
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class WaylandScreenMode(ScreenMode):
|
|
17
|
+
def __init__(self, screen: Screen, info: ModeInfo):
|
|
18
|
+
self.width = info.width
|
|
19
|
+
self.height = info.height
|
|
20
|
+
self.depth = info.depth
|
|
21
|
+
self.rate = info.rate
|
|
22
|
+
self.primary = info.primary
|
|
23
|
+
self.current = info.current
|
|
24
|
+
super().__init__(screen)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class WaylandDisplay(Display):
|
|
28
|
+
_protocols = ('/usr/share/wayland/wayland.xml', '/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml')
|
|
29
|
+
_display_instance: WaylandDisplay | None = None
|
|
30
|
+
|
|
31
|
+
def __new__(cls):
|
|
32
|
+
if cls._display_instance:
|
|
33
|
+
return cls._display_instance
|
|
34
|
+
cls._display_instance = super().__new__(cls)
|
|
35
|
+
return cls._display_instance
|
|
36
|
+
|
|
37
|
+
def __init__(self):
|
|
38
|
+
super().__init__()
|
|
39
|
+
# Create temporary Client connection to query Screen information:
|
|
40
|
+
# TODO: use the new fractional scaling Protocol if available.
|
|
41
|
+
self.client = Client(*self._protocols)
|
|
42
|
+
self.client.sync()
|
|
43
|
+
|
|
44
|
+
self.display_connection = egl.eglGetPlatformDisplay(eglext.EGL_PLATFORM_WAYLAND, self.client.wl_display_p, None)
|
|
45
|
+
|
|
46
|
+
assert egl.eglInitialize(self.display_connection, None, None) == egl.EGL_TRUE, "Failed to initialize Display"
|
|
47
|
+
|
|
48
|
+
self._screens = []
|
|
49
|
+
for i, _ in enumerate(self.client.globals.get('wl_output', [])):
|
|
50
|
+
# Initialize values to default
|
|
51
|
+
self._geo = None
|
|
52
|
+
self._modes = []
|
|
53
|
+
self._scale = None
|
|
54
|
+
self._name = None
|
|
55
|
+
self._descript = None
|
|
56
|
+
self._query_done = Event()
|
|
57
|
+
wl_output = self.client.protocol_dict['wayland'].bind_interface('wl_output', index=i)
|
|
58
|
+
self._mode_enum = wl_output.enums['mode']
|
|
59
|
+
self._transform_enum = wl_output.enums['transform']
|
|
60
|
+
# Callbacks will update values:
|
|
61
|
+
wl_output.set_handlers(
|
|
62
|
+
geometry=self._wl_output_geometry_handler,
|
|
63
|
+
mode=self._wl_output_mode_handler,
|
|
64
|
+
scale=self._wl_output_scale_handler,
|
|
65
|
+
name=self._wl_output_name_handler,
|
|
66
|
+
description=self._wl_output_description_handler,
|
|
67
|
+
done=self._wl_output_done_handler,
|
|
68
|
+
)
|
|
69
|
+
self.client.sync()
|
|
70
|
+
self._query_done.wait()
|
|
71
|
+
# Make Screen instance with the now-filled-in values:
|
|
72
|
+
self._screens.append(WaylandScreen(self, self._geo, self._modes, self._scale, self._name, self._descript))
|
|
73
|
+
wl_output.release()
|
|
74
|
+
|
|
75
|
+
# Start Wayland Event handlers
|
|
76
|
+
|
|
77
|
+
def _wl_output_done_handler(self):
|
|
78
|
+
self._query_done.set()
|
|
79
|
+
|
|
80
|
+
def _wl_output_scale_handler(self, scale):
|
|
81
|
+
self._scale = scale
|
|
82
|
+
|
|
83
|
+
def _wl_output_name_handler(self, name):
|
|
84
|
+
self._name = name
|
|
85
|
+
|
|
86
|
+
def _wl_output_description_handler(self, description):
|
|
87
|
+
self._descript = description
|
|
88
|
+
|
|
89
|
+
def _wl_output_geometry_handler(self, x, y, physical_width, physical_height, subpixel, make, model, transform):
|
|
90
|
+
transform = self._transform_enum[transform]
|
|
91
|
+
self._geo = Geometry(x, y, physical_width, physical_height, make, model, transform)
|
|
92
|
+
|
|
93
|
+
def _wl_output_mode_handler(self, flags, width, height, refresh):
|
|
94
|
+
is_current = self._mode_enum.entries[0] & flags
|
|
95
|
+
is_primary = self._mode_enum.entries[1] & flags
|
|
96
|
+
self._modes.append(ModeInfo(width, height, None, refresh * 0.001, is_current, is_primary))
|
|
97
|
+
|
|
98
|
+
# End Wayland Event handlers
|
|
99
|
+
|
|
100
|
+
def get_screens(self):
|
|
101
|
+
return self._screens
|
|
102
|
+
|
|
103
|
+
def __del__(self):
|
|
104
|
+
egl.eglTerminate(self.display_connection)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class WaylandScreen(Screen):
|
|
108
|
+
|
|
109
|
+
def get_display_id(self) -> str | int:
|
|
110
|
+
return self.name
|
|
111
|
+
|
|
112
|
+
def get_monitor_name(self) -> str | Literal["Unknown"]:
|
|
113
|
+
return self.description
|
|
114
|
+
|
|
115
|
+
def __init__(self, display, geometry, modes, scale, name, description):
|
|
116
|
+
self.name = name
|
|
117
|
+
self.description = description
|
|
118
|
+
self._scale = scale
|
|
119
|
+
self._geo = geometry
|
|
120
|
+
self._modes = modes
|
|
121
|
+
_width_pixels = max(mode.width for mode in self._modes)
|
|
122
|
+
_height_pixels = max(mode.height for mode in self._modes)
|
|
123
|
+
# No physical size can exist, such as WSL (they are virtual).
|
|
124
|
+
if self._geo.physical_width != 0:
|
|
125
|
+
_width_inches = self._geo.physical_width / 25.4
|
|
126
|
+
_height_inches = self._geo.physical_height / 25.4
|
|
127
|
+
_dpi_width = _width_pixels / _width_inches
|
|
128
|
+
_dpi_height = _height_pixels / _height_inches
|
|
129
|
+
self._dpi = (_dpi_width + _dpi_height) / 2
|
|
130
|
+
else:
|
|
131
|
+
self._dpi = scale
|
|
132
|
+
|
|
133
|
+
super().__init__(display, self._geo.x, self._geo.y, _width_pixels, _height_pixels)
|
|
134
|
+
|
|
135
|
+
def get_modes(self):
|
|
136
|
+
return self._modes
|
|
137
|
+
|
|
138
|
+
def get_mode(self):
|
|
139
|
+
for mode in self._modes:
|
|
140
|
+
if mode.current:
|
|
141
|
+
return mode
|
|
142
|
+
return self._modes[0]
|
|
143
|
+
|
|
144
|
+
def set_mode(self, mode):
|
|
145
|
+
pass
|
|
146
|
+
|
|
147
|
+
def restore_mode(self):
|
|
148
|
+
pass
|
|
149
|
+
|
|
150
|
+
def get_dpi(self):
|
|
151
|
+
return self._dpi
|
|
152
|
+
|
|
153
|
+
def get_scale(self):
|
|
154
|
+
return self._scale
|
|
155
|
+
|
|
156
|
+
def __repr__(self) -> str:
|
|
157
|
+
return f"{self.__class__.__name__}(x={self.x}, y={self.y}, width={self.width}, height={self.height})"
|
pyglet/display/win32.py
CHANGED
|
@@ -20,7 +20,6 @@ from pyglet.libs.win32.constants import (
|
|
|
20
20
|
WINDOWS_10_CREATORS_UPDATE_OR_GREATER,
|
|
21
21
|
WINDOWS_VISTA_OR_GREATER,
|
|
22
22
|
)
|
|
23
|
-
from pyglet.libs.win32.context_managers import device_context
|
|
24
23
|
from pyglet.libs.win32.types import (
|
|
25
24
|
DEVMODE,
|
|
26
25
|
DISPLAY_DEVICEW,
|
|
@@ -35,7 +34,7 @@ from pyglet.libs.win32.types import (
|
|
|
35
34
|
UINT32,
|
|
36
35
|
)
|
|
37
36
|
|
|
38
|
-
from .base import
|
|
37
|
+
from .base import Display, Screen, ScreenMode
|
|
39
38
|
|
|
40
39
|
if TYPE_CHECKING:
|
|
41
40
|
from ctypes.wintypes import HDC, HMONITOR, LPARAM, LPRECT
|
|
@@ -165,16 +164,6 @@ class Win32Screen(Screen): # noqa: D101
|
|
|
165
164
|
|
|
166
165
|
return "Unknown"
|
|
167
166
|
|
|
168
|
-
def get_matching_configs(self, template):
|
|
169
|
-
with device_context(None) as hdc:
|
|
170
|
-
canvas = Win32Canvas(self.display, 0, hdc)
|
|
171
|
-
configs = template.match(canvas)
|
|
172
|
-
# XXX deprecate config's being screen-specific
|
|
173
|
-
for config in configs:
|
|
174
|
-
config.screen = self
|
|
175
|
-
|
|
176
|
-
return configs
|
|
177
|
-
|
|
178
167
|
def _get_monitor_info(self) -> MONITORINFOEX:
|
|
179
168
|
info = MONITORINFOEX()
|
|
180
169
|
info.cbSize = sizeof(MONITORINFOEX)
|
|
@@ -257,6 +246,8 @@ _win32_scale_name = {
|
|
|
257
246
|
1: "center",
|
|
258
247
|
2: "stretch",
|
|
259
248
|
}
|
|
249
|
+
|
|
250
|
+
|
|
260
251
|
class Win32ScreenMode(ScreenMode): # noqa: D101
|
|
261
252
|
def __init__(self, screen: Win32Screen, mode: DEVMODE) -> None: # noqa: D107
|
|
262
253
|
super().__init__(screen)
|
|
@@ -271,8 +262,4 @@ class Win32ScreenMode(ScreenMode): # noqa: D101
|
|
|
271
262
|
return (f'{self.__class__.__name__}(width={self.width!r}, height={self.height!r}, depth={self.depth!r},'
|
|
272
263
|
f'rate={self.rate}, scaling={_win32_scale_name.get(self.scaling)})')
|
|
273
264
|
|
|
274
|
-
|
|
275
|
-
def __init__(self, display: Win32Display, hwnd: HWND, hdc: HDC) -> None: # noqa: D107
|
|
276
|
-
super().__init__(display)
|
|
277
|
-
self.hwnd = hwnd
|
|
278
|
-
self.hdc = hdc
|
|
265
|
+
|
pyglet/display/xlib.py
CHANGED
|
@@ -2,37 +2,45 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import ctypes
|
|
4
4
|
import warnings
|
|
5
|
-
from ctypes import POINTER, byref, c_buffer, c_char_p, c_int, cast
|
|
6
5
|
from typing import TYPE_CHECKING
|
|
6
|
+
from ctypes import POINTER, byref, c_buffer, c_char_p, c_int, cast
|
|
7
7
|
|
|
8
8
|
import pyglet
|
|
9
|
+
|
|
9
10
|
from pyglet import app
|
|
10
|
-
from pyglet.app.
|
|
11
|
-
from pyglet.libs.x11 import xlib
|
|
11
|
+
from pyglet.app.linux import LinuxSelectDevice
|
|
12
12
|
from pyglet.util import asbytes
|
|
13
13
|
|
|
14
14
|
from . import xlib_vidmoderestore
|
|
15
|
-
from .base import
|
|
15
|
+
from .base import Display, Screen, ScreenMode
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# XXX
|
|
19
|
+
# from pyglet.window import NoSuchDisplayException
|
|
20
|
+
class NoSuchDisplayException(Exception):
|
|
21
|
+
pass
|
|
16
22
|
|
|
23
|
+
|
|
24
|
+
from pyglet.libs.linux.x11 import xlib
|
|
17
25
|
if TYPE_CHECKING:
|
|
18
26
|
from pyglet.gl import Config
|
|
19
27
|
|
|
20
28
|
try:
|
|
21
|
-
from pyglet.libs.x11 import xinerama
|
|
29
|
+
from pyglet.libs.linux.x11 import xinerama
|
|
22
30
|
|
|
23
31
|
_have_xinerama = True
|
|
24
32
|
except:
|
|
25
33
|
_have_xinerama = False
|
|
26
34
|
|
|
27
35
|
try:
|
|
28
|
-
from pyglet.libs.x11 import xsync
|
|
36
|
+
from pyglet.libs.linux.x11 import xsync
|
|
29
37
|
|
|
30
38
|
_have_xsync = True
|
|
31
39
|
except:
|
|
32
40
|
_have_xsync = False
|
|
33
41
|
|
|
34
42
|
try:
|
|
35
|
-
from pyglet.libs.x11 import xf86vmode
|
|
43
|
+
from pyglet.libs.linux.x11 import xf86vmode
|
|
36
44
|
|
|
37
45
|
_have_xf86vmode = True
|
|
38
46
|
except:
|
|
@@ -59,7 +67,7 @@ def _error_handler(display, event):
|
|
|
59
67
|
# driver bugs (and so the reports are useless). Nevertheless, set
|
|
60
68
|
# environment variable PYGLET_DEBUG_X11 to 1 to get dumps of the error
|
|
61
69
|
# and a traceback (execution will continue).
|
|
62
|
-
if pyglet.options
|
|
70
|
+
if pyglet.options.debug_x11:
|
|
63
71
|
event = event.contents
|
|
64
72
|
buf = c_buffer(1024)
|
|
65
73
|
xlib.XGetErrorText(display, event.error_code, buf, len(buf))
|
|
@@ -80,7 +88,7 @@ _error_handler_ptr = xlib.XErrorHandler(_error_handler)
|
|
|
80
88
|
xlib.XSetErrorHandler(_error_handler_ptr)
|
|
81
89
|
|
|
82
90
|
|
|
83
|
-
class XlibDisplay(
|
|
91
|
+
class XlibDisplay(LinuxSelectDevice, Display):
|
|
84
92
|
_display = None # POINTER(xlib.Display)
|
|
85
93
|
|
|
86
94
|
_x_im = None # X input method
|
|
@@ -199,7 +207,7 @@ class XlibDisplay(XlibSelectDevice, Display):
|
|
|
199
207
|
self._screens = [screen]
|
|
200
208
|
return self._screens
|
|
201
209
|
|
|
202
|
-
#
|
|
210
|
+
# LinuxSelectDevice interface
|
|
203
211
|
|
|
204
212
|
def fileno(self) -> int:
|
|
205
213
|
return self._fileno
|
|
@@ -252,15 +260,7 @@ class XlibScreen(Screen):
|
|
|
252
260
|
def get_scale(self) -> float:
|
|
253
261
|
return self.get_dpi() / 96
|
|
254
262
|
|
|
255
|
-
def
|
|
256
|
-
canvas = XlibCanvas(self.display, None)
|
|
257
|
-
configs = template.match(canvas)
|
|
258
|
-
# XXX deprecate
|
|
259
|
-
for config in configs:
|
|
260
|
-
config.screen = self
|
|
261
|
-
return configs
|
|
262
|
-
|
|
263
|
-
def get_modes(self) -> list[XlibScreenModeXF86]:
|
|
263
|
+
def get_modes(self):
|
|
264
264
|
if not _have_xf86vmode:
|
|
265
265
|
return []
|
|
266
266
|
|
|
@@ -493,11 +493,3 @@ class XlibScreenModeXrandr(XlibScreenMode):
|
|
|
493
493
|
|
|
494
494
|
def __repr__(self) -> str:
|
|
495
495
|
return f'XlibScreenMode(width={self.width!r}, height={self.height!r}, depth={self.depth!r}, rate={self.rate})'
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
class XlibCanvas(Canvas): # noqa: D101
|
|
499
|
-
display: XlibDisplay
|
|
500
|
-
|
|
501
|
-
def __init__(self, display: XlibDisplay, x_window: xlib.Window) -> None: # noqa: D107
|
|
502
|
-
super().__init__(display)
|
|
503
|
-
self.x_window = x_window
|
|
@@ -16,11 +16,11 @@ import signal
|
|
|
16
16
|
import struct
|
|
17
17
|
import threading
|
|
18
18
|
|
|
19
|
-
from pyglet.libs.x11 import xlib
|
|
19
|
+
from pyglet.libs.linux.x11 import xlib
|
|
20
20
|
from pyglet.util import asbytes
|
|
21
21
|
|
|
22
22
|
try:
|
|
23
|
-
from pyglet.libs.x11 import xf86vmode
|
|
23
|
+
from pyglet.libs.linux.x11 import xf86vmode
|
|
24
24
|
except:
|
|
25
25
|
# No xf86vmode... should not be switching modes.
|
|
26
26
|
pass
|
pyglet/enums.py
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from enum import Enum, auto
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class GraphicsAPI(Enum):
|
|
6
|
+
OPENGL = auto()
|
|
7
|
+
OPENGL_2 = auto()
|
|
8
|
+
OPENGL_ES_2 = auto()
|
|
9
|
+
OPENGL_ES_3 = auto()
|
|
10
|
+
WEBGL = auto()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BlendFactor(Enum):
|
|
14
|
+
ZERO = "ZERO"
|
|
15
|
+
ONE = "ONE"
|
|
16
|
+
SRC_COLOR = "SRC_COLOR"
|
|
17
|
+
ONE_MINUS_SRC_COLOR = "ONE_MINUS_SRC_COLOR"
|
|
18
|
+
DST_COLOR = "DST_COLOR"
|
|
19
|
+
ONE_MINUS_DST_COLOR = "ONE_MINUS_DST_COLOR"
|
|
20
|
+
SRC_ALPHA = "SRC_ALPHA"
|
|
21
|
+
ONE_MINUS_SRC_ALPHA = "ONE_MINUS_SRC_ALPHA"
|
|
22
|
+
DST_ALPHA = "DST_ALPHA"
|
|
23
|
+
ONE_MINUS_DST_ALPHA = "ONE_MINUS_DST_ALPHA"
|
|
24
|
+
CONSTANT_COLOR = "CONSTANT_COLOR"
|
|
25
|
+
ONE_MINUS_CONSTANT_COLOR = "ONE_MINUS_CONSTANT_COLOR"
|
|
26
|
+
CONSTANT_ALPHA = "CONSTANT_ALPHA"
|
|
27
|
+
ONE_MINUS_CONSTANT_ALPHA = "ONE_MINUS_CONSTANT_ALPHA"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class BlendOp(Enum):
|
|
31
|
+
ADD = "ADD"
|
|
32
|
+
SUBTRACT = "SUBTRACT"
|
|
33
|
+
REVERSE_SUBTRACT = "REVERSE_SUBTRACT"
|
|
34
|
+
MIN = "MIN"
|
|
35
|
+
MAX = "MAX"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class TextureFilter(Enum):
|
|
39
|
+
LINEAR = auto()
|
|
40
|
+
NEAREST = auto()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class AddressMode(Enum):
|
|
44
|
+
REPEAT = auto()
|
|
45
|
+
MIRRORED_REPEAT = auto()
|
|
46
|
+
CLAMP_TO_EDGE = auto()
|
|
47
|
+
CLAMP_TO_BORDER = auto()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class TextureWrapping(Enum):
|
|
51
|
+
WRAP_S = auto()
|
|
52
|
+
WRAP_T = auto()
|
|
53
|
+
WRAP_R = auto()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ComponentFormat(str, Enum):
|
|
57
|
+
R = 'R'
|
|
58
|
+
RG = 'RG'
|
|
59
|
+
RGB = 'RGB'
|
|
60
|
+
RGBA = 'RGBA'
|
|
61
|
+
D = 'D' # Depth Component
|
|
62
|
+
DS = 'DS' # Depth Stencil
|
|
63
|
+
BGR = 'BGR'
|
|
64
|
+
BGRA = 'BGRA'
|
|
65
|
+
L = 'L' # Luminance (R) - Deprecated
|
|
66
|
+
LA = 'LA' # Luminance Alpha (LA) - Deprecated
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class TextureType(Enum):
|
|
70
|
+
TYPE_1D = auto()
|
|
71
|
+
TYPE_2D = auto()
|
|
72
|
+
TYPE_3D = auto()
|
|
73
|
+
TYPE_CUBE_MAP = auto()
|
|
74
|
+
TYPE_1D_ARRAY = auto()
|
|
75
|
+
TYPE_2D_ARRAY = auto()
|
|
76
|
+
TYPE_CUBE_MAP_ARRAY = auto()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class CompareOp(Enum):
|
|
80
|
+
NEVER = auto()
|
|
81
|
+
LESS = auto()
|
|
82
|
+
EQUAL = auto()
|
|
83
|
+
LESS_OR_EQUAL = auto()
|
|
84
|
+
GREATER = auto()
|
|
85
|
+
NOT_EQUAL = auto()
|
|
86
|
+
GREATER_OR_EQUAL = auto()
|
|
87
|
+
ALWAYS = auto()
|
|
88
|
+
|
|
89
|
+
class FramebufferTarget(Enum):
|
|
90
|
+
FRAMEBUFFER = auto()
|
|
91
|
+
DRAW = auto()
|
|
92
|
+
READ = auto()
|
|
93
|
+
|
|
94
|
+
class FramebufferAttachment(Enum):
|
|
95
|
+
COLOR0 = auto()
|
|
96
|
+
COLOR1 = auto()
|
|
97
|
+
COLOR2 = auto()
|
|
98
|
+
COLOR3 = auto()
|
|
99
|
+
COLOR4 = auto()
|
|
100
|
+
COLOR5 = auto()
|
|
101
|
+
COLOR6 = auto()
|
|
102
|
+
COLOR7 = auto()
|
|
103
|
+
COLOR8 = auto()
|
|
104
|
+
COLOR9 = auto()
|
|
105
|
+
COLOR10 = auto()
|
|
106
|
+
COLOR11 = auto()
|
|
107
|
+
COLOR12 = auto()
|
|
108
|
+
COLOR13 = auto()
|
|
109
|
+
COLOR14 = auto()
|
|
110
|
+
COLOR15 = auto()
|
|
111
|
+
|
|
112
|
+
DEPTH = auto()
|
|
113
|
+
STENCIL = auto()
|
|
114
|
+
DEPTH_STENCIL = auto()
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Weight(str, Enum):
|
|
119
|
+
"""An :py:class:`~enum.Enum` of known cross-platform font weight strings.
|
|
120
|
+
|
|
121
|
+
Each value is both an :py:class:`~enum.Enum` and a :py:class:`str`.
|
|
122
|
+
This is not a built-in Python :py:class:`~enum.StrEnum` to ensure
|
|
123
|
+
compatibility with Python < 3.11.
|
|
124
|
+
|
|
125
|
+
.. important:: Fonts will use the closest match if they lack a weight.
|
|
126
|
+
|
|
127
|
+
The values of this enum imitate the string names for font weights
|
|
128
|
+
as used in CSS and the OpenType specification. Numerical font weights
|
|
129
|
+
are not supported because:
|
|
130
|
+
|
|
131
|
+
* Integer font weight support and behavior varies by back-end
|
|
132
|
+
* Some font renderers do not support or round :py:class:`float` values
|
|
133
|
+
* Some font renderers lack support for variable-width fonts
|
|
134
|
+
|
|
135
|
+
Additional weight strings may be supported by certain font-rendering
|
|
136
|
+
back-ends. To learn more, please see your platform's API documentation
|
|
137
|
+
and the following:
|
|
138
|
+
|
|
139
|
+
#. `The MDN article on CSS font weights <https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight>`_
|
|
140
|
+
#. `The OpenType specification <https://learn.microsoft.com/en-us/typography/opentype/spec/os2#usweightclass>`_
|
|
141
|
+
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
THIN = 'thin'
|
|
145
|
+
EXTRALIGHT = 'extralight'
|
|
146
|
+
LIGHT = 'light'
|
|
147
|
+
NORMAL = 'normal'
|
|
148
|
+
"""The default weight for a font."""
|
|
149
|
+
MEDIUM = 'medium'
|
|
150
|
+
SEMIBOLD = 'semibold'
|
|
151
|
+
BOLD = 'bold'
|
|
152
|
+
"""The default **bold** style for a font."""
|
|
153
|
+
EXTRABOLD = 'extrabold'
|
|
154
|
+
BLACK = 'black'
|
|
155
|
+
EXTRABLACK = 'extrablack'
|
|
156
|
+
|
|
157
|
+
def __str__(self) -> str:
|
|
158
|
+
return self.value
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class Stretch(str, Enum):
|
|
162
|
+
"""The stretch or width class of the font."""
|
|
163
|
+
ULTRACONDENSED = 'ultracondensed'
|
|
164
|
+
EXTRACONDENSED = 'extracondensed'
|
|
165
|
+
CONDENSED = 'condensed'
|
|
166
|
+
SEMICONDENSED = 'semicondensed'
|
|
167
|
+
NORMAL = 'normal'
|
|
168
|
+
"""The default stretch for a font."""
|
|
169
|
+
SEMIEXPANDED = 'semiexpanded'
|
|
170
|
+
EXPANDED = 'expanded'
|
|
171
|
+
EXTRAEXPANDED = 'extraexpanded'
|
|
172
|
+
ULTRAEXPANDED = 'ultraexpanded'
|
|
173
|
+
|
|
174
|
+
def __str__(self) -> str:
|
|
175
|
+
return self.value
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class Style(str, Enum):
|
|
179
|
+
"""The slant style of the font."""
|
|
180
|
+
NORMAL = 'normal'
|
|
181
|
+
"""The default style for a font."""
|
|
182
|
+
ITALIC = 'italic'
|
|
183
|
+
OBLIQUE = 'oblique'
|
pyglet/event.py
CHANGED
|
@@ -348,7 +348,6 @@ class EventDispatcher:
|
|
|
348
348
|
"EventDispatcher.register_event_type('event_name')."
|
|
349
349
|
)
|
|
350
350
|
assert event_type in self.event_types, f"{event_type} not found in {self}.event_types == {self.event_types}"
|
|
351
|
-
|
|
352
351
|
invoked = False
|
|
353
352
|
|
|
354
353
|
# Search handler stack for matching event handlers
|
|
@@ -4,7 +4,8 @@ import sys
|
|
|
4
4
|
|
|
5
5
|
import pyglet
|
|
6
6
|
from pyglet import clock, event, graphics, image
|
|
7
|
-
from pyglet.
|
|
7
|
+
from pyglet.graphics import GeometryMode
|
|
8
|
+
from pyglet.graphics.api.gl import *
|
|
8
9
|
|
|
9
10
|
_is_pyglet_doc_run = hasattr(sys, "is_pyglet_doc_run") and sys.is_pyglet_doc_run
|
|
10
11
|
|
|
@@ -147,15 +148,15 @@ fragment_array_source = """#version 150 core
|
|
|
147
148
|
|
|
148
149
|
|
|
149
150
|
def get_default_shader():
|
|
150
|
-
return pyglet.
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
return pyglet.graphics.api.core.current_context.create_program((vertex_source, 'vertex'),
|
|
152
|
+
(geometry_source, 'geometry'),
|
|
153
|
+
(fragment_source, 'fragment'))
|
|
153
154
|
|
|
154
155
|
|
|
155
156
|
def get_default_array_shader():
|
|
156
|
-
return pyglet.
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
return pyglet.graphics.api.core.current_context.create_program((vertex_source, 'vertex'),
|
|
158
|
+
(geometry_source, 'geometry'),
|
|
159
|
+
(fragment_array_source, 'fragment'))
|
|
159
160
|
|
|
160
161
|
|
|
161
162
|
class SpriteGroup(graphics.Group):
|
|
@@ -172,7 +173,7 @@ class SpriteGroup(graphics.Group):
|
|
|
172
173
|
is created; applications usually do not need to explicitly create it.
|
|
173
174
|
|
|
174
175
|
:Parameters:
|
|
175
|
-
`texture` : `~pyglet.
|
|
176
|
+
`texture` : `~pyglet.graphics.Texture`
|
|
176
177
|
The (top-level) texture containing the sprite image.
|
|
177
178
|
`blend_src` : int
|
|
178
179
|
OpenGL blend source mode; for example,
|
|
@@ -180,7 +181,7 @@ class SpriteGroup(graphics.Group):
|
|
|
180
181
|
`blend_dest` : int
|
|
181
182
|
OpenGL blend destination mode; for example,
|
|
182
183
|
``GL_ONE_MINUS_SRC_ALPHA``.
|
|
183
|
-
`program` : `~pyglet.graphics.
|
|
184
|
+
`program` : `~pyglet.graphics.ShaderProgram`
|
|
184
185
|
A custom ShaderProgram.
|
|
185
186
|
`order` : int
|
|
186
187
|
Change the order to render above or below other Groups.
|
|
@@ -265,7 +266,7 @@ class Sprite(event.EventDispatcher):
|
|
|
265
266
|
`subpixel` : bool
|
|
266
267
|
Allow floating-point coordinates for the sprite. By default,
|
|
267
268
|
coordinates are restricted to integer values.
|
|
268
|
-
`program` : `~pyglet.graphics.
|
|
269
|
+
`program` : `~pyglet.graphics.ShaderProgram`
|
|
269
270
|
A custom shader to use. This shader program must contain the
|
|
270
271
|
exact same attribute names and types as the default shader.
|
|
271
272
|
The class methods and properties depend on this, and will
|
|
@@ -770,9 +771,10 @@ class Sprite(event.EventDispatcher):
|
|
|
770
771
|
See the module documentation for hints on drawing multiple sprites
|
|
771
772
|
efficiently.
|
|
772
773
|
"""
|
|
773
|
-
|
|
774
|
-
self.
|
|
775
|
-
self.
|
|
774
|
+
ctx = pyglet.graphics.api.core.current_context
|
|
775
|
+
self._group.set_state_recursive(ctx)
|
|
776
|
+
self._vertex_list.draw(GeometryMode.POINTS)
|
|
777
|
+
self._group.unset_state_recursive(ctx)
|
|
776
778
|
|
|
777
779
|
def __del__(self):
|
|
778
780
|
try:
|