Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a sprite sheet loaded as an OpenGL texture, and I'd like to draw a portion of that texture sequentially for animation. Is there an actual OpenGL command to draw part of a texture? I can get it done by modifying the U and V components when drawing the texture, but I'm not sure if there's a more elegant/correct method of doing this.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

Using a part of the UV space is the "correct" way. It's used for almost every full screen operation (except clear and some resolve ops). Avoid blitting and tex copy as much as you can.

Using UV and geometry gives you a lot of flexibility, you can rotate/zoom images and batch together sprites that share the same atlas. Just be careful about pixel center and filtering so that sprites don't bleed into each other.

share|improve this answer
add comment

Set UI transformation matrices, set U/V/vertex coordinates for quad, draw. Nothing more to it, really.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.