You are probably using a 64-bit operating system. At a 64-bit operations system the data type uint
has a size of 64 bits.
See Go language data types or A Tour of GO - Basic types.
The coordinates of the rectangle ar specified like this:
1: -0.5, 0.5 2: 0.5, 0.5
x-----------x
| |
| |
| |
| |
x-----------x
0: -0.5, -0.5 3: 0.5, -0.5
The indices array is a array of 64 bit integer values:
var rectangle = []uint{
0, 1, 2,
2, 3, 0,
}
But it is treated as an array of 32 bit integers, when the geometry is draw (gl.UNSIGNED_INT
):
gl.DrawElements(gl.TRIANGLES, 6, gl.UNSIGNED_INT, gl.PtrOffset(0))
This causes that each index of the array is splitted to 2 indices, which 32 bit each, where the 1st value is the index of the array and the 2nd is 0:
[0, 0, 1, 0, 2, 0, 2, 0, 3, 0 0, 0]
So the first 2 triangles (first 6 indices) are
0 - 0 - 1
0 - 2 - 0
In the image you can see this 2 triangles, which are narrowed down to 2 lines, because 2 points of each triangle are equal.
Use the data type uint32
to solve the issue:
var rectangle = []uint32{
0, 1, 2,
2, 3, 0,
}