/usr/share/pyshared/glitch/limbo/vertices.py is in python-glitch 0.6-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | """Draw vertices from numpy arrays."""
import OpenGL.GL as gl
import OpenGL.arrays.vbo as vbo
import glitch
class DrawVertexArray(glitch.Node):
def __init__(self, mode, array):
glitch.Node.__init__(self)
self.mode = mode
self.array = array
assert self.array.shape[1] == 2
if mode == gl.GL_LINES:
assert self.array.shape[0] % 2 == 0
# This is 2 * sizeof(float).
self.stride = 8
elif mode == gl.GL_TRIANGLES:
assert self.array.shape[0] % 3 == 0
self.stride = 8
else:
raise ValueError
def draw(self, ctx):
buffer = vbo.VBO(self.array)
buffer.bind()
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
# Three coordinates per vertex, with a stride of sizeof(float) * the
# number of fields.
gl.glVertexPointer(2, gl.GL_FLOAT, self.stride, buffer)
gl.glDrawArrays(self.mode, 0, self.array.shape[0])
gl.glDisableClientState(gl.GL_VERTEX_ARRAY)
buffer.unbind()
|