Texture mapping on gluDisk

Posted by Marnix on Game Development See other posts from Game Development or by Marnix
Published on 2011-03-05T17:54:05Z Indexed on 2011/03/05 23:33 UTC
Read the original article Hit count: 442

Filed under:
|
|

I'm trying to map a brick texture on the edge of a fountain and I'm using gluDisk for that. How can I make the right coordinates for the disk? My code looks like this and I have only found a function that takes the texture along with the camera.

I want the cubic texture to be alongside of the fountain, but gluDisk does a linear mapping. How do I get a circular mapping?

void Fountain::Draw()
{
    glPushMatrix(); // push 1
    this->ApplyWorldMatrixGL();
    glEnable(GL_TEXTURE_2D); // enable texturing
    glPushMatrix(); // push 2
    glRotatef(90,-1,0,0); // rotate 90 for the quadric

    // also drawing more here...

    // stone texture
    glBindTexture(GL_TEXTURE_2D, texIDs[0]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);   

    glPushMatrix(); // push 3
    glTranslatef(0,0,height);

    // spherical texture generation
    // this piece of code doesn't work as I intended
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);

    GLUquadric *tub = gluNewQuadric();
    gluQuadricTexture(tub, GL_TRUE);
    gluDisk(tub, radius, outerR, nrVertices, nrVertices);
    gluDeleteQuadric(tub);
    glDisable(GL_TEXTURE_GEN_S);
    glDisable(GL_TEXTURE_GEN_T);

    glPopMatrix(); // pop 3
    // more drawing here...
    glPopMatrix(); // pop 2
    // more drawing here...
    glPopMatrix(); // pop 1
}

To refine my question a bit. This is an image of what it is at default (left) and of what I want (right). The texture should fit in the border of the disk, a lot of times. If this is possible with the texture matrix, than that's fine with me as well. Left is the default texCoords, right is what I want

© Game Development or respective owner

Related posts about c++

Related posts about opengl