Sign in to follow this  
naversearch81

qrawing a shape in a new position

Recommended Posts

naversearch81    122
hi, i want to draw two balls. but the problem is i want to dwaw them according to the output of another program. that is i am estimating new 2d position every time and i like to draw the sphare everytime in newly estimated positions. for examle : i wnat to draw a ball in the position- x=1200.5 y=100.6 after that i want to draw the same ball at position x=125.5 y=102.6 how can i do that pls give me some example. thaking you all

Share this post


Link to post
Share on other sites
Tenac    124
glTranslatef translates the OpenGL coordinate system to a new position (flaot x, float y, float z).

glTranslatef(1200.5, 100.6, 0);
drawBall();
glTranslatef(125.5, 102.6, 0);
drawBall();
glTranslatef(0, 0, 0); //reset back to the default position

Share this post


Link to post
Share on other sites
bencelot    204
no no, that'll draw the ball once at (1200.5,100.6), and then at (1326,203.2), and then the final glTranslatef(0, 0, 0) will do nothing. The translates add onto eachother.

you want:

glPushMatrix();
glTranslatef(1200.5, 100.6, 0);
drawBall();
glPopMatrix();

glPushMatrix();
glTranslatef(125.5, 102.6, 0);
drawBall();
glPopMatrix();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this