def test_setting_subdata(self): data = np.zeros(100, np.float32) buffer = Buffer(target=gl.GL_ARRAY_BUFFER) # Set subdata when no data is set with self.assertRaises(RuntimeError): buffer.set_subdata(0, data) # Set nbytes and try again buffer.set_nbytes(data.nbytes) buffer.set_subdata(0, data) # Subpart buffer.set_subdata(0, data[:50]) buffer.set_subdata(50, data[50:]) # Too big with self.assertRaises(ValueError): buffer.set_subdata(1, data) # Weird with self.assertRaises(ValueError): buffer.set_subdata(-1, data) # Weirder with self.assertRaises(ValueError): buffer.set_subdata(1000000, data)
def test_setting_size(self): data = np.zeros(100, np.float32) buffer = Buffer(target=gl.GL_ARRAY_BUFFER) buffer.set_data(data) self.assertEqual(buffer.nbytes, data.nbytes) buffer.set_data( np.zeros(200, np.float32)) self.assertEqual(buffer.nbytes, 200*4) buffer.set_nbytes(10) self.assertEqual(buffer.nbytes, 10) buffer.set_nbytes(20) self.assertEqual(buffer.nbytes, 20)