Hi everyone! Faced with problem creation of animation: when i try will rotate for animation my cylinder from glut library, program is just closed. I tried solve problem across timer, difference methods, replacing Redisplay on multiple calling of my draw function but this doesn,t work...Can you help me ?
public Form3()
{
InitializeComponent();
AnT1.InitializeContexts();
Glut.glutDisplayFunc(Draw);
Glut.glutTimerFunc(50, Timer, 0);
Glut.glutMainLoop();
}
void Timer(int Iunused)
{
Glut.glutPostRedisplay();
Glut.glutTimerFunc(50, Timer, 0);
}
private void AnT1_Load(object sender, EventArgs e)
{
Glut.glutInit();
Glut.glutInitDisplayMode(Glut.GLUT_RGB | Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
Gl.glClearColor(255, 255, 255, 1);
Gl.glViewport(0, 0, AnT1.Width, AnT1.Height);
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluPerspective(45, (float)AnT1.Width / (float)AnT1.Height, 0.1, 200);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity();
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
Gl.glPushMatrix();
double xy = 0.2;
Gl.glTranslated(xy, 0, 0);
xy += 0.2;
Draw();
Glut.glutSwapBuffers();
Glut.glutPostRedisplay();
Gl.glPopMatrix();
}
void Draw()
{
Gl.glLoadIdentity();
Gl.glColor3f(0.502f, 0.502f, 0.502f);
Gl.glTranslated(-1, 0, -6);
Gl.glRotated(95, 1, 0, 0);
Glut.glutSolidCylinder(0.7, 2, 60, 60);
Gl.glLoadIdentity();
Gl.glColor3f(0, 0, 0);
Gl.glTranslated(-1, 0, -6);
Gl.glRotated(95, 1, 0, 0);
Glut.glutWireCylinder(0.7, 2, 20, 20);
}