Hi,

I've been trying to get 3D textures working in PyOpenGL.  I tried a simple 2D image (depth = 1).  The source image (which I choose randomly) is here.

texture3darray = pygame.surfarray.array3d(#pygame.Surface)
data = Numeric.array(Numeric.ravel(texture3darray),"uint8")

texture = glGenTextures(1)
glBindTexture(GL_TEXTURE_3D,texture)
glTexImage3D(GL_TEXTURE_3D,0,GL_RGB,480,342,1,0,GL_RGB,GL_UNSIGNED_BYTE,data)
glTexParameterf(paramtype,GL_TEXTURE_MIN_FILTER,GL_LINEAR)
glTexParameterf(paramtype,GL_TEXTURE_MAG_FILTER,GL_LINEAR)

I tried using this code to texture a rectangular solid, but I get an incorrect result--see here.  Here's the code for the solid:

#Inside a function
box = glGenLists(1)
glNewList(box,GL_COMPILE)
glDisable(GL_TEXTURE_2D)
glEnable(GL_TEXTURE_3D)
glSelectTexture(GL_TEXTURE_3D,texture)
glBegin(GL_QUADS)
# Right face
if normalflip: glNormal3f( 1.0, 0.0, 0.0)
else: glNormal3f(-1.0, 0.0, 0.0)
glTexCoord3f(1.0, 1.0, 1.0); glVertex3f( size[0],  size[1],  size[2])
glTexCoord3f(1.0, 0.0, 1.0); glVertex3f( size[0], -size[1],  size[2])
glTexCoord3f(1.0, 0.0, 0.0); glVertex3f( size[0], -size[1], -size[2])
glTexCoord3f(1.0, 1.0, 0.0); glVertex3f( size[0],  size[1], -size[2])
# Left Face
if normalflip: glNormal3f(-1.0, 0.0, 0.0)
else: glNormal3f( 1.0, 0.0, 0.0)
glTexCoord3f(0.0, 1.0, 1.0); glVertex3f(-size[0],  size[1],  size[2])
glTexCoord3f(0.0, 1.0, 0.0); glVertex3f(-size[0],  size[1], -size[2])
glTexCoord3f(0.0, 0.0, 0.0); glVertex3f(-size[0], -size[1], -size[2])
glTexCoord3f(0.0, 0.0, 1.0); glVertex3f(-size[0], -size[1],  size[2])
# Top Face
if normalflip: glNormal3f( 0.0, 1.0, 0.0)
else: glNormal3f( 0.0, -1.0, 0.0)
glTexCoord3f(0.0, 1.0, 0.0); glVertex3f(-size[0],  size[1], -size[2])
glTexCoord3f(0.0, 1.0, 1.0); glVertex3f(-size[0],  size[1],  size[2])
glTexCoord3f(1.0, 1.0, 1.0); glVertex3f( size[0],  size[1],  size[2])
glTexCoord3f(1.0, 1.0, 0.0); glVertex3f( size[0],  size[1], -size[2])
# Bottom Face
if normalflip: glNormal3f( 0.0,-1.0, 0.0)
else: glNormal3f( 0.0, 1.0, 0.0)
glTexCoord3f(1.0, 0.0, 1.0); glVertex3f( size[0], -size[1],  size[2])
glTexCoord3f(0.0, 0.0, 1.0); glVertex3f(-size[0], -size[1],  size[2])
glTexCoord3f(0.0, 0.0, 0.0); glVertex3f(-size[0], -size[1], -size[2])
glTexCoord3f(1.0, 0.0, 0.0); glVertex3f( size[0], -size[1], -size[2])
# Front Face
if normalflip: glNormal3f( 0.0, 0.0,-1.0)
else: glNormal3f( 0.0, 0.0, 1.0)
glTexCoord3f(1.0, 1.0, 0.0); glVertex3f( size[0],  size[1], -size[2])
glTexCoord3f(1.0, 0.0, 0.0); glVertex3f( size[0], -size[1], -size[2])
glTexCoord3f(0.0, 0.0, 0.0); glVertex3f(-size[0], -size[1], -size[2])
glTexCoord3f(0.0, 1.0, 0.0); glVertex3f(-size[0],  size[1], -size[2])
# Back Face
if normalflip: glNormal3f( 0.0, 0.0, 1.0)
else: glNormal3f( 0.0, 0.0,-1.0)
glTexCoord3f(0.0, 0.0, 1.0); glVertex3f(-size[0], -size[1],  size[2])
glTexCoord3f(1.0, 0.0, 1.0); glVertex3f( size[0], -size[1],  size[2])
glTexCoord3f(1.0, 1.0, 1.0); glVertex3f( size[0],  size[1],  size[2])
glTexCoord3f(0.0, 1.0, 1.0); glVertex3f(-size[0],  size[1],  size[2])
glEnd()
glDisable(GL_TEXTURE_3D)
glEnable(GL_TEXTURE_2D)
glEndList()

Why am I not seeing the rectangular solid be textured properly?  It should look like the 2D image on the top and bottom and the edges of the image on the sides of the box, right?

Ian