Sign in to follow this  

Closing program from animation

This topic is 1323 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

        } 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 tongue.png
Edited by Misantes

Share this post


Link to post
Share on other sites

This topic is 1323 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this