Sending WM_PAINT anytime? (no MFC)
-
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. :(
What do you want to do? do you want to send wm_paint?
-
What do you want to do? do you want to send wm_paint?
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. :(
-
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. :(
-
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.
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. :(
-
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. :(
-
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.
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. :(
-
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. :(
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.
-
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.
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. :(
-
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. :(
Lord Kixdemp wrote:
but do you live in these forums
Not exactly.;)
-
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. :(
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