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
    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_WRAP_T, GL_REPEAT);   

    glPushMatrix(); // push 3

    // spherical texture generation
    // this piece of code doesn't work as I intended

    GLUquadric *tub = gluNewQuadric();
    gluQuadricTexture(tub, GL_TRUE);
    gluDisk(tub, radius, outerR, nrVertices, nrVertices);

    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


I'm not sure I understand your diagram. Are you saying you want the image to repeat along the edge of the disk (i.e. the lines represent the borders of the image?) If so, that may produce visual artifacts that you might want to consider first.

The way you've drawn it here, the image will compress near the inner part of the disk, and stretch near the outer part. The different radii of the inner/outer circle causes the arc lengths to be different. You're essentially mapping a square to a trapezoid. I would post an image, but my account is too new. Argh.

I don't think GLU offers any other form of texture mapping for disks. If you want that kind of custom texture coordinates, you probably need to roll your own form of disk generation, which isn't that bad anyways. Still, you might want to reconsider using GLU for actual geometry anyways.

| improve this answer | |
  • \$\begingroup\$ That is indeed exactly what I want. Why shouldn't I use Quadrics? I thought it was better than doing it by myself with a glBegin(). I already have the code for my own ring, which is very easy with a quad strip, but I was just curious if you can change these texture coordinate generations. If it really is a no-go, then I would accept that. \$\endgroup\$ – Marnix Mar 6 '11 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.