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.
2 Answers
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.
Set UI transformation matrices, set U/V/vertex coordinates for quad, draw. Nothing more to it, really.