Quote:
but using function 'myellipse' makes the animation very slow
You want to improve speed, that process is named 'optimization', the tool that help you to spot bottle necks is the profiler.
Profiling (computer programming) - Wikipedia[
^]
Optimization is about being critical about your code, it translate at answering the questions:
Why do I it that way, is it necessary ?
Can I get same result with more efficient code ?
Your code is using a fixed increment
i=i+.001
which imply that for any elipse, you loop 6200 times, no matter the size of the elipse.
Critics: if my elipse is 10 pixels across, do I need to loop 6200 times ?
Answer is no, I can reduce the number of loops.
The trick is to adapt the increment to the size of elipse.
Something like this sould improve speed:
void myEllipse(int x,int y,float StAngle,float EndAngle,int RX, int RY)
{
double i, inc;
glBegin(GL_LINE_STRIP);
glColor3f(1,1,0);
inc=3.14/max(RX,RY)/2;
i=StAngle;
while(i<=EndAngle)
{
glVertex2f(int((RX*cos(i)+y)+.5),int((RY*sin(i)+x)+.5));
i=i+inc;
}
glEnd();
}
If you want real faster elipses and circles, you have to study this article:
Circles and the Digital Differential Analyzer | Dr Dobb's[
^]