PDA

View Full Version : Problem with animation



mr07th
05-31-2014, 07:14 AM
Hi everyone, I have a problem with animation. My program drawing spacecraft that contains cylinders (wire and solid from library of glut) and calculating angles of rotation for spacecraft. On the angles rotation I need will draw animation change of spacecraft at space. That I trying insert in my code glutTimerFunc my program just is closed. What is problem ?


public Form3()
{
InitializeComponent();
AnT1.InitializeContexts();
Glut.glutTimerFunc(50, Timer, 0);
}
void Timer(int value)
{
Gl.glRotated(1, 0, 0, 1);
Draw();
Glut.glutTimerFunc(50, Timer, 0);
}
void Draw()
{
Gl.glLoadIdentity();
Gl.glColor3f(0.502f, 0.502f, 0.502f);

Gl.glPushMatrix();
Gl.glTranslated(-1, 0, -6);
Gl.glRotated(95, 1, 0, 0);
Glut.glutSolidCylinder(0.7, 2, 60, 60);

next of similiarly of code
...
}

Rotation is carried out along three axes that will calculate. Please help. Time has double value.

rodrigoloc
06-01-2014, 08:39 PM
I do not know why your program closes. But if you rotate in Timer(int) function and then in Draw() function you load matrix's identity nothing will happen. Try declaring a member variable and add a value to it in Timer(int) function, then rotate in Draw() function.
P.S.: You're using an old OpenGL version.