Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
einarf committed Nov 12, 2024
1 parent 69a51fd commit 54e7526
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions arcade/gl/texture_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def __init__(

gl.glBindTexture(self._target, self._glo)

self._texture_2d(data)
self._texture_2d_array(data)

# Only set texture parameters on non-multisample textures
if self._samples == 0:
Expand Down Expand Up @@ -207,14 +207,14 @@ def resize(self, size: tuple[int, int]):

self._width, self._height = size

self._texture_2d(None)
self._texture_2d_array(None)

def __del__(self):
# Intercept garbage collection if we are using Context.gc()
if self._ctx.gc_mode == "context_gc" and self._glo.value > 0:
self._ctx.objects.append(self)

def _texture_2d(self, data):
def _texture_2d_array(self, data):
"""Create a 2D texture"""
# Start by resolving the texture format
try:
Expand Down Expand Up @@ -884,6 +884,6 @@ def get_handle(self, resident: bool = True) -> int:
return handle

def __repr__(self) -> str:
return "<Texture glo={} size={}x{} components={}>".format(
self._glo.value, self._width, self._height, self._components
return "<TextureArray glo={} size={}x{}x{} components={}>".format(
self._glo.value, self._width, self._layers, self._height, self._components
)
5 changes: 5 additions & 0 deletions tests/unit/gl/test_gl_texture_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ def test_create_individual_layers(ctx: arcade.ArcadeContext):
ta.write(layer_4, viewport=(0, 0, 3, 4, 4))

assert ta.read() == layers.tobytes()

def test_repr(ctx: arcade.ArcadeContext):
ta = ctx.texture_array((2, 4, 6), components=1, dtype="f1")
assert repr(ta).startswith("<TextureArray")

0 comments on commit 54e7526

Please sign in to comment.