Skip to content

Commit d55d315

Browse files
committed
Fix bounding box rendering with new uniforms
1 parent cc74bbe commit d55d315

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

demosys/scene/mesh.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ def draw(self, proj_mat, view_mat):
3333
self.mesh_shader.draw(self, proj_mat, view_mat)
3434

3535
def draw_bbox(self, proj_matrix, view_matrix, shader, vao):
36-
vao.bind(shader)
37-
shader.uniform_mat4("m_proj", proj_matrix)
38-
shader.uniform_mat4("m_mv", view_matrix)
39-
shader.uniform_3fv("bb_min", self.bbox_min)
40-
shader.uniform_3fv("bb_max", self.bbox_max)
41-
shader.uniform_3fv("color", [0.75, 0.75, 0.75])
42-
vao.draw()
36+
shader.uniform("m_proj", proj_matrix.astype('f4').tobytes())
37+
shader.uniform("m_mv", view_matrix.astype('f4').tobytes())
38+
shader.uniform("bb_min", self.bbox_min.astype('f4').tobytes())
39+
shader.uniform("bb_max", self.bbox_max.astype('f4').tobytes())
40+
shader.uniform("color", (0.75, 0.75, 0.75))
41+
vao.draw(shader)
4342

4443
def add_attribute(self, attr_type, name, components):
4544
"""

demosys/scene/scene.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ def draw(self, m_proj, m_mv):
3939
def draw_bbox(self, m_proj, m_mv, all=True):
4040
"""Draw scene and mesh bounding boxes"""
4141
# Scene bounding box
42-
self.bbox_vao.bind(self.bbox_shader)
43-
self.bbox_shader.uniform_mat4("m_proj", m_proj)
44-
self.bbox_shader.uniform_mat4("m_mv", m_mv)
45-
self.bbox_shader.uniform_3fv("bb_min", self.bbox_min)
46-
self.bbox_shader.uniform_3fv("bb_max", self.bbox_max)
47-
self.bbox_shader.uniform_3fv("color", [1.0, 0.0, 0.0])
48-
self.bbox_vao.draw()
42+
self.bbox_shader.uniform("m_proj", m_proj.astype('f4').tobytes())
43+
self.bbox_shader.uniform("m_mv", m_mv.astype('f4').tobytes())
44+
self.bbox_shader.uniform("bb_min", self.bbox_min.astype('f4').tobytes())
45+
self.bbox_shader.uniform("bb_max", self.bbox_max.astype('f4').tobytes())
46+
self.bbox_shader.uniform("color", (1.0, 0.0, 0.0))
47+
self.bbox_vao.draw(self.bbox_shader)
4948

5049
if not all:
5150
return

0 commit comments

Comments
 (0)