4
\$\begingroup\$

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.

\$\endgroup\$
7
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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