Texture Scaling
Is there any way to scale the size of textures which are tile mapped on surface? I can do it by playing with texture coords but this messes things up when I go to shift texture origin coords.
I am currently doing it like this:
glTexCoord2f(pPtr[0][0]*m_fTexScale+m_vTexOrigin[0],pPtr[0][1]*m_fTexScale+m_vTexOrigin[1]);
where pPtr is a vertex array.
What do you mean by "shift texture origin coords"?
If you wanted only half of a texture to show on a quad, for example, you would use the values (0, 0), (0, 0.5), (1, 0.5), and (1, 0) let''s say, so that it is stretched vertically and half of it shows up. If you want to keep it to scale, do something like
GLfloat x = 1/2;
(0, 0), (0, x), (x, x), (x, 0)
would show the bottom left quarter of your square texture stretched on the face of the quad.
If you wanted to add in more points in between, you take the percentage of the width and height you want, achieved by:
(wanted width/total width) and (wanted height/total height)
and multiply those by x, so, if you had two rectangular quads that formed a square, let''s say, you would use:
GLfloat x = 1/2;
GLfloat h = (wanted height/total height);
GLfloat w = (wanted width/total width);
(0, 0), (0, x * h), (x * w, x * h), (x * w, 0)
etc, etc, etc...
Hope you understand all that and that it applies to what you were wanting.
S.
If you wanted only half of a texture to show on a quad, for example, you would use the values (0, 0), (0, 0.5), (1, 0.5), and (1, 0) let''s say, so that it is stretched vertically and half of it shows up. If you want to keep it to scale, do something like
GLfloat x = 1/2;
(0, 0), (0, x), (x, x), (x, 0)
would show the bottom left quarter of your square texture stretched on the face of the quad.
If you wanted to add in more points in between, you take the percentage of the width and height you want, achieved by:
(wanted width/total width) and (wanted height/total height)
and multiply those by x, so, if you had two rectangular quads that formed a square, let''s say, you would use:
GLfloat x = 1/2;
GLfloat h = (wanted height/total height);
GLfloat w = (wanted width/total width);
(0, 0), (0, x * h), (x * w, x * h), (x * w, 0)
etc, etc, etc...
Hope you understand all that and that it applies to what you were wanting.
S.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement