1

I want this code to Display a cube(which already works), and render the pictures, given in the imgNames list, as surfaces of the cube. This partially works it only renders the last given texture on every side. I tried fiddling around with glActiveClientTexturesARB() but it told be that this Name wasn't defined.

Are there any suggestions?

def Cube(oV,imgNames): #oV is the starting point from the cube
    #creating a list of the raw img data
    imgs=[]
    for imgName in imgNames:
        imgs.append(pygame.image.load(imgName))

    h=imgs[0].get_height()/1000
    l=imgs[0].get_width()/1000
    w=imgs[1].get_width()/1000


    #setting up verticies and surfaces
    verticies = (
        (vAdd(oV,(0,l,0))),
        (vAdd(oV,(h,l,0))),
        (vAdd(oV,(h,0,0))),
        (oV),
        (vAdd(oV,(0,l,w))),
        (vAdd(oV,(h,l,w))),
        (vAdd(oV,(0,0,w))),
        (vAdd(oV,(h,0,w))),
        )


    surfaces = (
        (0,1,2,3),
        (3,2,7,6),
        (6,7,5,4),
        (4,5,1,0),
        (1,5,7,2),
        (4,0,3,6),    
        )

    #saw somebody use that for multitexturing, but doesn's seen to work
    glTs=("GL_TEXTURE0_ARB","GL_TEXTURE1_ARB","GL_TEXTURE2_ARB",
          "GL_TEXTURE3_ARB","GL_TEXTURE4_ARB","GL_TEXTURE5_ARB")

    #drawing each surface individually
    x=0
    for surface in surfaces:
        try:
            img=imgs[x]
            try:
                glActiveClientTextureARB(glTs[x])
            except:
                pass

            textureData = pygame.image.tostring(img, "RGB", 1)
            width = img.get_width()
            height = img.get_height()

            im = glGenTextures(1)
            glBindTexture(GL_TEXTURE_2D, im)

            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, textureData)
            glEnable(GL_TEXTURE_2D)
        except:
            pass
        glBegin(GL_QUADS)
        glTexCoord2f(0,0)
        glVertex3f(verticies[surface[0]][0],verticies[surface[0]][1],verticies[surface[0]][2])
        glTexCoord2f(0,1)
        glVertex3f(verticies[surface[1]][0],verticies[surface[1]][1],verticies[surface[1]][2])
        glTexCoord2f(1,1)
        glVertex3f(verticies[surface[2]][0],verticies[surface[2]][1],verticies[surface[2]][2])
        glTexCoord2f(1,0)
        glVertex3f(verticies[surface[3]][0],verticies[surface[3]][1],verticies[surface[3]][2])
        glEnd()
        x+=1
genpfault
  • 51,148
  • 11
  • 85
  • 139
Silas247
  • 11
  • 4
  • you most likely did not register needed extension like MultiTexturing ... Either you do it yourself which is a pain in the... or use some lib for that I use `GLEW` for that ,,, you just init OpenGL and after that you call glew init and that is all after that you can use any extension your gfx card have and GLEW supports ... To check if your extension is present read the extension strings or (in GLEW) jus look if used function is not NULL – Spektre Jul 16 '15 at 05:59
  • how you want to use more textures at once? (GLSL or some legacy GL texture combinations) With multi texturing you should provide texture coordinates for each unit [first relevant google hit](http://www.informit.com/articles/article.aspx?p=770639&seqNum=5) – Spektre Jul 16 '15 at 06:05

0 Answers0