Pyopengl Numpy Texture Appears As Solid Color
I'm trying to set numpy arrays as OpenGl textures in pygame. The problem is that only the first pixel is taken as texture data and instead of a random pattern (for example) I only
Solution 1:
As pointed out by genpfault I was missing texture coordinates. I needed to add them to the rectangle drawing part.
#draw rectangle
glTranslatef(300,200,0)
glBegin(GL_QUADS)
glTexCoord(0,0)
glVertex2f(0,0)
glTexCoord(0,1)
glVertex2f(0,height)
glTexCoord(1,1)
glVertex2f(width,height)
glTexCoord(1,0)
glVertex2f(width,0)
glEnd()
glFlush()
Read this if you are lost on how texture mapping works:
OpenGL Programming Guide - Chapter 9 Texture Mapping
Post a Comment for "Pyopengl Numpy Texture Appears As Solid Color"