Skip to content

Commit d12f5d9

Browse files
authored
TextureArray Support (#2447)
* Initial work * Fixes + tests + docs * Tweaks * Add texture_array to doctree
1 parent f8755e2 commit d12f5d9

File tree

8 files changed

+993
-2
lines changed

8 files changed

+993
-2
lines changed

arcade/gl/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from .buffer import Buffer
2626
from .vertex_array import Geometry, VertexArray
2727
from .texture import Texture2D
28+
from .texture_array import TextureArray
2829
from .sampler import Sampler
2930
from .framebuffer import Framebuffer
3031
from .program import Program
@@ -43,6 +44,7 @@
4344
"ShaderException",
4445
"VertexArray",
4546
"Texture2D",
47+
"TextureArray",
4648
"Sampler",
4749
"geometry",
4850
]

arcade/gl/context.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from .query import Query
3333
from .sampler import Sampler
3434
from .texture import Texture2D
35+
from .texture_array import TextureArray
3536
from .types import BufferDescription, GLenumLike, PyGLenum
3637
from .vertex_array import Geometry
3738

@@ -1069,6 +1070,40 @@ def texture(
10691070
compressed_data=compressed_data,
10701071
)
10711072

1073+
def texture_array(
1074+
self,
1075+
size: Tuple[int, int, int],
1076+
*,
1077+
components: int = 4,
1078+
dtype: str = "f1",
1079+
data: BufferProtocol | None = None,
1080+
wrap_x: PyGLenum | None = None,
1081+
wrap_y: PyGLenum | None = None,
1082+
filter: Tuple[PyGLenum, PyGLenum] | None = None,
1083+
) -> TextureArray:
1084+
"""
1085+
Create a 2D Texture Array.
1086+
1087+
This is a 2D texture with multiple layers. This is useful for
1088+
storing multiple textures in a single texture object. This can
1089+
be used for texture atlases or storing multiple frames of an
1090+
animation in a single texture or equally sized tile textures.
1091+
1092+
Note that ``size`` is a 3-tuple where the last value is the number of layers.
1093+
1094+
See :py:meth:`~arcade.gl.Context.texture` for arguments.
1095+
"""
1096+
return TextureArray(
1097+
self,
1098+
size,
1099+
components=components,
1100+
dtype=dtype,
1101+
data=data,
1102+
wrap_x=wrap_x,
1103+
wrap_y=wrap_y,
1104+
filter=filter,
1105+
)
1106+
10721107
def depth_texture(
10731108
self, size: Tuple[int, int], *, data: BufferProtocol | None = None
10741109
) -> Texture2D:

arcade/gl/texture.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,8 @@ def write(self, data: BufferOrBufferProtocol, level: int = 0, viewport=None) ->
648648
level:
649649
The texture level to write
650650
viewport:
651-
The area of the texture to write. 2 or 4 component tuple
651+
The area of the texture to write. 2 or 4 component tuple.
652+
(x, y, w, h) or (w, h). Default is the full texture.
652653
"""
653654
# TODO: Support writing to layers using viewport + alignment
654655
if self._samples > 0:

0 commit comments

Comments
 (0)