Only bind attribute if something in the buffer
@@ -172,6 +172,7 @@ impl Program
pub fn use_attribute_float_divisor(&self, buffer: &buffer::VertexBuffer, attribute_name: &str, divisor: usize) -> Result<(), Error>
{
+ if buffer.count() > 0 {
buffer.bind();
let loc = self.location(&attribute_name)?;
self.gl.enable_vertex_attrib_array(loc);
@@ -179,6 +180,7 @@ impl Program
self.gl.vertex_attrib_divisor(loc, divisor as u32);
self.gl.unbind_buffer(consts::ARRAY_BUFFER);
self.gl.unuse_program();
+ }
Ok(())
}
@@ -190,6 +192,7 @@ impl Program
pub fn use_attribute_vec2_float_divisor(&self, buffer: &buffer::VertexBuffer, attribute_name: &str, divisor: usize) -> Result<(), Error>
{
+ if buffer.count() > 0 {
buffer.bind();
let loc = self.location(&attribute_name)?;
self.gl.enable_vertex_attrib_array(loc);
@@ -197,6 +200,7 @@ impl Program
self.gl.vertex_attrib_divisor(loc, divisor as u32);
self.gl.unbind_buffer(consts::ARRAY_BUFFER);
self.gl.unuse_program();
+ }
Ok(())
}
@@ -208,6 +212,7 @@ impl Program
pub fn use_attribute_vec3_float_divisor(&self, buffer: &buffer::VertexBuffer, attribute_name: &str, divisor: usize) -> Result<(), Error>
{
+ if buffer.count() > 0 {
buffer.bind();
let loc = self.location(&attribute_name)?;
self.gl.enable_vertex_attrib_array(loc);
@@ -215,6 +220,7 @@ impl Program
self.gl.vertex_attrib_divisor(loc, divisor as u32);
self.gl.unbind_buffer(consts::ARRAY_BUFFER);
self.gl.unuse_program();
+ }
Ok(())
}
