OpenGL, C++, Scaling a texture within a quad.

Started by
1 comment, last by Gravious 15 years, 3 months ago
i want to make several 'sprite' quads with a single texture that has all the frames of animation on it, and just offset the texture to the right place. I can offset the texture within the quad, but the problem is, the texture is scaled to fit inside the quad, showing the whole sprite sheet, how to i keep it from doing that?
Advertisement
Quote:Original post by Gravious
I can offset the texture within the quad, but the problem is, the texture is scaled to fit inside the quad, showing the whole sprite sheet, how to i keep it from doing that?
Scale your texture coordinates. Typically one uses texture coordinates in the range [0, 1], which displays the entire texture. To display only the first half of your texture, halve the range: [0, 0.5].

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by swiftcoder
Quote:Original post by Gravious
I can offset the texture within the quad, but the problem is, the texture is scaled to fit inside the quad, showing the whole sprite sheet, how to i keep it from doing that?
Scale your texture coordinates. Typically one uses texture coordinates in the range [0, 1], which displays the entire texture. To display only the first half of your texture, halve the range: [0, 0.5].


There we go, thats what i wanted :D thanks

This topic is closed to new replies.

Advertisement