Skip to content

Commit d4086f2

Browse files
authored
load_texture: extra arguments for wrap and filter (#2383)
* load_texture: extra arguments for wrap and filter * Import order
1 parent 553894e commit d4086f2

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

arcade/context.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from arcade.gl.framebuffer import Framebuffer
2323
from arcade.gl.program import Program
2424
from arcade.gl.texture import Texture2D
25+
from arcade.gl.types import PyGLenum
2526
from arcade.gl.vertex_array import Geometry
2627
from arcade.texture_atlas import DefaultTextureAtlas, TextureAtlasBase
2728

@@ -451,8 +452,12 @@ def load_texture(
451452
path: str | Path,
452453
*,
453454
flip: bool = True,
455+
wrap_x: PyGLenum | None = None,
456+
wrap_y: PyGLenum | None = None,
457+
filter: tuple[PyGLenum, PyGLenum] | None = None,
454458
build_mipmaps: bool = False,
455459
internal_format: int | None = None,
460+
immutable: bool = False,
456461
compressed: bool = False,
457462
) -> Texture2D:
458463
"""
@@ -479,6 +484,12 @@ def load_texture(
479484
Path to texture
480485
flip:
481486
Flips the image upside down. Default is ``True``.
487+
wrap_x:
488+
The wrap mode for the x-axis. Default is ``None``.
489+
wrap_y:
490+
The wrap mode for the y-axis. Default is ``None``.
491+
filter:
492+
The min and mag filter. Default is ``None``.
482493
build_mipmaps:
483494
Build mipmaps for the texture. Default is ``False``.
484495
internal_format (optional):
@@ -501,7 +512,11 @@ def load_texture(
501512
image.size,
502513
components=4,
503514
data=image.convert("RGBA").tobytes(),
515+
wrap_x=wrap_x,
516+
wrap_y=wrap_y,
517+
filter=filter,
504518
internal_format=internal_format,
519+
immutable=immutable,
505520
compressed=compressed,
506521
)
507522
image.close()

arcade/examples/gl/bindless_texture.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,12 @@ def __init__(self):
151151

152152
# Load enough textures to cover for each point/sprite
153153
for i in range(16 * 9):
154-
texture = self.ctx.load_texture(next(resource_cycle))
155-
texture.wrap_x = self.ctx.CLAMP_TO_EDGE
156-
texture.wrap_y = self.ctx.CLAMP_TO_EDGE
154+
texture = self.ctx.load_texture(
155+
next(resource_cycle),
156+
immutable=True,
157+
wrap_x=self.ctx.CLAMP_TO_EDGE,
158+
wrap_y=self.ctx.CLAMP_TO_EDGE,
159+
)
157160
# Make sure we keep a reference to the texture to avoid GC
158161
self.textures.append(texture)
159162
# Create a texture handle and make it resident.

0 commit comments

Comments
 (0)