graphics - OpenGL ES/Android -- Is there a built-in function to reset the scale, translation, rotation of a object? -


my program draws object, translates, rotates, , scales it, redraws it, etc etc. set translation do:

gl.gltranslatef(2,4,666); 

then clear gl.gltranslatef(-2,-4,-666);

i'm wondering if there's built in function so?

glpushmatrix() , glpopmatrix() normal ways this. push before applying gltranslate, pop when done , revert stack. have remember, opengl state based system uses stack. when apply gltranslatef, adding translate function stack, drawn after placed on stack have translation done it. calling

gl.gltranslatef(2,4,666);  

and

gl.gltranslatef(-2,-4,-666); 

if understand correctly, cause scene first move object (-2,-4,-666), (2,4,666). because stack, last transformation apply gets applied first, , first last. helps remember little fact while you're setting scene. put push before gl.gltranslatef(2,4,666);, , pop after , should good.

glpushmatrix(); gl.gltranslatef(2,4,666); //draw code here glpopmatrix(); 

just remember whole stack thing , should able think through problem areas.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -