golem icon indicating copy to clipboard operation
golem copied to clipboard

Keep track of smallest and largest value in Buffer

Open knokko opened this issue 4 years ago • 0 comments

Currently, the ShaderProgram.draw method is unsafe because the user is responsible for ensuring that all elements in the ElementBuffer are valid indices into the VertexBuffer.

But, if the (Element)Buffer would keep track of its smallest and largest elements, the draw implementation could easily check that all indices are valid before drawing (it would be a matter of checking that the smallest element is at least 0 and the largest element is smaller than the number of vertices).

This would allow the draw method to be safe. Besides, it would prevent a lot of debugging work when the elements are not valid indices into the VertexBuffer.

knokko avatar Mar 07 '21 11:03 knokko