View Full Version : Texturing a cylinder
07-29-2001, 09:37 PM
I have a problem with a cylinder.
I already could put a texture on one that had the same radius at both ends. It was wrapped around it like paper around a pipe.
But now I have a very flat cylinder - almost like a disc. The problem is that the texture should be applied like one that is drawn on a disc.
So it should not be wrapped around the outer side but layed on it (like a label on a CD).
Is there a way I can do this...?
07-30-2001, 05:04 AM
You could draw a textured square over the cylinder's face on which you want to draw.
If you do it, be careful about the glDepthFunc ...
07-31-2001, 12:06 PM
:-( I didn't work - I don't know why.
All I see is a textured square with a cylinder behind it. The square is textured ok - the cylinder not.
I played a little with my test program:
First I tried to use a disc instead of GL_QUADS to apply the texture to, but it didn't change anything.
Then I tried some other parameters in glDepthFunc. Only GL_NOTEQUAL looked a little like what I was expecting but nothing really made me feel that I am on the right way....
Maybe I should post my test program and hope that somebody tells me what I am doing wrong.... :-)
08-01-2001, 04:44 AM
It seems that DFrey, on the advanced forum, has found a good idea for you : use glPolygonOffset !
08-01-2001, 07:12 AM
No sorry, I can't make it work.
So here it is: The drawing routine that I used in my test program.
Could you please take a look at it? I just want to be sure that we're talking about the same thing...
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
GLfloat r = 0.9;
GLfloat h = 0.2;
glPolygonOffset(1.0, 1.0); // ?
// cylinder that is to be textured...
gluCylinder(qobj, 0.3*r, r, h, 20, 1);
glVertex3f(-r, -r, h);
glVertex3f( r, -r, h);
glVertex3f( r, r, h);
glVertex3f(-r, r, h);
// I also tried this instead of the GL_QUADS
// gluDisk(qobj, 0.0, r, 20, 1);
08-03-2001, 01:28 AM
I'm not used to work with glPolygonOffset so you should ask to DFrey. But if I'm not mistaken, it seems that you use the same polygon offset for both your cylinder and square, so that could explain why it does not work. Try using 0,0 for the cylinder and 1,1 (as you do) for the square (or the opposite, i don't know).
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.