[Original] sets the image center to rotate around (OpenGL | es)
Source: Internet
Author: User
Suppose you want to draw a 32*32 image at the point (x, y) and rotate it in the center of the image, use the following CodeThen you can rotate glfloat vertices [] = {-imagewidth/2,-imageheight/2, imagewidth/2,-imageheight/2,-imagewidth/2, imageheight/2, imagewidth/2, imageheight/2}; // rotate around the center at the bottom /glfloat vertices [] /// {//-imagewidth/2, 0.0, // imagewidth/2, 0.0, //-imagewidth/2, imageheight, // imagewidth/2, imageheight //}; glloadidentity (); glcolor4f (1.0f, 1.0f, 1.0f, 1.0f); glpushmatrix (); gltranslatef (X, Y, 0.0f); glrotatef (angle, 0.0f, 0.0f, 1.0f); glscalef (XScale, yscale, 1.0f); glvertexpointer (2, gl_float, 0, vertices); gltexcoordpointer (2, gl_float, 0, coordinates); gldrawarrays (gl_triangle_strip, 0, 4); glpopmatrix, for example, you can use the positive and negative symbols of Angle in glrotatef (angle, 0.0f, 0.0f, 1.0f) to change from clockwise to counterclockwise.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.