cinera_handmade.network/cmuratori/hero/code/code225.hmml

48 lines
3.9 KiB
Plaintext
Raw Normal View History

[video output=day225 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Fading In and Out from the Windows Desktop" vod_platform=youtube id=hsKMH89VmR8 annotator=Miblo]
[1:15][Recap our current situation]
[1:45][Internet: SetLayeredWindowAttributes[ref
site=MSDN
page="SetLayeredWindowAttributes function"
url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms633540]]
[2:56][win32_handmade.cpp: Create a fullscreen window that's transparent but black, and gradually increase its opacity]
[5:01][Run the game and see the fade-out]
[5:15][win32_handmade.cpp: Make the fade-out routine something that can be called incrementally]
[9:24][Run the game and see that nothing happens]
[9:47][win32_handmade.cpp: Defer calling ShowWindow until FadeAlpha is 1.0f]
[13:58][win32_handmade.cpp: Enable the timing loop]
[14:13][Run the game and see a slight flicker on the transition]
[16:04][Debugger: Step into ShowWindow]
[18:35][win32_handmade.cpp: Try doing ToggleFullscreen after showing it, then try and force a repaint[ref
site="MSDN"
page="InvalidateRect function"
url="https://msdn.microsoft.com/en-us/library/windows/desktop/dd145002"]]
[20:39][win32_handmade.cpp: Set WindowsAlpha = 255 and test if(IsWindowVisible)]
[27:32][Debugger: Break into ShowWindow in SetFadeAlpha and see it's not getting called]
[28:23][Spy++: Look at the Window Styles]
[31:08][win32_handmade.cpp: Correct the FadingComplete / ShowingComplete tests][quote 341]
[31:43][Run the game and see that we don't have our glitch]
[32:35][win32_handmade.cpp: Introduce dFadeAlpha to fade back to the desktop]
[38:15][win32_handmade.h: Introduce win32_fader_state and win32_fader]
[40:37][win32_handmade.cpp: Introduce UpdateFade]
[41:23][win32_handmade.cpp: Make a little finite state machine for the fades]
[44:25][win32_handmade.cpp: Briefly describe the finite state machine]
[45:05][win32_handmade.h: Add Win32Fade_FadingGame to win32_fader_state]
[46:46][win32_handmade.cpp: Introduce InitFader, BeginFadein and BeginFadeOut]
[53:37][win32_handmade.cpp: Only do BeginFadeToDesktop if Win32Fade_Inactive]
[54:28][Run the game and see that we're working properly]
[54:59][Q&A][:speech]
[55:44][@m1el][Casey, you need one more state to wait for alpha-enabled window to show, because you might have the same bug when you fade to desktop]
[57:25][@SteelGolem][Your fading setup seems overcomplicated to me. Why not just take a screenshot, blit that to the back buffer, and fade that? What platforms wouldn't that work for?]
[1:00:26][@insofaras][Why are you using a second window for the fade in, instead of just fading in the main window?]
[1:02:06][@Miblo][Wow, thank you for such a comprehensive A: to my Q:. That's exactly what I wanted! Another small one: Would it be possible to make bits of the window transparent, e.g. for the situation where some monstar has torn a hole in the game window, revealing the desktop beneath?]
[1:03:31][@Mr4thDimention][Suppose you're Microsoft, but instead of wanting all of the money in the world you just want to make a living selling your OS. Do you think you could do that while providing a good way for users of your platform to debug the code that uses your API?]
[1:05:17][@insofaras][Can you not unset the layered window flag after doing the fade?]
[1:07:15][@SteelGolem][Wait, why can I Alt-PrintScreen to capture HDCP with windows but I can't take a screencap manually? I have lots of screenshots of my PS3 through the player via prntscrnt]
[1:08:53][@blah238][So this detour was all about startup and shutdown fades, but how would you implement fading in between in-game scenes? This shouldn't involve the Windows API, correct?]
[1:09:25][handmade_cutscene.h: Add tFadeIn to layered_scene]
[1:10:35][handmade_cutscene.cpp: Implement fade to black between cutscene shots]
[1:12:56][Run the game and see that fade]
[1:13:27][Note that the alpha must be gamma corrected]
[1:16:41][We are out of time][:speech]
[/video]