Skip to content

Commit

Permalink
Add shaders loading function and add line shader to MANIFEST.in
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcCote committed Nov 8, 2018
1 parent a6bd251 commit c239c7c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -16,3 +16,4 @@ include fury/_version.py
include fury/data/files/*.json
include fury/data/files/*.log.gz
include fury/data/files/*.pkl
include fury/shaders/*.geom
6 changes: 2 additions & 4 deletions fury/actor.py
Expand Up @@ -4,6 +4,7 @@
import vtk
from vtk.util import numpy_support

import fury.shaders
from fury.colormap import colormap_lookup_table, create_colormap
from fury.utils import (lines_to_vtk_polydata, set_input, apply_affine,
numpy_to_vtk_points, numpy_to_vtk_colors,
Expand Down Expand Up @@ -522,10 +523,7 @@ def line(lines, colors=None, opacity=1, linewidth=1,
poly_mapper.Update()

if depth_cue:
geom_shader_file = open("fury/shaders/line.geom", "r")
geom_shader_code = geom_shader_file.read()

poly_mapper.SetGeometryShaderCode(geom_shader_code)
poly_mapper.SetGeometryShaderCode(fury.shaders.load("line.geom"))

@vtk.calldata_type(vtk.VTK_OBJECT)
def vtkShaderCallback(caller, event, calldata=None):
Expand Down
12 changes: 12 additions & 0 deletions fury/shaders/__init__.py
@@ -0,0 +1,12 @@
"""Read shader files."""

from os.path import join as pjoin, dirname

SHADERS_DIR = pjoin(dirname(__file__))

def load(filename):
with open(pjoin(SHADERS_DIR, filename)) as shader_file:
return shader_file.read()


__all__ = ['SHADERS_DIR', 'load']
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -14,7 +14,7 @@
python3 --version
This may be due to an out-of-date pip.
This may be due to an out-of-date pip.
Make sure you have pip >= 9.0.1.
Upgrade pip like so:
Expand Down Expand Up @@ -55,6 +55,7 @@
"fury/data/files/*.json",
"fury/data/files/*.log.gz",
"fury/data/files/*.pkl"
"fury/shaders/*.geom"
]
},
install_requires=['numpy>=1.7.1',
Expand Down

0 comments on commit c239c7c

Please sign in to comment.