• Create Account

## Closing program from animation

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1mr07th  Members

Posted 02 June 2014 - 06:19 AM

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);
Glu.gluPerspective(45, (float)AnT1.Width / (float)AnT1.Height, 0.1, 200);
Gl.glMatrixMode(Gl.GL_MODELVIEW);

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.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.glColor3f(0, 0, 0);

Gl.glTranslated(-1, 0, -6);
Gl.glRotated(95, 1, 0, 0);
Glut.glutWireCylinder(0.7, 2, 20, 20);

} 

### #2Eck  Members

Posted 02 June 2014 - 08:01 AM

Put try/catches around your code and see if there's an exception being thrown. If so, what is the exception?

Run it in the debugger, step through your code, and see where it's failing.

- Eck

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

### #3SeanMiddleditch  Members

Posted 02 June 2014 - 09:56 AM

Put try/catches around your code and see if there's an exception being thrown. If so, what is the exception?

You can do that without modifying the code in many debuggers. In Visual Studio, for instance, in the menu go to Debug->Exceptions and check all the checkboxes. That'll make the debugger break when an exception is thrown independent of whether it's going to be caught or not, and unlike a try/catch, it breaks at the point the error happened without throwing (hah) away all the contextual information.

Game Developer, C++ Geek, Dragon Slayer - http://seanmiddleditch.com

C++ SG14 "Games & Low Latency" - Co-chair - public forums

Wargaming Seattle - Lead Server Engineer - We're hiring!

### #4mr07th  Members

Posted 02 June 2014 - 11:43 AM

Well I used Debug->Exceptions and I haven't exceptions /: my program is compile but will close after compile D: funny thing that i trying make animation in simple example and faced with same problem. Partially solved by try catch but i don't know what is exception /:

Edited by mr07th, 03 June 2014 - 01:21 AM.

### #5Misantes  GDNet+

Posted 03 June 2014 - 11:11 AM

Are you getting any particular error? I know a common one I get with OpenGL when rotating is when it's trying to divide by zero/or sqrt zero or something. I can't recall exactly what it is at the moment, but I'll try to create one and post it. But, if the numbers you're trying to rotate don't make sense to the program, it's possible that's crashing you(though, your glrotate() looks rather normal to me at first glance)? Do you still crash when not trying to animate?

(take this advice with a huge grain of salt as I'm still rather new to OpenGL myself).

edit*

OPENGL: /usr/include/glm/detail/func_exponential.inl:149: genType glm::sqrt(const genType&) [with genType = float]: Assertion x >= genType(0)' failed.
Aborted (core dumped)

the above error is what I get when trying to rotate illogical numbers(actually, i generated that error by giving glm::LookAt an impossible direction, which is different, but I think it's the same error roughly). But, the program does the same as what you're describing. It compiles then crashes immediately. I realize you're not using glm to rotate, but I only mention this because it seems possible your animation is trying to do something along these lines. Perhaps try adjusting your rotation a little or just really making sure that your animation isn't trying to do something that isn't working) and seeing if that lets it start? If I have time after work I'll download the code and see what it does on my machine.

Again, as a caveat, I'm no opengl expert so take this advice simply as another beginner who has had the same problem

Edited by Misantes, 03 June 2014 - 11:35 AM.

Beginner here <- please take any opinions with grain of salt

### #6Gooey  Members

Posted 03 June 2014 - 12:12 PM

i thought you needed a call to
glutCreateWindow(char * name)`

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.