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. OpenGL

OpenGL

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsgame-devhelp
9 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.
  • V Offline
    V Offline
    v_krishnan
    wrote on last edited by
    #1

    Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan

    T M P 3 Replies Last reply
    0
    • V v_krishnan

      Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Does your scene change every 100 msecs? Tomasz Sowinski -- http://www.shooltz.com.pl

      V 1 Reply Last reply
      0
      • V v_krishnan

        Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan

        M Offline
        M Offline
        Masoud Samimi
        wrote on last edited by
        #3

        Hi, Having the advantage of using MFC, you could do any of the followings: 1/ The best is to create a separate thread to do that particular job for you while the application is idle. 2/ The other option is to have the message pump method. 3/ Last but not least, is to put your anmation code in the OnIdle method of the application class. Override the OnIdle and try your code lines there. Hope these helped. Cheers! :)

        1 Reply Last reply
        0
        • T Tomasz Sowinski

          Does your scene change every 100 msecs? Tomasz Sowinski -- http://www.shooltz.com.pl

          V Offline
          V Offline
          v_krishnan
          wrote on last edited by
          #4

          Well, not whole of the scene, but some disjoint parts of the scene change. Currently, I redraw the whole picture. Is there any way to restrict drawing of only those parts which change and leaving the unchanged part intact? Thanks, Krishnan

          T 1 Reply Last reply
          0
          • V v_krishnan

            Well, not whole of the scene, but some disjoint parts of the scene change. Currently, I redraw the whole picture. Is there any way to restrict drawing of only those parts which change and leaving the unchanged part intact? Thanks, Krishnan

            T Offline
            T Offline
            Tomasz Sowinski
            wrote on last edited by
            #5

            > Is there any way to restrict drawing of only those parts > which change and leaving the unchanged part intact? Honestly, I don't know. But I think you need to move your rendering code to separate thread to make app UI responsive. I'd render to a bitmap and then blt results to the screen. Of course, you'll have to use some synchronization stuff (critical sections). Tomasz Sowinski -- http://www.shooltz.com.pl

            V 1 Reply Last reply
            0
            • T Tomasz Sowinski

              > Is there any way to restrict drawing of only those parts > which change and leaving the unchanged part intact? Honestly, I don't know. But I think you need to move your rendering code to separate thread to make app UI responsive. I'd render to a bitmap and then blt results to the screen. Of course, you'll have to use some synchronization stuff (critical sections). Tomasz Sowinski -- http://www.shooltz.com.pl

              V Offline
              V Offline
              v_krishnan
              wrote on last edited by
              #6

              I have done some performance tests on my app. They show that the time to actually issue OpenGL commands is more than the time to swap the buffers. as far as multithreading is concerned, I don't think that the CPU load would decrease by that.

              T 1 Reply Last reply
              0
              • V v_krishnan

                I have done some performance tests on my app. They show that the time to actually issue OpenGL commands is more than the time to swap the buffers. as far as multithreading is concerned, I don't think that the CPU load would decrease by that.

                T Offline
                T Offline
                Tomasz Sowinski
                wrote on last edited by
                #7

                : as far as multithreading is concerned, I don't think that : the CPU load would decrease by that. Multithreading is not going to reduce CPU load. Moving the rendering code to second thread will make your application *more responsive* - users will be able to more easily select options from the menu, resize the window or exit the program. Tomasz Sowinski -- http://www.shooltz.com.pl

                1 Reply Last reply
                0
                • V v_krishnan

                  Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan

                  P Offline
                  P Offline
                  Pete Bassett
                  wrote on last edited by
                  #8

                  Heres a mulit threaded OpenGL View class for you to use. It handles all of the threading issues for you. You just put your drawing code in the correct overloaded method and away you go... http://mkennedy.101main.com/software/OpenGLandCPP.asp Pete

                  P 1 Reply Last reply
                  0
                  • P Pete Bassett

                    Heres a mulit threaded OpenGL View class for you to use. It handles all of the threading issues for you. You just put your drawing code in the correct overloaded method and away you go... http://mkennedy.101main.com/software/OpenGLandCPP.asp Pete

                    P Offline
                    P Offline
                    Pete Bassett
                    wrote on last edited by
                    #9

                    Haha! "Mulit threadded" pete

                    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