Skip to content

Commit aa8a95e

Browse files
committed
Better sanity checking of map_buffer inputs
1 parent 9338bc3 commit aa8a95e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

demosys/opengl/vao.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,17 @@ def map_buffer(self, vbo, attrib_name, components):
142142
:param attrib_name: Name of the attribute in the shader
143143
:param components: Number of components (for example 3 for a x, y, x position)
144144
"""
145-
ab = self.array_buffer_map[id(vbo)]
145+
if not isinstance(vbo, VBO):
146+
raise VAOError("vbo parameter must be an OpenGL.arrays.vbo.VBO instance")
147+
148+
ab = self.array_buffer_map.get(id(vbo))
149+
if not ab:
150+
raise VAOError("VBO {} not previously added as an array map. "
151+
"Forgot to call add_arrray_buffer(..)?".format(id(vbo)))
146152

147153
# FIXME: Determine byte size based on data type in VBO
148154
offset = ab.stride
149-
ab.stride += components * 4
155+
ab.stride += components * type_size(ab.format)
150156
am = ArrayMapping(ab, attrib_name, components, offset)
151157

152158
self.array_mapping.append(am)

0 commit comments

Comments
 (0)