I don't want the texture to be stretched out

Hi all,



I’m working on a hud for my game, and since I’m a total noob, I read the HUDs for the total noob tutorial on the wiki.



Now, the way of making a dynamic gauge shown there seems a bit odd to me. Isn’t there a way to just cut out a part of a texture and add it to a quad without it beeing stretched out to fill the entire quad?



Thanks



/Per

Well, you see, a quad has 4 vertices. And you pin texture coordinates to the vertices. Vertices are the only anchors you have. Therefore the texture will stretch the whole quad anyway as far as I can see.



The way the tutorial is written, in fact a part of the original texture is cut out and pinned to the quad. But it must fill the entire quad. That’s why I decided to have a semi-transparent texture and place a shifting window over it, which is pinned to the quad.



If someone can think of a way of filling a quad with a texture without filling the whole quad (or resizing the quad, which would do the trick also), let me know.

I see… well, the reason I asked was because when going through other games texture directories, I noticed they aren’t having textures twice as large as the requierd area. Maybe they are doing it “ingame” or something though, so one doesn’t notice…

Sorry Per for me not being very responsive these days, I am terrorized by a bad cold currently.



Suppose you want a live/health/speed/whatever meter looking like a progress bar, like in the tutorial. If you don’t want a texture with a transparent part in it, what you COULD do is the following (supposing the bar goes from left to right and the initial value is 0)


  • Create your bar quad and map the texture to it.
  • Place the bar on the screen with a scale and translation so that it is at the leftmost position with a horizontal scale of 0.
  • If the value you want to be displayed grows larger, change the horizontal scale so that at maximum level it is 1.0, additionally adjust the translation so that the left border of the bar remains fixed on the screen. You will have to change the uv texture coordinates of the LEFT vertices though, or else your texture will be stretched! That is, for the right vertices the texture coordinates remain fixed, for the left ones you need to adjust them.



    Hope that helps. I am currently sitting at work so I cannot provide you with an example. Maybe I will write another step of the tutorial reflecting this idea.

I think I understand what you mean :slight_smile:



It sounds like a stable solution!