PDA

View Full Version : mapping texture to gluCylinder



sonicmouse
06-07-2011, 11:57 AM
Hello everyone!

I am having issues trying to map a texture properly to gluCylinder(). I am trying to make a "cup" shape where the top diameter is different from the bottom diameter.

I don't know if it's possible to do this with gluCylinder()... I am trying to avoid creating my own Cylinder.

Is it possible to map this texture properly?

Alfonse Reinheart
06-07-2011, 12:32 PM
I don't understand the problem; you seem to have the texture applied correctly.


I am trying to make a "cup" shape where the top diameter is different from the bottom diameter.

Then it's not a cylinder anymore.


I am trying to avoid creating my own Cylinder.

Why not? Generating a cylinder mesh isn't exactly the hardest thing in the world.

sonicmouse
06-07-2011, 12:37 PM
"Then it's not a cylinder anymore."

Well, technically it is since I am calling "gluCylinder" to create the cup.

"Why not? Generating a cylinder mesh isn't exactly the hardest thing in the world."

OK, so are you saying that it is not possible to map a cupped texture to a Cylinder created by "gluCylinder" ?

Alfonse Reinheart
06-07-2011, 02:08 PM
OK, so are you saying that it is not possible to map a cupped texture to a Cylinder created by "gluCylinder" ?

If you want a GLU quadric to have texture coordinates, call gluQuadricTexture on the quadric before calling gluCylinder on it.

sonicmouse
06-07-2011, 02:12 PM
I did that -- you can see in the pictures above that I have the texture mapping on to the cylinder -- I want it to map differently though

Alfonse Reinheart
06-07-2011, 02:29 PM
I did that -- you can see in the pictures above that I have the texture mapping on to the cylinder -- I want it to map differently though

Then you'll have to make a mesh and build your texture coordinates to achieve the mapping you want.

sonicmouse
06-07-2011, 02:40 PM
Super helpful... Thanks.

MaxH
06-07-2011, 03:55 PM
Maybe I'm misunderstanding, but it seems like you're making this problem harder than it really is. Why are the letters and white area in your source image arced? I think you'd get what you want if your source image was simply a white rectangle with horizontal lettering.

sonicmouse
06-07-2011, 05:02 PM
For example, if you take a McDonalds cup and unroll it, you will see that the text/pictures are skewed/warped to make up for the uneven radii on each end of the cylinder. I am trying to accomplish the same thing here.

... and it also gives you that nice rainbow-like shape

sonicmouse
06-07-2011, 05:07 PM
Maybe I am not giving OpenGL enough credit here? Do you think it will do the warping for me if I just do a straight rectangle and wrap it without warping the text?

I will give it a shot

MaxH
06-07-2011, 06:17 PM
Do you think it will do the warping for me if I just do a straight rectangle and wrap it without warping the text?
Not sure what you mean by 'warping'. If you like the way your letters appear on the cup now, then you could always insert the arced white image you are starting with into a slightly larger white rectangle, leaving the letters untouched. Then map the rectangle to the cup. That should give you pretty close to what you have now without the black areas on the cup.

sonicmouse
06-07-2011, 07:26 PM
OK -- that did it. I was way over-thinking this.

OpenGL automatically wraps it correctly without me having to warp/skew the text or the rectangle.

Sometimes it just takes another brain and set of eyes to slap me around a bit.

THANKS.