Skip to content

Commit 43a24bc

Browse files
committed
Update example in README
1 parent a24b6e6 commit 43a24bc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

README.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,18 @@ effect.py
107107

108108
.. code:: python
109109
110-
from demosys.effects import Effect
110+
from demosys.effects import effect
111111
from demosys.opengl import geometry, FBO
112112
from OpenGL import GL
113113
114-
class CubeEffect(Effect):
114+
class CubeEffect(effect.Effect):
115115
"""Rotating cube with UVs and normals"""
116116
def init(self):
117117
self.shader = self.get_shader('cube/cube.glsl')
118118
self.texture = self.get_texture('cube/texture.png')
119-
self.cube = geometry.cube(2.0)
119+
self.cube = geometry.cube(2.0, 2.0, 2.0)
120120
121+
@effect.bind_target
121122
def draw(self, time, target):
122123
GL.glEnable(GL.GL_DEPTH_TEST)
123124
@@ -128,11 +129,11 @@ effect.py
128129
proj_m = self.create_projection(fov=60.0)
129130
130131
# The VAO and shader will do a a little dance and agree on attributes
131-
self.cube.bind(self.shader)
132-
self.cube_shader.uniform_mat4("ProjM", proj_m)
133-
self.cube_shader.uniform_mat4("ModelViewM", mv_m)
134-
self.cube_shader.uniform_mat3("NormalM", normal_m)
135-
self.cube_shader.uniform_sampler_2d(0, "texture0", self.texture)
132+
with self.cube.bind(self.shader) as shader:
133+
shader.uniform_mat4("m_proj", proj_m)
134+
shader.uniform_mat4("m_mv", mv_m)
135+
shader.uniform_mat3("m_normal", normal_m)
136+
shader.uniform_sampler_2d(0, "texture0", self.texture)
136137
self.cube.draw()
137138
138139
There you go.

0 commit comments

Comments
 (0)