Skip to content

Commit

Permalink
Initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
einarf committed Nov 12, 2024
1 parent f8755e2 commit 735cbb7
Show file tree
Hide file tree
Showing 4 changed files with 915 additions and 1 deletion.
2 changes: 2 additions & 0 deletions arcade/gl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .buffer import Buffer
from .vertex_array import Geometry, VertexArray
from .texture import Texture2D
from .texture_array import TextureArray
from .sampler import Sampler
from .framebuffer import Framebuffer
from .program import Program
Expand All @@ -43,6 +44,7 @@
"ShaderException",
"VertexArray",
"Texture2D",
"TextureArray",
"Sampler",
"geometry",
]
35 changes: 35 additions & 0 deletions arcade/gl/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from .query import Query
from .sampler import Sampler
from .texture import Texture2D
from .texture_array import TextureArray
from .types import BufferDescription, GLenumLike, PyGLenum
from .vertex_array import Geometry

Expand Down Expand Up @@ -1069,6 +1070,40 @@ def texture(
compressed_data=compressed_data,
)

def texture_array(
self,
size: Tuple[int, int, int],
*,
components: int = 4,
dtype: str = "f1",
data: BufferProtocol | None = None,
wrap_x: PyGLenum | None = None,
wrap_y: PyGLenum | None = None,
filter: Tuple[PyGLenum, PyGLenum] | None = None,
) -> TextureArray:
"""
Create a 2D Texture Array.
This is a 2D texture with multiple layers. This is useful for
storing multiple textures in a single texture object. This can
be used for texture atlases or storing multiple frames of an
animation in a single texture or equally sized tile textures.
Note that ``size`` is a 3-tuple where the last value is the number of layers.
See :py:meth:`~arcade.gl.Context.texture` for arguments.
"""
return TextureArray(
self,
size,
components=components,
dtype=dtype,
data=data,
wrap_x=wrap_x,
wrap_y=wrap_y,
filter=filter,
)

def depth_texture(
self, size: Tuple[int, int], *, data: BufferProtocol | None = None
) -> Texture2D:
Expand Down
3 changes: 2 additions & 1 deletion arcade/gl/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ def write(self, data: BufferOrBufferProtocol, level: int = 0, viewport=None) ->
level:
The texture level to write
viewport:
The area of the texture to write. 2 or 4 component tuple
The area of the texture to write. 2 or 4 component tuple.
(x, y, w, h) or (w, h). Default is the full texture.
"""
# TODO: Support writing to layers using viewport + alignment
if self._samples > 0:
Expand Down
Loading

0 comments on commit 735cbb7

Please sign in to comment.