1
votes
//component
    glRotatef((GLfloat)-90, 1, 0, 0);
    gluCylinder(qObj,t_width/2,t_width/2,t_height+2*UDwall, 20, 20);
    glRotatef((GLfloat)90, 1, 0, 0);

I want to draw a Cylinder attaching the part of texture.

        glBindTexture(GL_TEXTURE_2D, texName[1]);//+

But not like glVertex3f, when I bind a texture that can not do by using TexCoord. (so just whole texture printed ;ㅅ;)

First is What can I do for adjusting the part of texture.

Second is (someone suggested using texture atlas)can I change the texture's Max coord(0.0~1.0) to other number?

1

1 Answers

0
votes

You could use a TextureMatrix to transform the coordinates of the texture so the desired rectangle shape (from texture altas) is in the right position.

So lets say you want to texture a rect that has coordinates (x,y) and dimensions (a,b). What we want to achieve here is to have the texture be at (0,0) for (x,y) and (1,1) for (x+a, y+b).

Solution

use Texture Matrix
translate by (-x, -y)
scale by (1.0 / a, 1.0 / b)