I like to use Numpy to create an array of vertices that is to be passed into glsl
.
Vertices
will be a numpy array that comprises the info of 3 vertex.
Each vertex
consist of:
pos = (x, y)
a 64-bit signed floating-point format that has a 32-bit R component in bytes 0..3, and a 32-bit G component in bytes 4..7, andcolor = (r, g, b)
a 96-bit signed floating-point format that has a 32-bit R component in bytes 0..3, a 32-bit G component in bytes 4..7, and a 32-bit B component in bytes 8..11
i.e. each vertex = (pos, color) = ( (x, y), (r, g, b) )
A triangle has 3 vertices, so finally I need a 1D numpy array to describe
Vertices = [vertex1, vertex2, vertex3]
= [ ( (x, y), (r, g, b) ),
( (x, y), (r, g, b) ),
( (x, y), (r, g, b) ) ]
How can I create Vertices
in numpy? The below syntax looks wrong.
Vertices = np.array([( (x1, y1), (r1, g1, b1) ),
( (x2, y2), (r2, g2, b2) ),
( (x3, y3), (r3, g3, b3) )], dtype=np.float32)
The bytes size of each vertex
should be 64/8 + 96/8 = 8 + 12 = 20 bytes.
The bytes size of Vertices
should be 20 bytes x 3 = 60 bytes.