![]() |
VOOZH | about |
OpenGL is a cross-language, cross-platform API for rendering 2D and 3D Vector Graphics. Using this, we can make a lot of design as well as animations. Below is the simple animation made using OpenGL.
Approach :
To make a picture moving, we need to understand the working procedure of a function used to display i.e glClear(GL_COLOR_BUFFER_BIT). Its task is to clear screen with default value after a certain time (normally, after 1/30 sec or 1/60 sec). So, if any change of coordinate happens, then it will appear to be moving as human eye can distinguish image only which is separated by 1/16 second (persistence of vision).
Now, the coordinates of circle are X = r*cos(?) and Y = r*sin(?) or for ellipse X = rx*cos(?) and Y = ry*cos(?) where rx and ry are radius in X- and Y- direction and ? is the angle.
If we vary ? from 0 to 2*pi (360 degree) at very small increase (say of 1 degree) and draw point on that coordinate, we can make a complete circle or ellipse. We can also make semi-circle or any arc of circle or ellipse by varying the starting and ending value of ? (angle).
These concepts are used to draw the following Animation:
For working on Ubuntu operating system:
gcc filename.c -lGL -lGLU -lglut -lm where filename.c is the name of the file with which this program is saved.
Below is the implementation in C.