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
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# WebGL object types
|
|
2
|
+
from typing import Any, Sequence
|
|
3
|
+
|
|
4
|
+
class WebGLShader: ...
|
|
5
|
+
class WebGLProgram: ...
|
|
6
|
+
class WebGLBuffer: ...
|
|
7
|
+
class WebGLTexture: ...
|
|
8
|
+
class WebGLFramebuffer: ...
|
|
9
|
+
class WebGLRenderbuffer: ...
|
|
10
|
+
class WebGLUniformLocation: ...
|
|
11
|
+
class WebGLActiveInfo:
|
|
12
|
+
name: str
|
|
13
|
+
size: int
|
|
14
|
+
type: int
|
|
15
|
+
class WebGLQuery: ...
|
|
16
|
+
class WebGLSampler: ...
|
|
17
|
+
class WebGLSync: ...
|
|
18
|
+
class WebGLTransformFeedback: ...
|
|
19
|
+
class WebGLVertexArrayObject: ...
|
|
20
|
+
|
|
21
|
+
class WebGLRenderingContext:
|
|
22
|
+
# --- Texture State ---
|
|
23
|
+
def activeTexture(self, texture: int) -> None: ...
|
|
24
|
+
|
|
25
|
+
# --- Shader Functions ---
|
|
26
|
+
def createShader(self, shaderType: int) -> WebGLShader | None: ...
|
|
27
|
+
def shaderSource(self, shader: WebGLShader, source: str) -> None: ...
|
|
28
|
+
def compileShader(self, shader: WebGLShader) -> None: ...
|
|
29
|
+
def getShaderParameter(self, shader: WebGLShader, pname: int) -> Any: ...
|
|
30
|
+
def getShaderInfoLog(self, shader: WebGLShader) -> str: ...
|
|
31
|
+
def getShaderSource(self, shader: WebGLShader) -> str: ...
|
|
32
|
+
def deleteShader(self, shader: WebGLShader | None) -> None: ...
|
|
33
|
+
|
|
34
|
+
# --- Program Functions ---
|
|
35
|
+
def createProgram(self) -> WebGLProgram | None: ...
|
|
36
|
+
def attachShader(self, program: WebGLProgram, shader: WebGLShader) -> None: ...
|
|
37
|
+
def detachShader(self, program: WebGLProgram, shader: WebGLShader) -> None: ...
|
|
38
|
+
def linkProgram(self, program: WebGLProgram) -> None: ...
|
|
39
|
+
def useProgram(self, program: WebGLProgram | None) -> None: ...
|
|
40
|
+
def getProgramParameter(self, program: WebGLProgram, pname: int) -> Any: ...
|
|
41
|
+
def getProgramInfoLog(self, program: WebGLProgram) -> str: ...
|
|
42
|
+
def getAttachedShaders(self, program: WebGLProgram) -> list[WebGLShader]: ...
|
|
43
|
+
def getActiveAttrib(self, program: WebGLProgram, index: int) -> WebGLActiveInfo | None: ...
|
|
44
|
+
def getActiveUniform(self, program: WebGLProgram, index: int) -> WebGLActiveInfo | None: ...
|
|
45
|
+
def getUniformLocation(self, program: WebGLProgram, name: str) -> WebGLUniformLocation | None: ...
|
|
46
|
+
def getUniform(self, program: WebGLProgram, location: WebGLUniformLocation) -> Any: ...
|
|
47
|
+
def deleteProgram(self, program: WebGLProgram | None) -> None: ...
|
|
48
|
+
|
|
49
|
+
# --- Buffer Functions ---
|
|
50
|
+
def createBuffer(self) -> WebGLBuffer | None: ...
|
|
51
|
+
def bindBuffer(self, target: int, buffer: WebGLBuffer | None) -> None: ...
|
|
52
|
+
def bufferData(self, target: int, data: int | bytes | Sequence[float] | memoryview, usage: int) -> None: ...
|
|
53
|
+
def bufferSubData(self, target: int, offset: int, data: bytes | Sequence[float] | memoryview) -> None: ...
|
|
54
|
+
def deleteBuffer(self, buffer: WebGLBuffer | None) -> None: ...
|
|
55
|
+
def getBufferParameter(self, target: int, pname: int) -> Any: ...
|
|
56
|
+
|
|
57
|
+
# --- Texture Functions ---
|
|
58
|
+
def createTexture(self) -> WebGLTexture | None: ...
|
|
59
|
+
def bindTexture(self, target: int, texture: WebGLTexture | None) -> None: ...
|
|
60
|
+
def texImage2D(
|
|
61
|
+
self, target: int, level: int, internalformat: int,
|
|
62
|
+
width: int, height: int, border: int,
|
|
63
|
+
format: int, type: int, pixels: bytes | memoryview | None = None,
|
|
64
|
+
) -> None: ...
|
|
65
|
+
def texImage2D(
|
|
66
|
+
self, target: int, level: int, internalformat: int,
|
|
67
|
+
format: int, type: int, source: Any,
|
|
68
|
+
) -> None: ... # Overload for image sources
|
|
69
|
+
def texSubImage2D(
|
|
70
|
+
self, target: int, level: int, xoffset: int, yoffset: int,
|
|
71
|
+
width: int, height: int, format: int, type: int,
|
|
72
|
+
pixels: bytes | memoryview | None = None,
|
|
73
|
+
) -> None: ...
|
|
74
|
+
def texSubImage2D(
|
|
75
|
+
self, target: int, level: int, xoffset: int, yoffset: int,
|
|
76
|
+
format: int, type: int, source: Any,
|
|
77
|
+
) -> None: ... # Overload for image sources
|
|
78
|
+
def texParameterf(self, target: int, pname: int, param: float) -> None: ...
|
|
79
|
+
def texParameteri(self, target: int, pname: int, param: int) -> None: ...
|
|
80
|
+
def compressedTexImage2D(
|
|
81
|
+
self, target: int, level: int, internalformat: int,
|
|
82
|
+
width: int, height: int, border: int, pixels: bytes | memoryview | None = None,
|
|
83
|
+
) -> None: ...
|
|
84
|
+
def generateMipmap(self, target: int) -> None: ...
|
|
85
|
+
def deleteTexture(self, texture: WebGLTexture | None) -> None: ...
|
|
86
|
+
def getTexParameter(self, target: int, pname: int) -> Any: ...
|
|
87
|
+
|
|
88
|
+
# --- Renderbuffer Functions ---
|
|
89
|
+
def createRenderbuffer(self) -> WebGLRenderbuffer | None: ...
|
|
90
|
+
def bindRenderbuffer(self, target: int, renderbuffer: WebGLRenderbuffer | None) -> None: ...
|
|
91
|
+
def renderbufferStorage(self, target: int, internalformat: int, width: int, height: int) -> None: ...
|
|
92
|
+
def renderbufferStorageMultisample(self, target: int, samples: int, internalformat: int, width: int, height: int) -> None: ...
|
|
93
|
+
def deleteRenderbuffer(self, renderbuffer: WebGLRenderbuffer | None) -> None: ...
|
|
94
|
+
def getRenderbufferParameter(self, target: int, pname: int) -> Any: ...
|
|
95
|
+
|
|
96
|
+
# --- Framebuffer Functions ---
|
|
97
|
+
def createFramebuffer(self) -> WebGLFramebuffer | None: ...
|
|
98
|
+
def bindFramebuffer(self, target: int, framebuffer: WebGLFramebuffer | None) -> None: ...
|
|
99
|
+
def framebufferRenderbuffer(self, target: int, attachment: int, renderbuffertarget: int, renderbuffer: WebGLRenderbuffer | None) -> None: ...
|
|
100
|
+
def framebufferTexture2D(self, target: int, attachment: int, textarget: int, texture: WebGLTexture | None, level: int) -> None: ...
|
|
101
|
+
def checkFramebufferStatus(self, target: int) -> int: ...
|
|
102
|
+
def deleteFramebuffer(self, framebuffer: WebGLFramebuffer | None) -> None: ...
|
|
103
|
+
def getFramebufferAttachmentParameter(self, target: int, attachment: int, pname: int) -> Any: ...
|
|
104
|
+
|
|
105
|
+
# --- State and Misc Functions ---
|
|
106
|
+
def clear(self, mask: int) -> None: ...
|
|
107
|
+
def clearColor(self, red: float, green: float, blue: float, alpha: float) -> None: ...
|
|
108
|
+
def clearDepth(self, depth: float) -> None: ...
|
|
109
|
+
def clearStencil(self, s: int) -> None: ...
|
|
110
|
+
def colorMask(self, red: bool, green: bool, blue: bool, alpha: bool) -> None: ...
|
|
111
|
+
def cullFace(self, mode: int) -> None: ...
|
|
112
|
+
def depthFunc(self, func: int) -> None: ...
|
|
113
|
+
def depthMask(self, flag: bool) -> None: ...
|
|
114
|
+
def depthRange(self, zNear: float, zFar: float) -> None: ...
|
|
115
|
+
def disable(self, cap: int) -> None: ...
|
|
116
|
+
def enable(self, cap: int) -> None: ...
|
|
117
|
+
def finish(self) -> None: ...
|
|
118
|
+
def flush(self) -> None: ...
|
|
119
|
+
def frontFace(self, mode: int) -> None: ...
|
|
120
|
+
def hint(self, target: int, mode: int) -> None: ...
|
|
121
|
+
def isBuffer(self, buffer: WebGLBuffer) -> bool: ...
|
|
122
|
+
def isContextLost(self) -> bool: ...
|
|
123
|
+
def isEnabled(self, cap: int) -> bool: ...
|
|
124
|
+
def isFramebuffer(self, framebuffer: WebGLFramebuffer) -> bool: ...
|
|
125
|
+
def isProgram(self, program: WebGLProgram) -> bool: ...
|
|
126
|
+
def isRenderbuffer(self, renderbuffer: WebGLRenderbuffer) -> bool: ...
|
|
127
|
+
def isShader(self, shader: WebGLShader) -> bool: ...
|
|
128
|
+
def isTexture(self, texture: WebGLTexture) -> bool: ...
|
|
129
|
+
def lineWidth(self, width: float) -> None: ...
|
|
130
|
+
def pixelStorei(self, pname: int, param: int | bool) -> None: ...
|
|
131
|
+
def polygonOffset(self, factor: float, units: float) -> None: ...
|
|
132
|
+
def readPixels(
|
|
133
|
+
self, x: int, y: int, width: int, height: int,
|
|
134
|
+
format: int, type: int, pixels: bytes | memoryview | None,
|
|
135
|
+
) -> None: ...
|
|
136
|
+
def sampleCoverage(self, value: float, invert: bool) -> None: ...
|
|
137
|
+
def scissor(self, x: int, y: int, width: int, height: int) -> None: ...
|
|
138
|
+
def getError(self) -> int: ...
|
|
139
|
+
def getParameter(self, pname: int) -> Any: ...
|
|
140
|
+
def getContextAttributes(self) -> Any: ...
|
|
141
|
+
def getExtension(self, name: str) -> Any: ...
|
|
142
|
+
def getSupportedExtensions(self) -> list[str] | None: ...
|
|
143
|
+
|
|
144
|
+
# --- Vertex Attribute Functions ---
|
|
145
|
+
def enableVertexAttribArray(self, index: int) -> None: ...
|
|
146
|
+
def disableVertexAttribArray(self, index: int) -> None: ...
|
|
147
|
+
def vertexAttrib1f(self, index: int, x: float) -> None: ...
|
|
148
|
+
def vertexAttrib1fv(self, index: int, values: Sequence[float] | memoryview) -> None: ...
|
|
149
|
+
def vertexAttrib2f(self, index: int, x: float, y: float) -> None: ...
|
|
150
|
+
def vertexAttrib2fv(self, index: int, values: Sequence[float] | memoryview) -> None: ...
|
|
151
|
+
def vertexAttrib3f(self, index: int, x: float, y: float, z: float) -> None: ...
|
|
152
|
+
def vertexAttrib3fv(self, index: int, values: Sequence[float] | memoryview) -> None: ...
|
|
153
|
+
def vertexAttrib4f(self, index: int, x: float, y: float, z: float, w: float) -> None: ...
|
|
154
|
+
def vertexAttrib4fv(self, index: int, values: Sequence[float] | memoryview) -> None: ...
|
|
155
|
+
def vertexAttribPointer(self, index: int, size: int, type: int, normalized: bool, stride: int, offset: int) -> None: ...
|
|
156
|
+
def getVertexAttrib(self, index: int, pname: int) -> Any: ...
|
|
157
|
+
def getVertexAttribOffset(self, index: int, pname: int) -> int: ...
|
|
158
|
+
def getAttribLocation(self, program: WebGLProgram, name: str) -> int: ...
|
|
159
|
+
|
|
160
|
+
# --- Uniform Functions ---
|
|
161
|
+
def uniform1f(self, location: WebGLUniformLocation, x: float) -> None: ...
|
|
162
|
+
def uniform1fv(self, location: WebGLUniformLocation, v: Sequence[float] | memoryview) -> None: ...
|
|
163
|
+
def uniform1i(self, location: WebGLUniformLocation, x: int) -> None: ...
|
|
164
|
+
def uniform1iv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
165
|
+
def uniform2f(self, location: WebGLUniformLocation, x: float, y: float) -> None: ...
|
|
166
|
+
def uniform2fv(self, location: WebGLUniformLocation, v: Sequence[float] | memoryview) -> None: ...
|
|
167
|
+
def uniform2i(self, location: WebGLUniformLocation, x: int, y: int) -> None: ...
|
|
168
|
+
def uniform2iv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
169
|
+
def uniform3f(self, location: WebGLUniformLocation, x: float, y: float, z: float) -> None: ...
|
|
170
|
+
def uniform3fv(self, location: WebGLUniformLocation, v: Sequence[float] | memoryview) -> None: ...
|
|
171
|
+
def uniform3i(self, location: WebGLUniformLocation, x: int, y: int, z: int) -> None: ...
|
|
172
|
+
def uniform3iv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
173
|
+
def uniform4f(self, location: WebGLUniformLocation, x: float, y: float, z: float, w: float) -> None: ...
|
|
174
|
+
def uniform4fv(self, location: WebGLUniformLocation, v: Sequence[float] | memoryview) -> None: ...
|
|
175
|
+
def uniform4i(self, location: WebGLUniformLocation, x: int, y: int, z: int, w: int) -> None: ...
|
|
176
|
+
def uniform4iv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
177
|
+
def uniformMatrix2fv(self, location: WebGLUniformLocation, transpose: bool, value: Sequence[float] | memoryview) -> None: ...
|
|
178
|
+
def uniformMatrix3fv(self, location: WebGLUniformLocation, transpose: bool, value: Sequence[float] | memoryview) -> None: ...
|
|
179
|
+
def uniformMatrix4fv(self, location: WebGLUniformLocation, transpose: bool, value: Sequence[float] | memoryview) -> None: ...
|
|
180
|
+
def validateProgram(self, program: WebGLProgram) -> None: ...
|
|
181
|
+
|
|
182
|
+
# --- Viewport ---
|
|
183
|
+
def viewport(self, x: int, y: int, width: int, height: int) -> None: ...
|
|
184
|
+
def drawArrays(self, mode: int, first: int, count: int) -> None: ...
|
|
185
|
+
def drawElements(self, mode: int, count: int, type: int, offset: int) -> None: ...
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class WebGL2RenderingContext(WebGLRenderingContext):
|
|
190
|
+
def beginQuery(self, target: int, query: WebGLQuery) -> None: ...
|
|
191
|
+
def beginTransformFeedback(self, primitiveMode: int) -> None: ...
|
|
192
|
+
def bindBufferBase(self, target: int, index: int, buffer: WebGLBuffer | None) -> None: ...
|
|
193
|
+
def bindBufferRange(self, target: int, index: int, buffer: WebGLBuffer | None, offset: int, size: int) -> None: ...
|
|
194
|
+
def bindSampler(self, unit: int, sampler: WebGLSampler | None) -> None: ...
|
|
195
|
+
def bindTransformFeedback(self, target: int, transformFeedback: WebGLTransformFeedback | None) -> None: ...
|
|
196
|
+
def bindVertexArray(self, array: WebGLVertexArrayObject | None) -> None: ...
|
|
197
|
+
def blitFramebuffer(
|
|
198
|
+
self, srcX0: int, srcY0: int, srcX1: int, srcY1: int,
|
|
199
|
+
dstX0: int, dstY0: int, dstX1: int, dstY1: int,
|
|
200
|
+
mask: int, filter: int,
|
|
201
|
+
) -> None: ...
|
|
202
|
+
def clearBufferfi(self, buffer: int, drawbuffer: int, depth: float, stencil: int) -> None: ...
|
|
203
|
+
def clearBufferfv(self, buffer: int, drawbuffer: int, values: Sequence[float] | memoryview) -> None: ...
|
|
204
|
+
def clearBufferiv(self, buffer: int, drawbuffer: int, values: Sequence[int] | memoryview) -> None: ...
|
|
205
|
+
def clearBufferuiv(self, buffer: int, drawbuffer: int, values: Sequence[int] | memoryview) -> None: ...
|
|
206
|
+
def clientWaitSync(self, sync: WebGLSync, flags: int, timeout: int) -> int: ...
|
|
207
|
+
def texStorage2D(self, target: int, levels: int, internalformat: int, width: int, height: int) -> None: ...
|
|
208
|
+
def compressedTexImage3D(
|
|
209
|
+
self, target: int, level: int, internalformat: int,
|
|
210
|
+
width: int, height: int, depth: int, border: int,
|
|
211
|
+
imageSize: int, data: bytes | memoryview | None,
|
|
212
|
+
) -> None: ...
|
|
213
|
+
def compressedTexSubImage3D(
|
|
214
|
+
self, target: int, level: int, xoffset: int, yoffset: int, zoffset: int,
|
|
215
|
+
width: int, height: int, depth: int, format: int,
|
|
216
|
+
imageSize: int, data: bytes | memoryview | None,
|
|
217
|
+
) -> None: ...
|
|
218
|
+
def copyBufferSubData(self, readTarget: int, writeTarget: int, readOffset: int, writeOffset: int, size: int) -> None: ...
|
|
219
|
+
def copyTexSubImage3D(
|
|
220
|
+
self, target: int, level: int, xoffset: int, yoffset: int, zoffset: int,
|
|
221
|
+
x: int, y: int, width: int, height: int,
|
|
222
|
+
) -> None: ...
|
|
223
|
+
def createQuery(self) -> WebGLQuery | None: ...
|
|
224
|
+
def deleteQuery(self, query: WebGLQuery | None) -> None: ...
|
|
225
|
+
def getQuery(self, target: int, pname: int) -> WebGLQuery | None: ...
|
|
226
|
+
def getQueryParameter(self, query: WebGLQuery, pname: int) -> Any: ...
|
|
227
|
+
def createSampler(self) -> WebGLSampler | None: ...
|
|
228
|
+
def deleteSampler(self, sampler: WebGLSampler | None) -> None: ...
|
|
229
|
+
def getSamplerParameter(self, sampler: WebGLSampler, pname: int) -> Any: ...
|
|
230
|
+
def samplerParameteri(self, sample: WebGLSampler, pname: int, param: int) -> None: ...
|
|
231
|
+
def samplerParameterf(self, sample: WebGLSampler, pname: int, param: float) -> None: ...
|
|
232
|
+
def createSync(self, condition: int, flags: int) -> WebGLSync | None: ...
|
|
233
|
+
def deleteSync(self, sync: WebGLSync | None) -> None: ...
|
|
234
|
+
def getSyncParameter(self, sync: WebGLSync, pname: int) -> Any: ...
|
|
235
|
+
def fenceSync(self, condition: int, flags: int) -> WebGLSync | None: ...
|
|
236
|
+
def createTransformFeedback(self) -> WebGLTransformFeedback | None: ...
|
|
237
|
+
def deleteTransformFeedback(self, transformFeedback: WebGLTransformFeedback | None) -> None: ...
|
|
238
|
+
def createVertexArray(self) -> WebGLVertexArrayObject | None: ...
|
|
239
|
+
def deleteVertexArray(self, array: WebGLVertexArrayObject | None) -> None: ...
|
|
240
|
+
def isQuery(self, query: WebGLQuery) -> bool: ...
|
|
241
|
+
def isSampler(self, sampler: WebGLSampler) -> bool: ...
|
|
242
|
+
def isSync(self, sync: WebGLSync) -> bool: ...
|
|
243
|
+
def isTransformFeedback(self, transformFeedback: WebGLTransformFeedback) -> bool: ...
|
|
244
|
+
def isVertexArray(self, array: WebGLVertexArrayObject) -> bool: ...
|
|
245
|
+
def drawArraysInstanced(self, mode: int, first: int, count: int, instanceCount: int) -> None: ...
|
|
246
|
+
def drawElementsInstanced(self, mode: int, count: int, type: int, offset: int, instanceCount: int) -> None: ...
|
|
247
|
+
def drawRangeElements(self, mode: int, start: int, end: int, count: int, type: int, offset: int) -> None: ...
|
|
248
|
+
def endQuery(self, target: int) -> None: ...
|
|
249
|
+
def endTransformFeedback(self) -> None: ...
|
|
250
|
+
def getBufferSubData(self, target: int, srcByteOffset: int, dstBuffer: bytearray | memoryview) -> None: ...
|
|
251
|
+
def getIndexedParameter(self, target: int, index: int) -> Any: ...
|
|
252
|
+
# --- Uniform Block Functions ---
|
|
253
|
+
def getUniformBlockIndex(self, program: WebGLProgram, uniformBlockName: str) -> int: ...
|
|
254
|
+
def getActiveUniformBlockParameter(self, program: WebGLProgram, uniformBlockIndex: int, pname: int) -> Any: ...
|
|
255
|
+
def getActiveUniformBlockName(self, program: WebGLProgram, uniformBlockIndex: int) -> str: ...
|
|
256
|
+
def uniformBlockBinding(self, program: WebGLProgram, uniformBlockIndex: int, uniformBlockBinding: int) -> None: ...
|
|
257
|
+
|
|
258
|
+
# --- Blending Functions ---
|
|
259
|
+
def blendColor(self, red: float, green: float, blue: float, alpha: float) -> None: ...
|
|
260
|
+
def blendEquation(self, mode: int) -> None: ...
|
|
261
|
+
def blendEquationSeparate(self, modeRGB: int, modeAlpha: int) -> None: ...
|
|
262
|
+
def blendFunc(self, sfactor: int, dfactor: int) -> None: ...
|
|
263
|
+
def blendFuncSeparate(self, srcRGB: int, dstRGB: int, srcAlpha: int, dstAlpha: int) -> None: ...
|
|
264
|
+
|
|
265
|
+
# --- Additional WebGL2 Functions ---
|
|
266
|
+
def getFragDataLocation(self, program: WebGLProgram, name: str) -> int: ...
|
|
267
|
+
def drawBuffers(self, buffers: Sequence[int]) -> None: ...
|
|
268
|
+
def uniform1ui(self, location: WebGLUniformLocation, v0: int) -> None: ...
|
|
269
|
+
def uniform1uiv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
270
|
+
def uniform2ui(self, location: WebGLUniformLocation, v0: int, v1: int) -> None: ...
|
|
271
|
+
def uniform2uiv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
272
|
+
def uniform3ui(self, location: WebGLUniformLocation, v0: int, v1: int, v2: int) -> None: ...
|
|
273
|
+
def uniform3uiv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
274
|
+
def uniform4ui(self, location: WebGLUniformLocation, v0: int, v1: int, v2: int, v3: int) -> None: ...
|
|
275
|
+
def uniform4uiv(self, location: WebGLUniformLocation, v: Sequence[int] | memoryview) -> None: ...
|
|
276
|
+
def vertexAttribDivisor(self, index: int, divisor: int) -> None: ...
|
|
277
|
+
def waitSync(self, sync: WebGLSync, flags: int, timeout: int) -> int: ...
|
|
278
|
+
def readBuffer(self, source: int) -> None: ...
|
|
279
|
+
def transformFeedbackVaryings(self, program: WebGLProgram, varyings: Sequence[str], buffermode: int) -> None: ...
|
|
280
|
+
def texImage3D(
|
|
281
|
+
self, target: int, level: int, internalformat: int,
|
|
282
|
+
width: int, height: int, depth: int, border: int,
|
|
283
|
+
format: int, type: int, pixels: int | bytes | memoryview | None = None,
|
|
284
|
+
) -> None: ...
|
|
285
|
+
def texImage3D(
|
|
286
|
+
self, target: int, level: int, internalformat: int,
|
|
287
|
+
width: int, height: int, depth: int, border: int,
|
|
288
|
+
format: int, type: int, source: Any,
|
|
289
|
+
) -> None: ... # Overload for image sources
|
|
290
|
+
def texStorage3D(self, target: int, levels: int, internalformat: int, width: int, height: int, depth: int) -> None: ...
|
|
291
|
+
def texSubImage3D(
|
|
292
|
+
self, target: int, level: int, xoffset: int, yoffset: int,
|
|
293
|
+
zoffset: int, width: int, height: int, depth: int, format: int,
|
|
294
|
+
type: int, pixels: int | bytes | memoryview | None = None,
|
|
295
|
+
) -> None: ...
|
|
296
|
+
def texSubImage3D(
|
|
297
|
+
self, target: int, level: int, xoffset: int, yoffset: int,
|
|
298
|
+
zoffset: int, width: int, height: int, depth: int, format: int,
|
|
299
|
+
type: int, source: Any,
|
|
300
|
+
) -> None: ... # Overload for image sources
|
|
301
|
+
def framebufferTextureLayer(self,
|
|
302
|
+
target: int,
|
|
303
|
+
attachment: int,
|
|
304
|
+
texture: WebGLTexture | None,
|
|
305
|
+
level: int,
|
|
306
|
+
layer: int,
|
|
307
|
+
) -> None: ...
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"""Group multiple small images into larger Textures.
|
|
2
2
|
|
|
3
3
|
This module provides classes to efficiently pack small images into larger Textures.
|
|
4
|
-
This can have major performance benefits when
|
|
4
|
+
This can have major performance benefits when dealing with a large number of images.
|
|
5
5
|
|
|
6
6
|
:py:class:`~pyglet.image.atlas.TextureAtlas` maintains one texture; :py:class:`TextureBin`
|
|
7
7
|
manages a collection of atlases of a given size. :py:class:`TextureArrayBin` works similarly
|
|
8
|
-
except for :py:class:`~pyglet.
|
|
8
|
+
except for :py:class:`~pyglet.graphics.TextureArray`s instead of altases.
|
|
9
9
|
|
|
10
|
-
This module is used internally by the :py:mod
|
|
10
|
+
This module is used internally by the :py:mod:`~pyglet.resource` module.
|
|
11
11
|
|
|
12
12
|
Example usage::
|
|
13
13
|
|
|
@@ -21,8 +21,8 @@ Example usage::
|
|
|
21
21
|
boat_texture = bin.add(boat_image)
|
|
22
22
|
|
|
23
23
|
The result of :py:meth:`TextureBin.add` is a :py:class:`TextureRegion`
|
|
24
|
-
containing the image. Once added, an image cannot be removed from a bin (or an
|
|
25
|
-
atlas); nor can a list of images be obtained from a given bin or atlas -- it is
|
|
24
|
+
containing the image. Once added, an image cannot be removed from a bin (or an
|
|
25
|
+
atlas); nor can a list of images be obtained from a given bin or atlas -- it is
|
|
26
26
|
the application's responsibility to keep track of the regions returned by the
|
|
27
27
|
``add`` methods.
|
|
28
28
|
|
|
@@ -34,18 +34,18 @@ import pyglet
|
|
|
34
34
|
|
|
35
35
|
from typing import TYPE_CHECKING
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
if TYPE_CHECKING:
|
|
38
|
-
from pyglet.image import
|
|
39
|
+
from pyglet.image import ImageData, ImageDataRegion
|
|
40
|
+
from pyglet.graphics.texture import TextureRegion, TextureArrayRegion
|
|
39
41
|
|
|
40
42
|
|
|
41
|
-
class AllocatorException(Exception):
|
|
42
|
-
"""The allocator does not have sufficient free space for the requested
|
|
43
|
-
image size."""
|
|
44
|
-
pass
|
|
43
|
+
class AllocatorException(Exception): # noqa: N818
|
|
44
|
+
"""The allocator does not have sufficient free space for the requested image size."""
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class _Strip:
|
|
48
|
-
__slots__ = '
|
|
48
|
+
__slots__ = 'max_height', 'x', 'y', 'y2'
|
|
49
49
|
|
|
50
50
|
def __init__(self, y: int, max_height: int) -> None:
|
|
51
51
|
self.x = 0
|
|
@@ -54,7 +54,7 @@ class _Strip:
|
|
|
54
54
|
self.y2 = y
|
|
55
55
|
|
|
56
56
|
def add(self, width: int, height: int) -> tuple[int, int]:
|
|
57
|
-
assert width > 0 and height > 0
|
|
57
|
+
assert width > 0 and height > 0 # noqa: PT018
|
|
58
58
|
assert height <= self.max_height
|
|
59
59
|
|
|
60
60
|
x, y = self.x, self.y
|
|
@@ -77,18 +77,18 @@ class Allocator:
|
|
|
77
77
|
best when rectangles are allocated of the same size, or in decreasing
|
|
78
78
|
height order.
|
|
79
79
|
"""
|
|
80
|
-
__slots__ = '
|
|
80
|
+
__slots__ = 'height', 'strips', 'used_area', 'width'
|
|
81
81
|
|
|
82
82
|
def __init__(self, width: int, height: int) -> None:
|
|
83
83
|
"""Create an ``Allocator`` of the given size."""
|
|
84
|
-
assert width > 0 and height > 0
|
|
84
|
+
assert width > 0 and height > 0 # noqa: PT018
|
|
85
85
|
self.width = width
|
|
86
86
|
self.height = height
|
|
87
87
|
self.strips = [_Strip(0, height)]
|
|
88
88
|
self.used_area = 0
|
|
89
89
|
|
|
90
90
|
def alloc(self, width: int, height: int) -> tuple[int, int]:
|
|
91
|
-
"""Get the position of a free area in the allocator of the given size
|
|
91
|
+
"""Get the position of a free area in the allocator of the given size.
|
|
92
92
|
|
|
93
93
|
If a suitable position can be found for the requested size, the position
|
|
94
94
|
will be marked as in-use and returned. (The same position will never be
|
|
@@ -110,7 +110,8 @@ class Allocator:
|
|
|
110
110
|
self.strips.append(newstrip)
|
|
111
111
|
return newstrip.add(width, height)
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
msg = f"No more space in {self} for box {width}x{height}"
|
|
114
|
+
raise AllocatorException(msg)
|
|
114
115
|
|
|
115
116
|
def get_usage(self) -> float:
|
|
116
117
|
"""Get the fraction of area already allocated.
|
|
@@ -120,8 +121,7 @@ class Allocator:
|
|
|
120
121
|
return self.used_area / float(self.width * self.height)
|
|
121
122
|
|
|
122
123
|
def get_fragmentation(self) -> float:
|
|
123
|
-
"""Get the fraction of area that's unlikely to ever be used, based on
|
|
124
|
-
current allocation behaviour.
|
|
124
|
+
"""Get the fraction of area that's unlikely to ever be used, based on current allocation behaviour.
|
|
125
125
|
|
|
126
126
|
This method is useful for debugging and profiling only.
|
|
127
127
|
"""
|
|
@@ -140,7 +140,7 @@ class TextureAtlas:
|
|
|
140
140
|
by allowing all the Images to be drawn together with a single
|
|
141
141
|
Texture bind, rather than multiple tiny Texture binds per draw.
|
|
142
142
|
|
|
143
|
-
When creating a TextureAtlas instance, a new :py:class:`~pyglet.
|
|
143
|
+
When creating a TextureAtlas instance, a new :py:class:`~pyglet.graphics.Texture`
|
|
144
144
|
object will be created at the requested size. If the maximum texture
|
|
145
145
|
size supported by the OpenGL driver is less than requested, the
|
|
146
146
|
smaller of the two will be used.
|
|
@@ -148,18 +148,18 @@ class TextureAtlas:
|
|
|
148
148
|
|
|
149
149
|
def __init__(self, width: int = 2048, height: int = 2048) -> None:
|
|
150
150
|
"""Create a Texture Atlas of the given size."""
|
|
151
|
-
max_texture_size = pyglet.
|
|
151
|
+
max_texture_size = pyglet.graphics.texture.get_max_texture_size()
|
|
152
152
|
width = min(width, max_texture_size)
|
|
153
153
|
height = min(height, max_texture_size)
|
|
154
154
|
|
|
155
|
-
self.texture = pyglet.
|
|
155
|
+
self.texture = pyglet.graphics.Texture.create(width, height)
|
|
156
156
|
self.allocator = Allocator(width, height)
|
|
157
157
|
|
|
158
|
-
def add(self, img: ImageData, border: int = 0) -> TextureRegion:
|
|
158
|
+
def add(self, img: ImageData | ImageDataRegion, border: int = 0) -> TextureRegion:
|
|
159
159
|
"""Add ImageData to the atlas.
|
|
160
160
|
|
|
161
161
|
Given :py:class:`~pyglet.image.ImageData`, add it to the Atlas and
|
|
162
|
-
return a new :py:class:`~pyglet.
|
|
162
|
+
return a new :py:class:`~pyglet.graphics.TextureRegion` object. An
|
|
163
163
|
optional ``border`` argument can be passed, which will leave the
|
|
164
164
|
specified number of blank pixels around the added ImageData. This
|
|
165
165
|
can be useful in certain situations and blend modes, where
|
|
@@ -171,14 +171,15 @@ class TextureAtlas:
|
|
|
171
171
|
no room in the atlas for the image.
|
|
172
172
|
"""
|
|
173
173
|
x, y = self.allocator.alloc(img.width + border * 2, img.height + border * 2)
|
|
174
|
-
self.texture.
|
|
174
|
+
self.texture.bind()
|
|
175
|
+
self.texture.upload(img, x + border, y + border, 0)
|
|
175
176
|
return self.texture.get_region(x + border, y + border, img.width, img.height)
|
|
176
177
|
|
|
177
178
|
|
|
178
179
|
class TextureBin:
|
|
179
180
|
"""Collection of TextureAtlases.
|
|
180
181
|
|
|
181
|
-
:py:class:`~pyglet.
|
|
182
|
+
:py:class:`~pyglet.graphics.atlas.TextureBin` maintains a collection
|
|
182
183
|
of TextureAtlases, and creates new ones as necessary to accommodate
|
|
183
184
|
adding an unbound number of Images. When one TextureAltas is full,
|
|
184
185
|
a new one is automatically created to fit the next ImageData.
|
|
@@ -186,12 +187,12 @@ class TextureBin:
|
|
|
186
187
|
|
|
187
188
|
def __init__(self, texture_width: int = 2048, texture_height: int = 2048) -> None:
|
|
188
189
|
"""Create a texture bin for holding atlases of the given size."""
|
|
189
|
-
max_texture_size = pyglet.
|
|
190
|
+
max_texture_size = pyglet.graphics.texture.get_max_texture_size()
|
|
190
191
|
self.texture_width = min(texture_width, max_texture_size)
|
|
191
192
|
self.texture_height = min(texture_height, max_texture_size)
|
|
192
193
|
self.atlases = []
|
|
193
194
|
|
|
194
|
-
def add(self, img: ImageData |
|
|
195
|
+
def add(self, img: ImageData | ImageDataRegion, border: int = 0) -> TextureRegion:
|
|
195
196
|
"""Add an image into this texture bin.
|
|
196
197
|
|
|
197
198
|
This method calls :py:meth:`~TextureAtlas.add` for the first atlas
|
|
@@ -224,8 +225,8 @@ class TextureArrayBin:
|
|
|
224
225
|
"""
|
|
225
226
|
|
|
226
227
|
def __init__(self, texture_width: int = 2048, texture_height: int = 2048, max_depth: int | None = None) -> None:
|
|
227
|
-
max_texture_size = pyglet.
|
|
228
|
-
self.max_depth = max_depth or pyglet.
|
|
228
|
+
max_texture_size = pyglet.graphics.texture.get_max_texture_size()
|
|
229
|
+
self.max_depth = max_depth or pyglet.graphics.texture.get_max_array_texture_layers()
|
|
229
230
|
self.texture_width = min(texture_width, max_texture_size)
|
|
230
231
|
self.texture_height = min(texture_height, max_texture_size)
|
|
231
232
|
self.arrays = []
|
|
@@ -233,7 +234,7 @@ class TextureArrayBin:
|
|
|
233
234
|
def add(self, img: ImageData) -> TextureArrayRegion:
|
|
234
235
|
"""Add an image into this texture array bin.
|
|
235
236
|
|
|
236
|
-
This method calls :py:meth:`~pyglet.
|
|
237
|
+
This method calls :py:meth:`~pyglet.graphics.TextureArray.add` for the first
|
|
237
238
|
array that has room for the image.
|
|
238
239
|
|
|
239
240
|
``TextureArraySizeExceeded`` is raised if the image exceeds the dimensions of
|
|
@@ -242,11 +243,11 @@ class TextureArrayBin:
|
|
|
242
243
|
try:
|
|
243
244
|
array = self.arrays[-1]
|
|
244
245
|
return array.add(img)
|
|
245
|
-
except pyglet.
|
|
246
|
+
except pyglet.graphics.texture.TextureArrayDepthExceeded:
|
|
246
247
|
pass
|
|
247
248
|
except IndexError:
|
|
248
249
|
pass
|
|
249
250
|
|
|
250
|
-
array = pyglet.
|
|
251
|
+
array = pyglet.graphics.texture.TextureArray.create(self.texture_width, self.texture_height, max_depth=self.max_depth)
|
|
251
252
|
self.arrays.append(array)
|
|
252
253
|
return array.add(img)
|