Skip to content

Commit

Permalink
Merge branch 'shader_experimental' of github.com:pvcraven/arcade into…
Browse files Browse the repository at this point in the history
… shader_experimental
  • Loading branch information
pvcraven committed Apr 8, 2020
2 parents ab0375d + 95b524b commit cdf42c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions arcade/experimental/postprocessing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from pyglet import gl
from typing import Tuple
from arcade import shader
from arcade.experimental import geometry
Expand Down Expand Up @@ -54,7 +55,7 @@ class GaussianBlurHorizontal(PostProcessing):
def __init__(self, size: Tuple[int, int], kernel_size=5):
super().__init__(size)
self._kernel_size = kernel_size
self._fbo = shader.framebuffer(color_attachments=shader.Texture(size, 3))
self._fbo = shader.framebuffer(color_attachments=shader.texture(size, 3, wrap_x=gl.GL_CLAMP_TO_EDGE, wrap_y=gl.GL_CLAMP_TO_EDGE))
self._program = shader.load_program(
vertex_shader_filename=SHADER_PATH / 'texture_ndc_vs.glsl',
fragment_shader_filename=SHADER_PATH / 'gaussian_blurx_fs.glsl',
Expand All @@ -74,7 +75,7 @@ class GaussianBlurVertical(PostProcessing):
def __init__(self, size: Tuple[int, int], kernel_size=5):
super().__init__(size)
self._kernel_size = kernel_size
self._fbo = shader.framebuffer(color_attachments=shader.Texture(size, 3))
self._fbo = shader.framebuffer(color_attachments=shader.texture(size, 3, wrap_x=gl.GL_CLAMP_TO_EDGE, wrap_y=gl.GL_CLAMP_TO_EDGE))
self._program = shader.load_program(
vertex_shader_filename=SHADER_PATH / 'texture_ndc_vs.glsl',
fragment_shader_filename=SHADER_PATH / 'gaussian_blury_fs.glsl',
Expand Down
15 changes: 13 additions & 2 deletions arcade/shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,14 +688,25 @@ def __repr__(self):
self.texture_id.value, self.width, self.height, self._components)


def texture(size: Tuple[int, int], components: int, data=None) -> Texture:
def texture(size: Tuple[int, int], components: int, data=None,
wrap_x: gl.GLenum = None, wrap_y: gl.GLenum = None, filter: Tuple[gl.GLenum, gl.GLenum] = None) -> Texture:
"""Create a Texture.
Wrap modes: ``GL_REPEAT``, ``GL_MIRRORED_REPEAT``, ``GL_CLAMP_TO_EDGE``, ``GL_CLAMP_TO_BORDER``
Minifying filters: ``GL_NEAREST``, ``GL_LINEAR``, ``GL_NEAREST_MIPMAP_NEAREST``, ``GL_LINEAR_MIPMAP_NEAREST``
``GL_NEAREST_MIPMAP_LINEAR``, ``GL_LINEAR_MIPMAP_LINEAR``
Magnifying filters: ``GL_NEAREST``, ``GL_LINEAR``
:param Tuple[int, int] size: The size of the texture
:param int components: Number of components (1: R, 2: RG, 3: RGB, 4: RGBA)
:param buffer data: The texture data (optional)
:param GLenum wrap_x: How the texture wraps in x direction
:param GLenum wrap_x: How the texture wraps in y direction
:param Tuple[GLenum, GLenum] filter: Minification and magnification filter
"""
return Texture(size, components, data)
return Texture(size, components, data, wrap_x=wrap_x, wrap_y=wrap_y, filter=filter)


class Framebuffer:
Expand Down

0 comments on commit cdf42c0

Please sign in to comment.