reset transformation state
glLoadldentityl); II retain current position glTranslatef|xpos,ypos, 0.);
II Translate ball back to center gITranslateflD., RadiusOfBall, 0.); II Scale ball about its bottom glScalef|sx,sy, 1.1;
II Translate the ball upward so that ifs bottom is at the origin glTranslateflO-.RadiusOfBall, 0.); II draw the ball draw_ball(l;
Matrix math is very important to the understanding of graphics routines. But using matrices in actual code is involved and often tedious. It is much easier to use the glTranslate, glScale, and glRotate commands. These commands internally create the appropriate matrix and perform the necessary computations. For the rest of the book, we shall use the above-mentioned OpenGL functions in our coding examples.
Post a comment