Skip to content

load_texture: extra arguments for wrap and filter #2383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading