Skip to content

Commit

Permalink
load_texture: extra arguments for wrap and filter (#2383)
Browse files Browse the repository at this point in the history
* load_texture: extra arguments for wrap and filter

* Import order
  • Loading branch information
einarf authored Oct 2, 2024
1 parent 553894e commit d4086f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 15 additions & 0 deletions arcade/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from arcade.gl.framebuffer import Framebuffer
from arcade.gl.program import Program
from arcade.gl.texture import Texture2D
from arcade.gl.types import PyGLenum
from arcade.gl.vertex_array import Geometry
from arcade.texture_atlas import DefaultTextureAtlas, TextureAtlasBase

Expand Down Expand Up @@ -451,8 +452,12 @@ def load_texture(
path: str | Path,
*,
flip: bool = True,
wrap_x: PyGLenum | None = None,
wrap_y: PyGLenum | None = None,
filter: tuple[PyGLenum, PyGLenum] | None = None,
build_mipmaps: bool = False,
internal_format: int | None = None,
immutable: bool = False,
compressed: bool = False,
) -> Texture2D:
"""
Expand All @@ -479,6 +484,12 @@ def load_texture(
Path to texture
flip:
Flips the image upside down. Default is ``True``.
wrap_x:
The wrap mode for the x-axis. Default is ``None``.
wrap_y:
The wrap mode for the y-axis. Default is ``None``.
filter:
The min and mag filter. Default is ``None``.
build_mipmaps:
Build mipmaps for the texture. Default is ``False``.
internal_format (optional):
Expand All @@ -501,7 +512,11 @@ def load_texture(
image.size,
components=4,
data=image.convert("RGBA").tobytes(),
wrap_x=wrap_x,
wrap_y=wrap_y,
filter=filter,
internal_format=internal_format,
immutable=immutable,
compressed=compressed,
)
image.close()
Expand Down
9 changes: 6 additions & 3 deletions arcade/examples/gl/bindless_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,12 @@ def __init__(self):

# Load enough textures to cover for each point/sprite
for i in range(16 * 9):
texture = self.ctx.load_texture(next(resource_cycle))
texture.wrap_x = self.ctx.CLAMP_TO_EDGE
texture.wrap_y = self.ctx.CLAMP_TO_EDGE
texture = self.ctx.load_texture(
next(resource_cycle),
immutable=True,
wrap_x=self.ctx.CLAMP_TO_EDGE,
wrap_y=self.ctx.CLAMP_TO_EDGE,
)
# Make sure we keep a reference to the texture to avoid GC
self.textures.append(texture)
# Create a texture handle and make it resident.
Expand Down

0 comments on commit d4086f2

Please sign in to comment.