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?
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.
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.
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).
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.
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?
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).]