iphone - How do I rotate an object using OpenGL ES 2.0? -


in opengl es 1.1, can use glrotatef() rotate model, function doesn't exist in opengl es 2.0.

therefore, how perform rotation in opengl es 2.0?

to follow on christian's said, you'll need keep track of model view matrix , manipulate perform rotations need. you'll pass in matrix uniform shader, , following:

attribute vec4 position;  uniform mat4 modelviewprojmatrix;  void main() {     gl_position = modelviewprojmatrix * position; } 

i've found core animation catransform3d helper functions work performing right kind of matrix manipulations needed this. can rotate, scale, , translate catransform3d, read out 4x4 matrix elements create model view matrix need.

if want see in action, this sample iphone application created shows how perform rotation of cube using both opengl es 1.1 , 2.0.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -