[PyOpenGL-Users] glVertexAttribPointer Problem
Brought to you by:
mcfletch
|
From: Thomas <p_t...@gm...> - 2011-01-30 17:35:33
|
Hello,
I'm trying to use glVertexAttribPointer and interleaved vertex data.
// simple coordinate cross: vertex0, color0, ...
data = [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, # x0
1.0, 0.0, 0.0, 1.0, 0.0, 0.0, # x1
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, # y0
0.0, 1.0, 0.0, 0.0, 1.0, 0.0, # y1
0.0, 0.0, 0.0, 0.0, 0.0, 1.0, # z0
0.0, 0.0, 1.0, 0.0, 0.0, 1.0] # z1
buffer = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER, buffer)
glBufferData(GL_ARRAY_BUFFER, numpy.array(cross, numpy.float32),
GL_STATIC_DRAW)
# attributes are queried by glGetAttribLocation after shaders are linked
glVertexAttribPointer(attributes['coord'], GLint(3), GL_FLOAT, GL_FALSE,
GLsizei(6 * 4), ctypes.c_void_p(0))
glVertexAttribPointer(attributes['color'], GLint(3), GL_FLOAT, GL_FALSE,
GLsizei(6 * 4), ctypes.c_void_p(3))
for index in attributes.values():
glEnableVertexAttribArray(index)
In my vertex shader I have:
attribute vec3 coord;
attribute vec3 color;
Vertex data is correct, but "vec3 color" is always (0.0, 0.0, 0.0)
Is it a problem with pyopengl or did I miss something in my setup?
-Thomas
|