pyglet 3.0.dev1__py3-none-any.whl → 3.0.dev2__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 +1 -1
- pyglet/enums.py +11 -1
- pyglet/experimental/geoshader_sprite.py +1 -1
- pyglet/experimental/particles.py +26 -34
- pyglet/graphics/__init__.py +0 -2
- pyglet/graphics/api/gl/draw.py +1 -1
- pyglet/graphics/api/gl/enums.py +1 -2
- pyglet/graphics/api/gl/shader.py +1 -1
- pyglet/graphics/api/gl/vertexdomain.py +2 -1
- pyglet/graphics/api/gl2/draw.py +1 -1
- pyglet/graphics/api/gl2/vertexdomain.py +1 -1
- pyglet/graphics/api/webgl/draw.py +1 -1
- pyglet/graphics/api/webgl/enums.py +1 -2
- pyglet/graphics/api/webgl/shader.py +1 -1
- pyglet/graphics/api/webgl/vertexdomain.py +2 -2
- pyglet/graphics/draw.py +1 -2
- pyglet/graphics/shader.py +2 -1
- pyglet/graphics/vertexdomain.py +2 -1
- pyglet/gui/ninepatch.py +2 -2
- pyglet/gui/widgets.py +1 -1
- pyglet/input/base.py +3 -2
- pyglet/input/win32/xinput.py +2 -2
- pyglet/media/codecs/webaudio_pyodide.py +3 -4
- pyglet/model/__init__.py +9 -35
- pyglet/model/codecs/base.py +68 -51
- pyglet/model/codecs/gltf.py +107 -63
- pyglet/model/codecs/obj.py +60 -57
- pyglet/shapes.py +3 -2
- pyglet/sprite.py +2 -2
- pyglet/text/caret.py +1 -1
- pyglet/text/formats/structured.py +1 -2
- pyglet/text/layout/base.py +2 -2
- {pyglet-3.0.dev1.dist-info → pyglet-3.0.dev2.dist-info}/METADATA +3 -2
- {pyglet-3.0.dev1.dist-info → pyglet-3.0.dev2.dist-info}/RECORD +36 -37
- {pyglet-3.0.dev1.dist-info → pyglet-3.0.dev2.dist-info}/WHEEL +1 -1
- pyglet/graphics/base.py +0 -10
- {pyglet-3.0.dev1.dist-info → pyglet-3.0.dev2.dist-info/licenses}/LICENSE +0 -0
pyglet/__init__.py
CHANGED
pyglet/enums.py
CHANGED
|
@@ -10,6 +10,15 @@ class GraphicsAPI(Enum):
|
|
|
10
10
|
WEBGL = auto()
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
class GeometryMode(Enum):
|
|
14
|
+
POINTS = auto()
|
|
15
|
+
LINES = auto()
|
|
16
|
+
LINE_STRIP = auto()
|
|
17
|
+
TRIANGLES = auto()
|
|
18
|
+
TRIANGLE_STRIP = auto()
|
|
19
|
+
TRIANGLE_FAN = auto()
|
|
20
|
+
|
|
21
|
+
|
|
13
22
|
class BlendFactor(Enum):
|
|
14
23
|
ZERO = "ZERO"
|
|
15
24
|
ONE = "ONE"
|
|
@@ -86,11 +95,13 @@ class CompareOp(Enum):
|
|
|
86
95
|
GREATER_OR_EQUAL = auto()
|
|
87
96
|
ALWAYS = auto()
|
|
88
97
|
|
|
98
|
+
|
|
89
99
|
class FramebufferTarget(Enum):
|
|
90
100
|
FRAMEBUFFER = auto()
|
|
91
101
|
DRAW = auto()
|
|
92
102
|
READ = auto()
|
|
93
103
|
|
|
104
|
+
|
|
94
105
|
class FramebufferAttachment(Enum):
|
|
95
106
|
COLOR0 = auto()
|
|
96
107
|
COLOR1 = auto()
|
|
@@ -114,7 +125,6 @@ class FramebufferAttachment(Enum):
|
|
|
114
125
|
DEPTH_STENCIL = auto()
|
|
115
126
|
|
|
116
127
|
|
|
117
|
-
|
|
118
128
|
class Weight(str, Enum):
|
|
119
129
|
"""An :py:class:`~enum.Enum` of known cross-platform font weight strings.
|
|
120
130
|
|
|
@@ -4,7 +4,7 @@ import sys
|
|
|
4
4
|
|
|
5
5
|
import pyglet
|
|
6
6
|
from pyglet import clock, event, graphics, image
|
|
7
|
-
from pyglet.
|
|
7
|
+
from pyglet.enums import GeometryMode
|
|
8
8
|
from pyglet.graphics.api.gl import *
|
|
9
9
|
|
|
10
10
|
_is_pyglet_doc_run = hasattr(sys, "is_pyglet_doc_run") and sys.is_pyglet_doc_run
|
pyglet/experimental/particles.py
CHANGED
|
@@ -7,8 +7,7 @@ import time
|
|
|
7
7
|
|
|
8
8
|
import pyglet
|
|
9
9
|
from pyglet import clock, event, graphics, image
|
|
10
|
-
from pyglet.
|
|
11
|
-
from pyglet.graphics.api.gl import *
|
|
10
|
+
from pyglet.enums import BlendFactor, GeometryMode
|
|
12
11
|
|
|
13
12
|
_is_pyglet_doc_run = hasattr(sys, "is_pyglet_doc_run") and sys.is_pyglet_doc_run
|
|
14
13
|
|
|
@@ -186,6 +185,9 @@ def get_default_shader():
|
|
|
186
185
|
|
|
187
186
|
|
|
188
187
|
class EmitterGroup(graphics.Group):
|
|
188
|
+
blend_src: BlendFactor
|
|
189
|
+
blend_dest: BlendFactor
|
|
190
|
+
|
|
189
191
|
def __init__(self, texture, blend_src, blend_dest, program, parent=None):
|
|
190
192
|
super().__init__(parent=parent)
|
|
191
193
|
self.texture = texture
|
|
@@ -203,15 +205,14 @@ class Emitter(event.EventDispatcher):
|
|
|
203
205
|
_animation = None
|
|
204
206
|
_frame_index = 0
|
|
205
207
|
_paused = False
|
|
206
|
-
_rotation = 0
|
|
207
208
|
_visible = True
|
|
208
209
|
_vertex_list = None
|
|
209
210
|
group_class = EmitterGroup
|
|
210
211
|
|
|
211
212
|
def __init__(self, img, x, y, z, count, velocity, spread,
|
|
212
213
|
color_start=(255, 255, 255, 255), color_end=(255, 255, 255, 255),
|
|
213
|
-
scale_start=(1.0, 1.0), scale_end=(1.0, 1.0),
|
|
214
|
-
blend_src=
|
|
214
|
+
scale_start=(1.0, 1.0), scale_end=(1.0, 1.0), rotation=0.0,
|
|
215
|
+
blend_src=BlendFactor.SRC_ALPHA, blend_dest=BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
215
216
|
batch=None, group=None, program=None):
|
|
216
217
|
|
|
217
218
|
self._img = img
|
|
@@ -225,6 +226,7 @@ class Emitter(event.EventDispatcher):
|
|
|
225
226
|
self._color_end = color_end
|
|
226
227
|
self._scale_start = scale_start
|
|
227
228
|
self._scale_end = scale_end
|
|
229
|
+
self._rotation = rotation
|
|
228
230
|
|
|
229
231
|
if isinstance(img, image.Animation):
|
|
230
232
|
self._animation = img
|
|
@@ -274,7 +276,7 @@ class Emitter(event.EventDispatcher):
|
|
|
274
276
|
program,
|
|
275
277
|
self._user_group)
|
|
276
278
|
if (self._batch and
|
|
277
|
-
self._batch.update_shader(self._vertex_list,
|
|
279
|
+
self._batch.update_shader(self._vertex_list, GeometryMode.POINTS, self._group, program)):
|
|
278
280
|
# Exit early if changing domain is not needed.
|
|
279
281
|
return
|
|
280
282
|
|
|
@@ -290,7 +292,8 @@ class Emitter(event.EventDispatcher):
|
|
|
290
292
|
"""
|
|
291
293
|
if self._animation:
|
|
292
294
|
clock.unschedule(self._animate)
|
|
293
|
-
self._vertex_list
|
|
295
|
+
if self._vertex_list:
|
|
296
|
+
self._vertex_list.delete()
|
|
294
297
|
self._vertex_list = None
|
|
295
298
|
self._texture = None
|
|
296
299
|
self._group = None
|
|
@@ -357,47 +360,36 @@ class ParticleManager:
|
|
|
357
360
|
def __init__(self, img, lifespan, count, velocity,
|
|
358
361
|
spread=(10.0, 10.0),
|
|
359
362
|
color_start=(255, 255, 255, 255), color_end=(255, 255, 255, 255),
|
|
360
|
-
scale_start=(1.0, 1.0), scale_end=(1.0, 1.0),
|
|
363
|
+
scale_start=(1.0, 1.0), scale_end=(1.0, 1.0), rotation=0.0,
|
|
361
364
|
batch=None, group=None):
|
|
362
365
|
|
|
363
366
|
self._img = img
|
|
364
|
-
self.
|
|
365
|
-
self.
|
|
366
|
-
self.
|
|
367
|
-
self.
|
|
368
|
-
self.
|
|
369
|
-
self.
|
|
370
|
-
self.
|
|
371
|
-
self.
|
|
367
|
+
self.lifespan = lifespan
|
|
368
|
+
self.count = count
|
|
369
|
+
self.velocity = velocity
|
|
370
|
+
self.spread = spread
|
|
371
|
+
self.color_start = color_start
|
|
372
|
+
self.color_end = color_end
|
|
373
|
+
self.scale_start = scale_start
|
|
374
|
+
self.scale_end = scale_end
|
|
375
|
+
self.rotation = rotation
|
|
372
376
|
|
|
373
377
|
self._batch = batch
|
|
374
378
|
self._group = group
|
|
375
379
|
self._program = get_default_shader()
|
|
376
380
|
clock.schedule_interval(self._update_shader_time, 1 / 60)
|
|
377
381
|
|
|
378
|
-
# TODO: remove debug
|
|
379
|
-
self.total_number = 0
|
|
380
|
-
self.total_label = pyglet.text.Label("particles: 0", 10, 10, dpi=256, color=(10, 200, 10), batch=batch)
|
|
381
|
-
|
|
382
382
|
def _update_shader_time(self, dt):
|
|
383
383
|
self._program['time'] = time.perf_counter()
|
|
384
384
|
|
|
385
|
-
|
|
385
|
+
@staticmethod
|
|
386
|
+
def _delete_callback(dt, emitter):
|
|
386
387
|
emitter.delete()
|
|
387
388
|
|
|
388
|
-
# TODO: remove debug
|
|
389
|
-
self.total_number -= 1
|
|
390
|
-
self.total_label.text = f"particles: {self.total_number * self._count * 8!s}"
|
|
391
|
-
|
|
392
389
|
def create_emitter(self, x, y, z=0):
|
|
393
|
-
emitter = Emitter(self._img, x, y, z, self.
|
|
394
|
-
color_start=self.
|
|
395
|
-
scale_start=self.
|
|
390
|
+
emitter = Emitter(self._img, x, y, z, self.count, self.velocity, self.spread,
|
|
391
|
+
color_start=self.color_start, color_end=self.color_end,
|
|
392
|
+
scale_start=self.scale_start, scale_end=self.scale_end, rotation=self.rotation,
|
|
396
393
|
batch=self._batch, group=self._group)
|
|
397
|
-
pyglet.clock.schedule_once(self._delete_callback, self.
|
|
398
|
-
|
|
399
|
-
# TODO: remove debug
|
|
400
|
-
self.total_number += 1
|
|
401
|
-
self.total_label.text = f"particles: {self.total_number * self._count * 8!s}"
|
|
402
|
-
|
|
394
|
+
pyglet.clock.schedule_once(self._delete_callback, self.lifespan, emitter)
|
|
403
395
|
return emitter
|
pyglet/graphics/__init__.py
CHANGED
|
@@ -8,8 +8,6 @@ See the :ref:`guide_graphics` for details on how to use this graphics API.
|
|
|
8
8
|
"""
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
from pyglet.graphics.base import GeometryMode # noqa: F401
|
|
13
11
|
from pyglet.graphics import api # noqa: F401
|
|
14
12
|
from pyglet.graphics.draw import Group, ShaderGroup # noqa: F401
|
|
15
13
|
from pyglet.graphics.state import State # noqa: F401
|
pyglet/graphics/api/gl/draw.py
CHANGED
|
@@ -14,7 +14,7 @@ from pyglet.graphics.state import State
|
|
|
14
14
|
_debug_graphics_batch = pyglet.options.debug_graphics_batch
|
|
15
15
|
|
|
16
16
|
if TYPE_CHECKING:
|
|
17
|
-
from pyglet.
|
|
17
|
+
from pyglet.enums import GeometryMode
|
|
18
18
|
from pyglet.graphics.api.gl2.shader import ShaderProgram
|
|
19
19
|
from pyglet.graphics.api.gl.vertexdomain import VertexList, IndexedVertexList
|
|
20
20
|
|
pyglet/graphics/api/gl/enums.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from pyglet.graphics import GeometryMode
|
|
4
3
|
from pyglet.graphics.api.gl import (
|
|
5
4
|
GL_LINEAR, GL_NEAREST, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, \
|
|
6
5
|
GL_TEXTURE_CUBE_MAP, \
|
|
@@ -15,7 +14,7 @@ from pyglet.graphics.api.gl import (
|
|
|
15
14
|
GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL,
|
|
16
15
|
GL_GEQUAL, GL_ALWAYS)
|
|
17
16
|
|
|
18
|
-
from pyglet.enums import BlendFactor, TextureFilter, TextureType, TextureWrapping, CompareOp
|
|
17
|
+
from pyglet.enums import BlendFactor, TextureFilter, TextureType, TextureWrapping, CompareOp, GeometryMode
|
|
19
18
|
|
|
20
19
|
geometry_map = {
|
|
21
20
|
GeometryMode.POINTS: GL_POINTS,
|
pyglet/graphics/api/gl/shader.py
CHANGED
|
@@ -42,7 +42,7 @@ from pyglet.graphics.shader import ShaderSource, ShaderType, ShaderBase, Attribu
|
|
|
42
42
|
from pyglet.graphics.shader import ShaderException
|
|
43
43
|
|
|
44
44
|
from pyglet.graphics.api.gl.buffer import BufferObject
|
|
45
|
-
from pyglet.
|
|
45
|
+
from pyglet.enums import GeometryMode
|
|
46
46
|
|
|
47
47
|
if TYPE_CHECKING:
|
|
48
48
|
from _weakref import CallableProxyType
|
|
@@ -64,7 +64,8 @@ from pyglet.graphics.vertexdomain import (
|
|
|
64
64
|
if TYPE_CHECKING:
|
|
65
65
|
from ctypes import Array
|
|
66
66
|
from pyglet.graphics.shader import AttributeView
|
|
67
|
-
from pyglet.graphics import
|
|
67
|
+
from pyglet.graphics import Group
|
|
68
|
+
from pyglet.enums import GeometryMode
|
|
68
69
|
from pyglet.graphics.shader import Attribute
|
|
69
70
|
from pyglet.customtypes import CType, DataTypes
|
|
70
71
|
|
pyglet/graphics/api/gl2/draw.py
CHANGED
|
@@ -23,7 +23,7 @@ _debug_graphics_batch = pyglet.options.debug_graphics_batch
|
|
|
23
23
|
|
|
24
24
|
if TYPE_CHECKING:
|
|
25
25
|
from pyglet.graphics.state import State
|
|
26
|
-
from pyglet.
|
|
26
|
+
from pyglet.enums import GeometryMode
|
|
27
27
|
from pyglet.graphics.api.gl2.shader import ShaderProgram
|
|
28
28
|
|
|
29
29
|
|
|
@@ -62,7 +62,7 @@ from pyglet.graphics.vertexdomain import (
|
|
|
62
62
|
if TYPE_CHECKING:
|
|
63
63
|
from pyglet.graphics.shader import AttributeView
|
|
64
64
|
from pyglet.customtypes import CType, DataTypes
|
|
65
|
-
from pyglet.
|
|
65
|
+
from pyglet.enums import GeometryMode
|
|
66
66
|
from pyglet.graphics.shader import Attribute
|
|
67
67
|
|
|
68
68
|
_c_types = {
|
|
@@ -10,7 +10,7 @@ from pyglet.graphics.draw import BatchBase, _DomainKey, Group
|
|
|
10
10
|
_debug_graphics_batch = pyglet.options.debug_graphics_batch
|
|
11
11
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
|
-
from pyglet.
|
|
13
|
+
from pyglet.enums import GeometryMode
|
|
14
14
|
from pyglet.graphics.api.webgl.vertexdomain import IndexedVertexList, VertexList
|
|
15
15
|
from pyglet.graphics.api.webgl.shader import ShaderProgram
|
|
16
16
|
from pyglet.graphics.api.webgl.context import OpenGLSurfaceContext
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from pyglet.graphics import GeometryMode
|
|
4
3
|
from pyglet.graphics.api.webgl.gl import (
|
|
5
4
|
GL_LINEAR, GL_NEAREST, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, \
|
|
6
5
|
GL_TEXTURE_CUBE_MAP, \
|
|
@@ -15,7 +14,7 @@ from pyglet.graphics.api.webgl.gl import (
|
|
|
15
14
|
GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL,
|
|
16
15
|
GL_GEQUAL, GL_ALWAYS)
|
|
17
16
|
|
|
18
|
-
from pyglet.enums import BlendFactor, TextureFilter, TextureType, TextureWrapping, CompareOp
|
|
17
|
+
from pyglet.enums import BlendFactor, TextureFilter, TextureType, TextureWrapping, CompareOp, GeometryMode
|
|
19
18
|
|
|
20
19
|
geometry_map = {
|
|
21
20
|
GeometryMode.POINTS: GL_POINTS,
|
|
@@ -26,7 +26,7 @@ from typing import TYPE_CHECKING, Any, Callable, Sequence, Type, Union
|
|
|
26
26
|
import pyglet
|
|
27
27
|
|
|
28
28
|
# from pyglet.graphics.api.webgl.buffer import BufferObject
|
|
29
|
-
from pyglet.
|
|
29
|
+
from pyglet.enums import GeometryMode
|
|
30
30
|
from pyglet.graphics.api.webgl import gl
|
|
31
31
|
from pyglet.graphics.api.webgl.buffer import BufferObject
|
|
32
32
|
from pyglet.graphics.api.webgl.gl import (
|
|
@@ -66,7 +66,7 @@ from pyglet.graphics.vertexdomain import (
|
|
|
66
66
|
if TYPE_CHECKING:
|
|
67
67
|
from pyglet.graphics.shader import AttributeView
|
|
68
68
|
from pyglet.customtypes import CType, DataTypes
|
|
69
|
-
from pyglet.
|
|
69
|
+
from pyglet.enums import GeometryMode
|
|
70
70
|
from pyglet.graphics.shader import Attribute
|
|
71
71
|
from pyglet.graphics.api.webgl.context import OpenGLSurfaceContext
|
|
72
72
|
|
|
@@ -228,7 +228,7 @@ class VertexDomain(VertexDomainBase):
|
|
|
228
228
|
if self._supports_multi_draw:
|
|
229
229
|
starts = (GLint * primcount)(*start_list)
|
|
230
230
|
sizes = (GLsizei * primcount)(*size_list)
|
|
231
|
-
self._multi_draw_array(starts[:], 0, sizes[:], 0, primcount)
|
|
231
|
+
self._multi_draw_array(mode, starts[:], 0, sizes[:], 0, primcount)
|
|
232
232
|
else:
|
|
233
233
|
for start, size in zip(start_list, size_list):
|
|
234
234
|
self._gl.drawArrays(mode, start, size)
|
pyglet/graphics/draw.py
CHANGED
|
@@ -5,7 +5,7 @@ from dataclasses import dataclass
|
|
|
5
5
|
from typing import Any, Callable, Sequence, TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
import pyglet
|
|
8
|
-
from pyglet.enums import BlendFactor, BlendOp, CompareOp
|
|
8
|
+
from pyglet.enums import BlendFactor, BlendOp, CompareOp, GeometryMode
|
|
9
9
|
|
|
10
10
|
from pyglet.graphics.state import (
|
|
11
11
|
State,
|
|
@@ -22,7 +22,6 @@ from pyglet.graphics.state import (
|
|
|
22
22
|
|
|
23
23
|
if TYPE_CHECKING:
|
|
24
24
|
from pyglet.customtypes import ScissorProtocol
|
|
25
|
-
from pyglet.graphics import GeometryMode
|
|
26
25
|
from pyglet.graphics.api.base import SurfaceContext
|
|
27
26
|
from pyglet.graphics.texture import TextureBase
|
|
28
27
|
from pyglet.graphics.vertexdomain import VertexDomain, VertexList, IndexedVertexList
|
pyglet/graphics/shader.py
CHANGED
|
@@ -10,7 +10,8 @@ from typing import Literal, Sequence, Any, TYPE_CHECKING, Callable, Protocol
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from pyglet.customtypes import DataTypes, CType
|
|
12
12
|
from pyglet.graphics.vertexdomain import IndexedVertexList, VertexList, InstanceIndexedVertexList, InstanceVertexList
|
|
13
|
-
from pyglet.graphics import
|
|
13
|
+
from pyglet.graphics import Batch, Group
|
|
14
|
+
from pyglet.enums import GeometryMode
|
|
14
15
|
from _weakref import CallableProxyType
|
|
15
16
|
|
|
16
17
|
|
pyglet/graphics/vertexdomain.py
CHANGED
|
@@ -35,7 +35,8 @@ if TYPE_CHECKING:
|
|
|
35
35
|
from pyglet.graphics.api.base import SurfaceContext
|
|
36
36
|
from pyglet.graphics.instance import InstanceBucket, VertexInstanceBase, BaseInstanceDomain
|
|
37
37
|
from pyglet.graphics.buffer import AttributeBufferObject, IndexedBufferObject
|
|
38
|
-
from pyglet.graphics import
|
|
38
|
+
from pyglet.graphics import Group
|
|
39
|
+
from pyglet.enums import GeometryMode
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
def _nearest_pow2(v: int) -> int:
|
pyglet/gui/ninepatch.py
CHANGED
|
@@ -2,12 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
|
-
from pyglet.enums import BlendFactor
|
|
5
|
+
from pyglet.enums import BlendFactor, GeometryMode
|
|
6
6
|
from pyglet.sprite import Sprite
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
9
|
from pyglet.image import _AbstractImage, Animation
|
|
10
|
-
from pyglet.graphics import Batch, Group
|
|
10
|
+
from pyglet.graphics import Batch, Group
|
|
11
11
|
from pyglet.text.layout import TextLayout
|
|
12
12
|
|
|
13
13
|
|
pyglet/gui/widgets.py
CHANGED
|
@@ -266,7 +266,7 @@ class PushButton(WidgetBase):
|
|
|
266
266
|
return
|
|
267
267
|
self._sprite.image = self._unpressed_img
|
|
268
268
|
self._pressed = False
|
|
269
|
-
self.dispatch_event('on_release')
|
|
269
|
+
self.dispatch_event('on_release', self)
|
|
270
270
|
|
|
271
271
|
def on_mouse_motion(self, x: int, y: int, dx: int, dy: int) -> None:
|
|
272
272
|
if not self.enabled or self._pressed:
|
pyglet/input/base.py
CHANGED
|
@@ -77,12 +77,13 @@ class Device:
|
|
|
77
77
|
|
|
78
78
|
Args:
|
|
79
79
|
window:
|
|
80
|
-
Optional window to associate with the device.
|
|
80
|
+
Optional window to associate with the device. The behavior
|
|
81
81
|
of this parameter is device and operating system dependent.
|
|
82
82
|
It can usually be omitted for most devices.
|
|
83
83
|
exclusive:
|
|
84
84
|
If ``True`` the device will be opened exclusively so that no
|
|
85
|
-
other application can use it.
|
|
85
|
+
other application can use it. Note that not all device types
|
|
86
|
+
support being opened exclusively.
|
|
86
87
|
|
|
87
88
|
Raises:
|
|
88
89
|
DeviceOpenException:
|
pyglet/input/win32/xinput.py
CHANGED
|
@@ -551,12 +551,12 @@ class XInputController(Controller):
|
|
|
551
551
|
|
|
552
552
|
for button_name in controller_api_to_pyglet.values():
|
|
553
553
|
control = self.device.controls[button_name]
|
|
554
|
-
self.
|
|
554
|
+
# self.button_controls.append(control)
|
|
555
555
|
self._bind_button_control(control, button_name)
|
|
556
556
|
|
|
557
557
|
for axis_name in "leftx", "lefty", "rightx", "righty", "lefttrigger", "righttrigger":
|
|
558
558
|
control = self.device.controls[axis_name]
|
|
559
|
-
self.
|
|
559
|
+
# self.absolute_axis_controls.append(control)
|
|
560
560
|
self._bind_axis_control(control, axis_name, Sign.DEFAULT)
|
|
561
561
|
|
|
562
562
|
def rumble_play_weak(self, strength=1.0, duration=0.5):
|
|
@@ -97,10 +97,9 @@ class PyodideDecoder(MediaDecoder): # noqa: D101
|
|
|
97
97
|
return '.mp3', '.aac', '.wav', '.ogg', '.webm'
|
|
98
98
|
# possibly use audio.canPlayType?
|
|
99
99
|
|
|
100
|
-
def decode(self, filename: str, file: BinaryIO, streaming: bool = True) -> JavascriptWebAudioSource
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return StaticSource(JavascriptWebAudioSource(filename, file))
|
|
100
|
+
def decode(self, filename: str, file: BinaryIO, streaming: bool = True) -> JavascriptWebAudioSource:
|
|
101
|
+
# web audio doesn't really have streaming sources, so just always return this regardless
|
|
102
|
+
return JavascriptWebAudioSource(filename, file)
|
|
104
103
|
|
|
105
104
|
|
|
106
105
|
def get_decoders() -> list[PyodideDecoder]: # noqa: D103
|
pyglet/model/__init__.py
CHANGED
|
@@ -32,6 +32,7 @@ from math import pi, sin, cos
|
|
|
32
32
|
from typing import TYPE_CHECKING
|
|
33
33
|
|
|
34
34
|
import pyglet
|
|
35
|
+
import pyglet.enums
|
|
35
36
|
from pyglet import graphics
|
|
36
37
|
from pyglet.math import Mat4
|
|
37
38
|
|
|
@@ -128,7 +129,7 @@ class Model:
|
|
|
128
129
|
batch = graphics.Batch()
|
|
129
130
|
|
|
130
131
|
for group, vlist in zip(self.groups, self.vertex_lists):
|
|
131
|
-
self._batch.migrate(vlist,
|
|
132
|
+
self._batch.migrate(vlist, pyglet.enums.GeometryMode.TRIANGLES, group, batch)
|
|
132
133
|
|
|
133
134
|
self._batch = batch
|
|
134
135
|
|
|
@@ -213,25 +214,6 @@ class TexturedMaterialGroup(BaseMaterialGroup):
|
|
|
213
214
|
self.set_shader_program(program)
|
|
214
215
|
self.uniforms = {"model": self.matrix}
|
|
215
216
|
self.set_shader_uniforms(program, self.uniforms)
|
|
216
|
-
#
|
|
217
|
-
# def set_state(self) -> None:
|
|
218
|
-
# # gl.glActiveTexture(gl.GL_TEXTURE0)
|
|
219
|
-
# # gl.glBindTexture(self.texture.target, self.texture.id)
|
|
220
|
-
# # self.program.use()
|
|
221
|
-
# # self.program['model'] = self.matrix
|
|
222
|
-
# pass
|
|
223
|
-
#
|
|
224
|
-
# def __hash__(self) -> int:
|
|
225
|
-
# return hash((self.texture.target, self.texture.id, self.program, self.order, self.parent))
|
|
226
|
-
#
|
|
227
|
-
# def __eq__(self, other) -> bool:
|
|
228
|
-
# return (self.__class__ is other.__class__ and
|
|
229
|
-
# self.material == other.material and
|
|
230
|
-
# self.texture.target == other.texture.target and
|
|
231
|
-
# self.texture.id == other.texture.id and
|
|
232
|
-
# self.program == other.program and
|
|
233
|
-
# self.order == other.order and
|
|
234
|
-
# self.parent == other.parent)
|
|
235
217
|
|
|
236
218
|
|
|
237
219
|
class MaterialGroup(BaseMaterialGroup):
|
|
@@ -278,19 +260,11 @@ class MaterialGroup(BaseMaterialGroup):
|
|
|
278
260
|
}
|
|
279
261
|
"""
|
|
280
262
|
|
|
281
|
-
def
|
|
282
|
-
|
|
283
|
-
self.program
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return hash((self.material, self.program, self.order, self.parent))
|
|
287
|
-
|
|
288
|
-
def __eq__(self, other):
|
|
289
|
-
return (self.__class__ is other.__class__ and
|
|
290
|
-
self.material == other.material and
|
|
291
|
-
self.program == other.program and
|
|
292
|
-
self.order == other.order and
|
|
293
|
-
self.parent == other.parent)
|
|
263
|
+
def __init__(self, material: SimpleMaterial, program: ShaderProgram, order: int = 0, parent: Group | None = None):
|
|
264
|
+
super().__init__(material, program, order, parent)
|
|
265
|
+
self.set_shader_program(program)
|
|
266
|
+
self.uniforms = {"model": self.matrix}
|
|
267
|
+
self.set_shader_uniforms(program, self.uniforms)
|
|
294
268
|
|
|
295
269
|
|
|
296
270
|
class Cube(Model):
|
|
@@ -364,7 +338,7 @@ class Cube(Model):
|
|
|
364
338
|
7, 6, 4, 6, 5, 4, # back
|
|
365
339
|
3, 2, 0, 2, 1, 0] # front
|
|
366
340
|
|
|
367
|
-
return self._program.vertex_list_indexed(len(vertices) // 3,
|
|
341
|
+
return self._program.vertex_list_indexed(len(vertices) // 3, pyglet.enums.GeometryMode.TRIANGLES, indices,
|
|
368
342
|
batch=self._batch, group=self._group,
|
|
369
343
|
POSITION=('f', vertices),
|
|
370
344
|
NORMAL=('f', normals),
|
|
@@ -422,7 +396,7 @@ class Sphere(Model):
|
|
|
422
396
|
indices.extend([first, second, second + 1])
|
|
423
397
|
indices.extend([first, second + 1, first + 1])
|
|
424
398
|
|
|
425
|
-
return self._program.vertex_list_indexed(len(vertices) // 3,
|
|
399
|
+
return self._program.vertex_list_indexed(len(vertices) // 3, pyglet.enums.GeometryMode.TRIANGLES, indices,
|
|
426
400
|
batch=self._batch, group=self._group,
|
|
427
401
|
POSITION=('f', vertices),
|
|
428
402
|
NORMAL=('f', normals),
|