Пример #1
0
	def test_buffer_unmap_invalidates(self):
		point = dtype([('position', pos), ('UV', uv)])
		buf = Buffer()
		buf.target = GL.GL_ARRAY_BUFFER
		buf[...] = numpy.zeros((20, 5), dtype=point)

		m = buf.map()
		buf.unmap()

		with self.assertRaises(IndexError):
			m[0]
		with self.assertRaises(IndexError):
			m[0] = 1
Пример #2
0
	def test_subbuffer_map(self):
		point = dtype([('position', pos), ('UV', uv)])
		buf = Buffer()
		with buf.bind(GL.GL_ARRAY_BUFFER):
			buf[...] = numpy.zeros((20, 5), dtype=point)

			m = buf[0].map()
		self.assertTrue(buf.mapped)
		np_test.assert_equal(m, numpy.zeros(5, dtype=point))
		m[0] = numpy.ones(1, dtype=point)
		with buf.bind(GL.GL_ARRAY_BUFFER):
			buf.unmap()
		self.assertFalse(buf.mapped)
		
		with buf.bind(GL.GL_ARRAY_BUFFER):
			m = buf[0].map()
		np_test.assert_equal(m[0], numpy.ones(1, dtype=point))
		np_test.assert_equal(m[1:], numpy.zeros(4, dtype=point))
		with buf.bind(GL.GL_ARRAY_BUFFER):
			buf.unmap()