qrawing a shape in a new position

Started by
1 comment, last by bencelot 15 years, 11 months ago
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
Advertisement
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
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();
--------------------------Check out my free, top-down multiplayer shooter: Subvein

This topic is closed to new replies.

Advertisement