c++ - Rotation in OpenGL ES 2.0 -


i have 2x4 matrix. represent 4 points of square. need rotate said square x radians (which can converted degrees) rotation point/ anchor being center of square.

since opengl es 2.0 has removed transformation functions (glpush/glpop, glrotate, gltranslate, glscale, etc.) need rotation myself. can me write function preform rotation?

rotations in 2d can expressed (where theta in radians):

cs = cos(theta); sn = sin(theta);  out.x = in.x * cs - in.y * sn; out.y = in.x * sn + in.y * cs; 

the above linear equations can expressed 2x2 matrix (in american way, arranged in columns):

|  cs  sn | | -sn  cs | 

the matrix can expanded add translations:

|  cs  sn  tx | | -sn  cs  ty | |   0   0  1  | 

in openggles 2.0 packing 4 points array of 2 components, need transform them in vertex shader. compute above matrix , send down pipeline using uniform.

this can quite long if don't know opengl es 2.0 pipeline. require more info?


Comments

Popular posts from this blog

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -