It's actually taking the color vector instead of the vertex vector. I noticed because I set the colors to random(), and the triangle clusterfudge that is my cube keeps changing shape when I reload the program.
I'm in the process of updating my code to match OpenGL3/4 standards and use PyGLM instead of numpy. Unfortunately it looks like my pointers are getting scrambled by the VAO.
I checked my view, perspective, and model matricies and they appear to be correct. I have also tried transposing them to no avail. Here's the VBO:
vector color (random)
[[-0.25 -0.25 0.25 0.4582803 0.8329993 0.36713707]
[-0.25 0.25 0.25 0.7530541 0.87386566 0.07133926]
[ 0.25 0.25 0.25 0.2536045 0.34725097 0.5796058 ]
[-0.25 -0.25 0.25 0.4582803 0.8329993 0.36713707]
[ 0.25 0.25 0.25 0.2536045 0.34725097 0.5796058 ]
etc...
Here's my shader code:
#version 420
layout (location=0) in vec3 vertex_attrib;
// in vec3 texcoord_attrib;
// layout (location=1) in vec3 normal_attrib;
layout (location=2) in vec3 color_attrib;
out vec3 vertex;
// out vec3 normal;
out vec3 color;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main() {
gl_Position = projection * view * model * vec4(vertex_attrib, 1.0f);
vertex = gl_Position.xyz;
// normal = normal_attrib;
color = color_attrib;
}
Commenting/uncommenting the normal location appears to do nothing.
VAO code where it binds the pointers for the VBO:
self.VBOs.append(VBO)
try:
VBO.bind()
for args in self.vptr_args:
print(args)
glEnableVertexAttribArray(args[0])
glVertexAttribPointer(*args)
finally:
VBO.unbind()
# args for the two calls of glVertexAttribPointer: (result of the print)
# index=0, size=3, typ=GL_FLOAT, normalized=GL_FALSE, stride=0, pointer=None
# index=2, size=3, typ=GL_FLOAT, normalized=GL_FALSE, stride=0, pointer=c_void_p(12)
I'm terribly confused. The only thing I can think of is that PyGLM says it's using high-precision floats which is messing up the offset?
Edit: GLGets
VertexPointer 0
Enabled: 1
Size: 3
Type: 5126
Stride: 0
Buffer binding: 1
Ptr: 0
//
VertexPointer 1
Enabled: 1
Size: 3
Type: 5126
Stride: 0
Buffer binding: 1
Ptr: 12