Пример #1
0
	def test_flush(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.map(GL.GL_MAP_WRITE_BIT | GL.GL_MAP_FLUSH_EXPLICIT_BIT)
			m.flush()
Пример #2
0
	def test_buffer_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.map()
		self.assertTrue(buf.mapped)
		np_test.assert_equal(m, numpy.zeros((20, 5), dtype=point))
		m[0] = 1
		with buf.bind(GL.GL_ARRAY_BUFFER):
			buf.unmap()
		self.assertFalse(buf.mapped)

		with buf.bind(GL.GL_ARRAY_BUFFER):
			m = buf.map(GL.GL_MAP_READ_BIT)
		np_test.assert_equal(m[0], numpy.ones(5, dtype=point))
		np_test.assert_equal(m[1:], numpy.zeros((19, 5), dtype=point))
		with buf.bind(GL.GL_ARRAY_BUFFER):
			buf.unmap()
Пример #3
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