Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Quadrics interfering with textures

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Quadrics interfering with textures

    I built a simple 3D modeler to build model files that I can use in my OpenGL apps. To test it out, I made a simple 4 Point Square using

    glBegin(GL_QUADS)
    Vertexes, texXoords, etc..
    glEnd

    When I add a texturemap to it, it works just fine. But when I add a sphere or disk to the scene and texturemap it, the square's texture gets distorted. It only happens with spheres and Disks, and only when I texture map them.

    I am texturemapping the Spheres/Disks with
    glBindTexture( My_Texture )
    gluQuadricTexture(MyQuad, True)

    Changing the draw order of the two shapes has no effect, can anybody help me?

    An image of the correct-looking texture is here:
    http://www.angelfire.com/md/torasque/ogl1.JPG

    an image of the screwed up texture is here:
    http://www.angelfire.com/md/torasque/ogl2.JPG

    [This message has been edited by Noah (edited 08-29-2000).]

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    High Desert of California
    Posts
    27

    Re: Quadrics interfering with textures

    That's the way it works!
    Try this... take a sheet of paper and wrap it around ball. Notice how it doesn't wrap smoothly. That's the same problem that OpenGl is having texturing a square texture map onto a none flat object.

    The are two possible solutions. One is to modify the texture so that it looks warped when applied to a flat object, but correct when applied to a sphere. The other is to figure out enough points on the texture to cooridinate with the map so that when applied it is stretched and compressed to fit right. But i'd go with the first option, it's actually easier than figuring out the math.

    When you appy a square texture to a sphere, the exact center part of the texture will map correctly, as you move up or down, you have less area of sphere compared to texture, so you must adjust your texture to compensate.

    Hope this helps.
    Nobody

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Re: Quadrics interfering with textures

    Originally posted by Nobody:
    That's the way it works!
    Try this... take a sheet of paper and wrap it around ball. Notice how it doesn't wrap smoothly. That's the same problem that OpenGl is having texturing a square texture map onto a none flat object.
    Nobody
    No no no, you misunderstand me...The sphere's texture is interfering with the texture of a DIFERENT object. The OTHER object's texture looks fine UNTIL I texture map a sphere, and THEN, the OTHER OBJECTS's (Not the sphere's) texture becomes messed up.

  4. #4
    Intern Contributor
    Join Date
    Jun 2000
    Location
    Vermont
    Posts
    51

    Re: Quadrics interfering with textures

    I've never had to call glQuadricTexture(), try not using it.

    Morgan
    A

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Re: Quadrics interfering with textures

    Errr... so how do you texturemap quadric objects? They ignore glBindTexture unless you call gluQuadricTetxure with the number of the quadric objectt and the state of the texture (true/false).

  6. #6
    Intern Contributor
    Join Date
    Jun 2000
    Location
    Vermont
    Posts
    51

    Re: Quadrics interfering with textures

    Err... A call like the following works fine for me:

    glBindTexture( GL_TEXTURE_2D, gTexture );
    gluSphere( gQuadratic, 100, 15, 15 );

    How are you building your quadratic?

    Morgan
    A

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Re: Quadrics interfering with textures

    Originally posted by Morgan:

    How are you building your quadratic?

    Morgan[/B]
    Like this: (Written in BASIC but i'm sure you can figure it out)

    If Quad = 0 then
    Quad = gluNewQuadric()
    End if

    If Solid then
    gluQuadricDrawStyle(Quad, GLU_FILL)
    else
    gluQuadricDrawStyle(Quad, GLU_LINE)
    End if

    glBindTexture( GL_TEXTURE_2D, MyTexture )
    gluSphere(Quad, Radius, Slices, Stacks)

    And I just tried it, the sphere is _not_ texture mapped unless i call
    gluQuadricTexture(Quad, True)
    end when I do that, the other shape's texture gets messed up.

  8. #8
    Intern Contributor
    Join Date
    Jun 2000
    Location
    Vermont
    Posts
    51

    Re: Quadrics interfering with textures

    Oops, I looked over some of my code a little more carefully and discovered that I do infact call gluQuadricTexture(), so that's not the problem. Does it make any difference in your program whether you render the cube first or last?

    Morgan
    A

  9. #9
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Re: Quadrics interfering with textures

    That's the wierd part, draw or creation order does not matter. Also, no matter how many spheres there are, it only screws up the first square, not any subsequent ones. I'm using a 3rd party plugin for my Basic compiler (REALbasic) that allows me to access the OGL libraries. I'll contact the author to see if he's doing something wierd.

    [This message has been edited by Noah (edited 08-31-2000).]

  10. #10
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Greenbelt, MD, USA
    Posts
    29

    Re: Quadrics interfering with textures

    ARRRG! Im such an idiot!

    I was accidentally rendering the cube with:

    vertex
    texcoord
    vertex
    texcoord
    etc...

    instead of

    texcoord
    vertex
    texcoord
    vertex
    etc...

    Thanks for your help though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •