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. Sending WM_PAINT anytime? (no MFC)

Sending WM_PAINT anytime? (no MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
c++game-devjsonquestion
11 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.
  • L Lord Kixdemp

    Hello, my fellow programmers! I'm trying to make a (simple) game using the Windows API. There's no animation, and probably won't be any time in the future, so the only time the game screen (which is stored in its own control) needs to be updated is right after user input. I got this working right by using InvalidateRect(hwnd, NULL, FALSE); after handling WM_KEYDOWN, but this causes a bit of flicker... I thought, "isn't there a vsync() style function?", but then, if the flicker is as noticeable as it is, then that means it's taking too much time to draw the game, which isn't good. I thought of using dirty rectangles (easy task since the game only consists of 32x32 tiles), but would that completely remove the flicker? Even on slower machines? Thanks in advance!

    Windows Calculator told me I will die at 28. :(

    H Offline
    H Offline
    Hamid Taebi
    wrote on last edited by
    #2

    What do you want to do? do you want to send wm_paint?

    L 1 Reply Last reply
    0
    • H Hamid Taebi

      What do you want to do? do you want to send wm_paint?

      L Offline
      L Offline
      Lord Kixdemp
      wrote on last edited by
      #3

      Nevermind, I solved it, sorry for the noise... Turned out I was using the wrong flags on BitBlt. :wtf: It now works like a charm. [joke] And, Hamid, no offense, but do you live in these forums? You seem to be in like, every thread. :laugh: [/joke]

      Windows Calculator told me I will die at 28. :(

      H N 2 Replies Last reply
      0
      • L Lord Kixdemp

        Hello, my fellow programmers! I'm trying to make a (simple) game using the Windows API. There's no animation, and probably won't be any time in the future, so the only time the game screen (which is stored in its own control) needs to be updated is right after user input. I got this working right by using InvalidateRect(hwnd, NULL, FALSE); after handling WM_KEYDOWN, but this causes a bit of flicker... I thought, "isn't there a vsync() style function?", but then, if the flicker is as noticeable as it is, then that means it's taking too much time to draw the game, which isn't good. I thought of using dirty rectangles (easy task since the game only consists of 32x32 tiles), but would that completely remove the flicker? Even on slower machines? Thanks in advance!

        Windows Calculator told me I will die at 28. :(

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #4

        Do you really need to invalidate the entire client area? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        In testa che avete, signor di Ceprano?

        L 1 Reply Last reply
        0
        • CPalliniC CPallini

          Do you really need to invalidate the entire client area? :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

          L Offline
          L Offline
          Lord Kixdemp
          wrote on last edited by
          #5

          I'll use the typical programmer's excuse to write crappy code: it was 3 AM and I didn't want to write code to check which parts needed updating. X| (Actually, it was 5 PM, but I hadn't slept at all that night... :laugh:)

          Windows Calculator told me I will die at 28. :(

          CPalliniC 1 Reply Last reply
          0
          • L Lord Kixdemp

            I'll use the typical programmer's excuse to write crappy code: it was 3 AM and I didn't want to write code to check which parts needed updating. X| (Actually, it was 5 PM, but I hadn't slept at all that night... :laugh:)

            Windows Calculator told me I will die at 28. :(

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #6

            Really you work too much for being a Lord. :-D

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

            In testa che avete, signor di Ceprano?

            L 1 Reply Last reply
            0
            • CPalliniC CPallini

              Really you work too much for being a Lord. :-D

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

              L Offline
              L Offline
              Lord Kixdemp
              wrote on last edited by
              #7

              Yeah, day and night don't exist for me anymore...

              while (Leo->IsAlive()
              {
                  Leo->WakeUp();
                  Laptop->ResumefromHibernate();
                  Laptop->m_aMessages = Email->Check();
                  Laptop->Hibernate();
                  Leo->Exercise(30);
                  Laptop->ResumefromHibernate();
              
                  Laptop->OpenEnvironment();
                  while (Leo->m_pBody->m_pEyes[0]->CanStayOpen() &&
                      Leo->m_pBody->m_pEyes[1]->CanStayOpen())
                  {
                      Leo->Code(Laptop);
                  }
              
                  Leo->GoToSleep();
              }
              

              Pretty sad, no? ;P

              Windows Calculator told me I will die at 28. :(

              CPalliniC 1 Reply Last reply
              0
              • L Lord Kixdemp

                Yeah, day and night don't exist for me anymore...

                while (Leo->IsAlive()
                {
                    Leo->WakeUp();
                    Laptop->ResumefromHibernate();
                    Laptop->m_aMessages = Email->Check();
                    Laptop->Hibernate();
                    Leo->Exercise(30);
                    Laptop->ResumefromHibernate();
                
                    Laptop->OpenEnvironment();
                    while (Leo->m_pBody->m_pEyes[0]->CanStayOpen() &&
                        Leo->m_pBody->m_pEyes[1]->CanStayOpen())
                    {
                        Leo->Code(Laptop);
                    }
                
                    Leo->GoToSleep();
                }
                

                Pretty sad, no? ;P

                Windows Calculator told me I will die at 28. :(

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #8

                Uhm...

                Lord Kixdemp wrote:

                Leo->Exercise(30);

                Is this time subtracted to coding? :-D

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

                In testa che avete, signor di Ceprano?

                L 1 Reply Last reply
                0
                • CPalliniC CPallini

                  Uhm...

                  Lord Kixdemp wrote:

                  Leo->Exercise(30);

                  Is this time subtracted to coding? :-D

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

                  L Offline
                  L Offline
                  Lord Kixdemp
                  wrote on last edited by
                  #9

                  Yep. I spent my time coding, sleeping, and 30 minutes of exercise... if I'm not feeling lazy.;)

                  Windows Calculator told me I will die at 28. :(

                  1 Reply Last reply
                  0
                  • L Lord Kixdemp

                    Nevermind, I solved it, sorry for the noise... Turned out I was using the wrong flags on BitBlt. :wtf: It now works like a charm. [joke] And, Hamid, no offense, but do you live in these forums? You seem to be in like, every thread. :laugh: [/joke]

                    Windows Calculator told me I will die at 28. :(

                    H Offline
                    H Offline
                    Hamid Taebi
                    wrote on last edited by
                    #10

                    Lord Kixdemp wrote:

                    but do you live in these forums

                    Not exactly.;)

                    1 Reply Last reply
                    0
                    • L Lord Kixdemp

                      Nevermind, I solved it, sorry for the noise... Turned out I was using the wrong flags on BitBlt. :wtf: It now works like a charm. [joke] And, Hamid, no offense, but do you live in these forums? You seem to be in like, every thread. :laugh: [/joke]

                      Windows Calculator told me I will die at 28. :(

                      N Offline
                      N Offline
                      Nelek
                      wrote on last edited by
                      #11

                      Can you share the solution? It may help at least 4 or 5 users that asked about flickering in the last days.

                      Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                      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