Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. animation in opengl

animation in opengl

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsgame-dev
19 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A appollosputnik

    I am trying to animate my object like below, the object should move back and forth, but with this i can't see the movement. please tell me whats going wrong in this code below. Thanks Sujan [code]

    // TODO: Add your command handler code here
    CDC* pDC = GetDC();
    wglMakeCurrent(pDC->m_hDC, m_hrc);
    transObj2[0]=transObj2[0] - 40.0f;
    Invalidate();
    Sleep(5000);
    transObj2[0]=transObj2[0] + 40.0f;
    Invalidate();
    Sleep(5000);
    wglMakeCurrent(NULL,NULL);

    [/code]

    enhzflepE Offline
    enhzflepE Offline
    enhzflep
    wrote on last edited by
    #2

    But there's no drawing code! OpenGL maintains the positions of your vertices and polygons for 1 frame. In this sample you never tell GL anything, except the HDC of the window you'd like it to draw in. Even this looks a little suspicious. Generally, one would get the HDC of a static control and throw that to GL. You've not draw the objects at all, hence you'll not see them drawn in different positions. Go lookup Nehe OpenGL tutorials. Or even 'Rotate Triangle openGL'...

    A 1 Reply Last reply
    0
    • enhzflepE enhzflep

      But there's no drawing code! OpenGL maintains the positions of your vertices and polygons for 1 frame. In this sample you never tell GL anything, except the HDC of the window you'd like it to draw in. Even this looks a little suspicious. Generally, one would get the HDC of a static control and throw that to GL. You've not draw the objects at all, hence you'll not see them drawn in different positions. Go lookup Nehe OpenGL tutorials. Or even 'Rotate Triangle openGL'...

      A Offline
      A Offline
      appollosputnik
      wrote on last edited by
      #3

      MY OBJECT IS THERE I DINT POST THE DRAWSCENE PART OF THE CODE. IT'S DRAWN ON THE SCREEN, ONLY DIFFICULTY I AM FACING IN SIMULATING IT. I WANT THE OBJECT TO MOVE BACK AND FORTH FOR 1 MINUTE. HOW CAN I ACHIEVE THIS PLS HELP.

      enhzflepE 1 Reply Last reply
      0
      • A appollosputnik

        MY OBJECT IS THERE I DINT POST THE DRAWSCENE PART OF THE CODE. IT'S DRAWN ON THE SCREEN, ONLY DIFFICULTY I AM FACING IN SIMULATING IT. I WANT THE OBJECT TO MOVE BACK AND FORTH FOR 1 MINUTE. HOW CAN I ACHIEVE THIS PLS HELP.

        enhzflepE Offline
        enhzflepE Offline
        enhzflep
        wrote on last edited by
        #4

        YOUR REWARD FOR YELLING IS NOTHING! That's right, I'm going to give you nothing. Bugger off!

        L 1 Reply Last reply
        0
        • enhzflepE enhzflep

          YOUR REWARD FOR YELLING IS NOTHING! That's right, I'm going to give you nothing. Bugger off!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          You might like to remove the obscenity from the above.

          speaking as ...

          enhzflepE 1 Reply Last reply
          0
          • A appollosputnik

            I am trying to animate my object like below, the object should move back and forth, but with this i can't see the movement. please tell me whats going wrong in this code below. Thanks Sujan [code]

            // TODO: Add your command handler code here
            CDC* pDC = GetDC();
            wglMakeCurrent(pDC->m_hDC, m_hrc);
            transObj2[0]=transObj2[0] - 40.0f;
            Invalidate();
            Sleep(5000);
            transObj2[0]=transObj2[0] + 40.0f;
            Invalidate();
            Sleep(5000);
            wglMakeCurrent(NULL,NULL);

            [/code]

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #6

            Sleep will lock all update/refresh to the display. For example, use glutTimerFunc to update your scene transformations and draw your scene at fixed intervals. Have a look at : 3.050 How can I perform animations with GLUT?[^] for a start.

            Watched code never compiles.

            1 Reply Last reply
            0
            • L Lost User

              You might like to remove the obscenity from the above.

              speaking as ...

              enhzflepE Offline
              enhzflepE Offline
              enhzflep
              wrote on last edited by
              #7

              Not a word or construct used in the above post is not used in (free to air) tv commercials, played at any hour of the day in this country. To which are you referring? (I assume it is the aussie version of sod off)

              L 1 Reply Last reply
              0
              • A appollosputnik

                I am trying to animate my object like below, the object should move back and forth, but with this i can't see the movement. please tell me whats going wrong in this code below. Thanks Sujan [code]

                // TODO: Add your command handler code here
                CDC* pDC = GetDC();
                wglMakeCurrent(pDC->m_hDC, m_hrc);
                transObj2[0]=transObj2[0] - 40.0f;
                Invalidate();
                Sleep(5000);
                transObj2[0]=transObj2[0] + 40.0f;
                Invalidate();
                Sleep(5000);
                wglMakeCurrent(NULL,NULL);

                [/code]

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                Invalidate();
                Sleep(5000);

                That call to Sleep() prevents your code from responding to the next WM_PAINT message. You need to run in a separate thread, or put this code in your paint handler.

                speaking as ...

                1 Reply Last reply
                0
                • enhzflepE enhzflep

                  Not a word or construct used in the above post is not used in (free to air) tv commercials, played at any hour of the day in this country. To which are you referring? (I assume it is the aussie version of sod off)

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #9

                  enhzflep wrote:

                  To which are you referring?

                  Well you don't need me to spell it out, but I would also refer you to http://www.codeproject.com/Messages/3117206/HOW-TO-ANSWER-A-QUESTION.aspx[^].

                  speaking as ...

                  enhzflepE 1 Reply Last reply
                  0
                  • L Lost User

                    enhzflep wrote:

                    To which are you referring?

                    Well you don't need me to spell it out, but I would also refer you to http://www.codeproject.com/Messages/3117206/HOW-TO-ANSWER-A-QUESTION.aspx[^].

                    speaking as ...

                    enhzflepE Offline
                    enhzflepE Offline
                    enhzflep
                    wrote on last edited by
                    #10

                    I really can't be bothered with this rubbish. Am I to take it from you that the following are insults?

                    • Go away
                    • Nick off
                    • Sod off
                    • Bugger off

                    I'd agree that some may consider it insulting to be told to go away - I consider it insulting to be forced to vote in a democracy. But neither being told to go away or being required to vote is an insult. You may want to turn down the gain on your sensitivity stage.....

                    L 1 Reply Last reply
                    0
                    • enhzflepE enhzflep

                      I really can't be bothered with this rubbish. Am I to take it from you that the following are insults?

                      • Go away
                      • Nick off
                      • Sod off
                      • Bugger off

                      I'd agree that some may consider it insulting to be told to go away - I consider it insulting to be forced to vote in a democracy. But neither being told to go away or being required to vote is an insult. You may want to turn down the gain on your sensitivity stage.....

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #11

                      enhzflep wrote:

                      You may want to turn down the gain on your sensitivity stage.....

                      I am not in the least bothered by such expressions. I just agree with Chris that this sort of language is not appropriate in the general forums.

                      speaking as ...

                      enhzflepE 1 Reply Last reply
                      0
                      • L Lost User

                        enhzflep wrote:

                        You may want to turn down the gain on your sensitivity stage.....

                        I am not in the least bothered by such expressions. I just agree with Chris that this sort of language is not appropriate in the general forums.

                        speaking as ...

                        enhzflepE Offline
                        enhzflepE Offline
                        enhzflep
                        wrote on last edited by
                        #12

                        I won't bother pointing out the fact that you've changed your complaint when challenged. I will point out that

                        1. I provided information that indicated the problem I had with the offending post
                        2. There was no insult in my reply
                        3. There was no sarcasm in my post
                        4. There was no slap-down handed out
                        5. Each of the words used are entirely 10 y/old sister safe

                        I've resigned myself to the realization that if you're prepared to agree, the best we can do is to agree to disagree. If that still doesn't suit you, I suggest you follow point 4 of "HOW TO ANSWER A QUESTION" with regards to my post that you deem so awful. Should there be sufficient repetitions of that direction, my post will evaporate. Before that point, I will not be taking a step backwards.

                        L 1 Reply Last reply
                        0
                        • enhzflepE enhzflep

                          I won't bother pointing out the fact that you've changed your complaint when challenged. I will point out that

                          1. I provided information that indicated the problem I had with the offending post
                          2. There was no insult in my reply
                          3. There was no sarcasm in my post
                          4. There was no slap-down handed out
                          5. Each of the words used are entirely 10 y/old sister safe

                          I've resigned myself to the realization that if you're prepared to agree, the best we can do is to agree to disagree. If that still doesn't suit you, I suggest you follow point 4 of "HOW TO ANSWER A QUESTION" with regards to my post that you deem so awful. Should there be sufficient repetitions of that direction, my post will evaporate. Before that point, I will not be taking a step backwards.

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #13

                          enhzflep wrote:

                          I won't bother pointing out the fact that you've changed your complaint when challenged.

                          I've changed nothing; you are merely trying to justify your use of offensive language.

                          speaking as ...

                          enhzflepE 1 Reply Last reply
                          0
                          • L Lost User

                            enhzflep wrote:

                            I won't bother pointing out the fact that you've changed your complaint when challenged.

                            I've changed nothing; you are merely trying to justify your use of offensive language.

                            speaking as ...

                            enhzflepE Offline
                            enhzflepE Offline
                            enhzflep
                            wrote on last edited by
                            #14

                            Indeed. On reflection, I did make a muck of that. I'd erroneously recalled that you first declared it an insult. Clearly, your definition of offensive and mine do not match. However, it is kid-sister safe. So, do we agree to disagree?:java:

                            L 1 Reply Last reply
                            0
                            • enhzflepE enhzflep

                              Indeed. On reflection, I did make a muck of that. I'd erroneously recalled that you first declared it an insult. Clearly, your definition of offensive and mine do not match. However, it is kid-sister safe. So, do we agree to disagree?:java:

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #15

                              enhzflep wrote:

                              So, do we agree to disagree?[Coffee]

                              Sure, although I'm drinking tea at the moment.

                              speaking as ...

                              enhzflepE 1 Reply Last reply
                              0
                              • L Lost User

                                enhzflep wrote:

                                So, do we agree to disagree?[Coffee]

                                Sure, although I'm drinking tea at the moment.

                                speaking as ...

                                enhzflepE Offline
                                enhzflepE Offline
                                enhzflep
                                wrote on last edited by
                                #16

                                :thumbsup: Makes two of us. (drinking tea at the moment, that is)

                                L 1 Reply Last reply
                                0
                                • enhzflepE enhzflep

                                  :thumbsup: Makes two of us. (drinking tea at the moment, that is)

                                  L Offline
                                  L Offline
                                  Lost User
                                  wrote on last edited by
                                  #17

                                  And just for the record, nothing in the foregoing exchange changes my opinion of your technical abilities (which is on the high side).

                                  speaking as ...

                                  enhzflepE 1 Reply Last reply
                                  0
                                  • L Lost User

                                    And just for the record, nothing in the foregoing exchange changes my opinion of your technical abilities (which is on the high side).

                                    speaking as ...

                                    enhzflepE Offline
                                    enhzflepE Offline
                                    enhzflep
                                    wrote on last edited by
                                    #18

                                    That's very kind of you to mention your favourable view. I have the same opinion of you. I eagerly anticipate the content of your responses whenever I see your username. (perhaps less so for the preceding conversation, though that's another matter :laugh: ) Gee computing is easy when people and personalities aren't involved! Upwards and onwards... Regards, Simon.

                                    L 1 Reply Last reply
                                    0
                                    • enhzflepE enhzflep

                                      That's very kind of you to mention your favourable view. I have the same opinion of you. I eagerly anticipate the content of your responses whenever I see your username. (perhaps less so for the preceding conversation, though that's another matter :laugh: ) Gee computing is easy when people and personalities aren't involved! Upwards and onwards... Regards, Simon.

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #19

                                      enhzflep wrote:

                                      the preceding conversation

                                      Closed and forgotten.

                                      speaking as ...

                                      1 Reply Last reply
                                      0
                                      Reply
                                      • Reply as topic
                                      Log in to reply
                                      • Oldest to Newest
                                      • Newest to Oldest
                                      • Most Votes


                                      • Login

                                      • Don't have an account? Register

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • World
                                      • Users
                                      • Groups