I use Python 3.6. Originally I use code like this:
array_to_texture(self.board)
glColor3fv((1.0, 1.0, 1.0))
glBegin(GL_QUADS)
for vertex, tex in zip(self.POINTS, self.TEX):
glTexCoord2f(*tex)
glVertex3fv(vertex)
glEnd()
and it works. It draw square with texture in 3D space.
Now I want to use VBO to do the trick. To draw walls (with fixed color) is possible to use following code:
vbo = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER, vbo)
glBufferData(GL_ARRAY_BUFFER, len(vertices) * 4, (c_float * len(vertices))(*vertices), GL_STATIC_DRAW)
glVertexPointer(3, GL_FLOAT, 0, None)
glDrawArrays(GL_QUADS, 0, 4)
That works perfectly. The major question, how can I attach and draw a texture with this approach? How Can I create some kind of buffer for texture coordinates and use it? I really struggle to find some minimal working example.
The minor question is, how is it possible that the glDrawArrays(GL_QUADS, 0, 4)
line works, even though the GL_QUADS are not allowed in documentation: http://pyopengl.sourceforge.net/documentation/manual-3.0/glDrawArrays.html