Question

I'm trying to get multipass texturing work for me but right now i can get simple texturing to work, can anybody spor whats going wring with the following code. This examples just shows the poly as white, rather than textured.

def loadTexture(name):

    img = PIL.Image.open(name) # .jpg, .bmp, etc. also work
    img_data = numpy.array(list(img.getdata()), numpy.int8)

    id = glGenTextures(1)
    glPixelStorei(GL_UNPACK_ALIGNMENT,1)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img.size[0], img.size[1], 0, GL_RGB, GL_UNSIGNED_BYTE, img_data)
    return id

....

tex = loadTexture(/foobar.png)

....

glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glTranslate(0.0, 0.0, -600)
glScale(50.0, 50.0, 50.0)
glRotate(90, 0.0, 0.0, 0.0)

glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, tex)
glBegin(GL_TRIANGLES)

....

glEnd()

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top