Skip to content

Commit 3b6944d

Browse files
committed
Create effect should use the correct resource structure
1 parent ef0cfe8 commit 3b6944d

File tree

6 files changed

+32
-16
lines changed

6 files changed

+32
-16
lines changed

TODO.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

22
## TODO
33

4-
- Split up README into several files
5-
- Properly verify all settings
64
- Write documentation (readthedocs)
5+
- Effects
6+
- OpenGL stuff
7+
- Properly verify all settings
78
- Make EffectControllers
89
- SingleEffectController
910
- TrackSystemEffectController
@@ -27,4 +28,4 @@ Generic Data:
2728
- FBOs
2829
- Textures
2930
- Settings entry for key bindings
30-
- Look into using freetype
31+
- Look into using freetype or some kind of fonts

demosys/core/management/commands/createeffect.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,33 @@ def handle(self, *args, **options):
2323
return
2424

2525
os.mkdir(name)
26-
os.mkdir(os.path.join(name, 'textures'))
27-
os.mkdir(os.path.join(name, 'shaders'))
26+
os.makedirs(os.path.join(name, 'textures', name))
27+
os.makedirs(os.path.join(name, 'shaders', name))
2828

2929
# Create effect.py
3030
with open(os.path.join(name, 'effect.py'), 'w') as fd:
31-
fd.write(default_effect())
31+
fd.write(default_effect(name))
3232

3333
# Create default.glsl
34-
with open(os.path.join(name, 'shaders', 'default.glsl'), 'w') as fd:
34+
with open(os.path.join(name, 'shaders', name, 'default.glsl'), 'w') as fd:
3535
fd.write(default_shader())
3636

3737

38-
def default_effect():
38+
def default_effect(name):
3939
file_path = os.path.join(root_path(), 'effects/default/effect.py')
40-
return open(file_path, 'r').read()
40+
with open(file_path, 'r') as fd:
41+
data = fd.read()
42+
43+
data = data.replace('"default/default.glsl"', '"{}/default.glsl"'.format(name))
44+
return data
4145

4246

4347
def default_shader():
44-
file_path = os.path.join(root_path(), 'effects/default/shaders/default.glsl')
45-
return open(file_path, 'r').read()
48+
file_path = os.path.join(root_path(), 'effects/default/shaders/default/default.glsl')
49+
with open(file_path, 'r') as fd:
50+
data = fd.read()
51+
52+
return data
4653

4754

4855
def root_path():

demosys/effects/default/effect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from demosys.effects import effect
22
from demosys.opengl import geometry
33
from OpenGL import GL
4-
from pyrr import matrix44
4+
# from pyrr import matrix44
55

66

77
class DefaultEffect(effect.Effect):
88
"""Generated default efffect"""
99
def __init__(self):
10-
self.shader = self.get_shader("default.glsl")
10+
self.shader = self.get_shader("default/default.glsl")
1111
self.cube = geometry.cube(4.0, 4.0, 4.0)
1212

1313
@effect.bind_target
@@ -16,7 +16,7 @@ def draw(self, time, frametime, target):
1616

1717
# Rotate and translate
1818
m_mv = self.create_transformation(rotation=(time * 1.2, time * 2.1, time * 0.25),
19-
translation=(0.0, 0.0, -6.0))
19+
translation=(0.0, 0.0, -8.0))
2020

2121
# Apply the rotation and translation from the system camera
2222
# m_mv = matrix44.multiply(m_mv, self.sys_camera.view_matrix)

docs/source/quickstart.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ We should now have the folloing structure:
102102
├── cube
103103
│   ├── effect.py
104104
│   ├── shaders
105-
│   │   └── default.glsl
105+
│   │   └── cube
106+
│   │   └── default.glsl
106107
│   └── textures
108+
│   └── cube
107109
└── settings.py
108110
manage.py
109111
@@ -112,6 +114,12 @@ The ``cube`` directory is a template for an effect:
112114
- A local ``shaders`` directory for glsl shaders specific to the effect
113115
- A local ``textures`` directory for texture files specific to the effect
114116

117+
Notice that the ``shaders`` and ``textures`` directory also has a sub-folder with the same name
118+
as the effect. This is because these directories are added to a global virtual directory
119+
and the only way to make these resources unique is to put it in a directory that is *hopefully* unique.
120+
121+
This can of course be used in creative ways to also override resources on purpose.
122+
115123
For the effect to be recognized by the system we need to add it ``EFFECTS`` in
116124
``settings.py``.
117125

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="demosys-py",
5-
version="0.3.5",
5+
version="0.3.6",
66
description="Modern OpenGL 4.1+ Prototype Framework inspired by Django",
77
long_description=open('README.rst').read(),
88
url="https://github.com/Contraz/demosys-py",

0 commit comments

Comments
 (0)