78 lines
6.1 KiB
Plaintext
78 lines
6.1 KiB
Plaintext
[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Handling Multiple Display Aspect Ratios" vod_platform=youtube id=EKxPnlQ2ipI annotator=Miblo]
|
|
[0:10][Recap and set the stage for the day]
|
|
[0:35][Consult the issues[ref
|
|
site="GitHub"
|
|
page="HandmadeHero/cpp Issues"
|
|
url="https://github.com/HandmadeHero/cpp/issues"]]
|
|
[2:11][Determine to fix the "Wrong glViewport parameters" issue]
|
|
[3:52][Run the game and demo the resizing situation]
|
|
[5:01][handmade_opengl.cpp: Make OpenGLDisplayBitmap() and OpenGLRenderCommands() pass the WindowWidth and WindowHeight to glViewport()]
|
|
[6:27][Run the game and see how it now looks]
|
|
[9:00][Blackboard: Aspect Ratio Resize]
|
|
[11:03][Blackboard: No aspect ratio support]
|
|
[12:57][Blackboard: Aspect-awareness]
|
|
[16:48][Blackboard: Black bar]
|
|
[18:12][Blackboard: Our two cases]
|
|
[19:38][handmade_render.cpp: Introduce AspectRatioFit()]
|
|
[23:43][Blackboard: Calculating aspect ratios]
|
|
[27:16][handmade_render.cpp: Make AspectRatioFit() calculate the optimal dimensions based on that fundamental aspect ratio]
|
|
[34:22][handmade_opengl.cpp: Make OpenGLRenderCommands() take the DrawRegion and pass it to glViewport()]
|
|
[35:41][handmade_math.h: Introduce GetWidth() and GetHeight()]
|
|
[39:20][handmade_opengl.cpp: Introduce OpenGLBindFramebuffer()]
|
|
[40:54][Run the game and see that it looks the same]
|
|
[41:06][win32_handmade.cpp: Make Win32DisplayBufferInWindow() call AspectRatioFit() to set the DrawRegion]
|
|
[42:08][Run the game and try out the new resizing]
|
|
[43:24][handmade_opengl.cpp: Make OpenGLDisplayBitmap() take the DrawRegion and pass it to OpenGLBindFramebuffer()]
|
|
[45:04][Run the game and see that it just works]
|
|
[45:33][handmade_opengl.cpp: Make OpenGLDisplayBitmap() clear to the ClearColor and prevent OpenGLRenderCommands() from drawing the outlines]
|
|
[47:53][Run the game, see how it all is and close that issue]
|
|
[49:33][Determine to fix the "Incorrect Unproject" issue]
|
|
[51:53][win32_handmade.cpp: DrawRegion WinMain()]
|
|
[53:17][win32_handmade.cpp: Remove the win32_rendering_type enum in favour of a single GlobalSoftwareRendering]
|
|
[54:21][Run the game and ensure that toggling the software renderer still works]
|
|
[54:43][win32_handmade.cpp: Make WinMain() compute DrawRegion early on and make all the appropriate functions take it]
|
|
[56:52][win32_handmade.cpp: Make WinMain() map the mouse position to the DrawRegion]
|
|
[58:56][Run the game and see if the mouse cursor is now working okay]
|
|
[1:00:01][win32_handmade.cpp: Make WinMain() base the mouse position on the RenderCommands dimensions]
|
|
[1:00:31][Run the game and see that the mouse cursor is still failing]
|
|
[1:01:59][Debugger: Resize the window, step in to WinMain() and inspect the MouseU and MouseV]
|
|
[1:03:21][win32_handmade.cpp: Make WinMain() correctly compute the MouseY]
|
|
[1:03:56][Run the game and see that the mouse coordinates are now being passed correctly]
|
|
[1:04:18][Q&A][:speech]
|
|
[1:05:22][Close that issue]
|
|
[1:06:39][@cubercaleb][(Before today) I have a 1600x900 monitor and when I change the code to render at that resolution, both the UI picking and the collision detection for the player get all sorts of messed up, but I haven't tested that since you removed the free moving stuff]
|
|
[1:06:57][@hayai][Can you make it so that holding shift while resizing the window makes it just scale at the intended aspect ratio?]
|
|
[1:07:52][@shinny_magikarp][Casey, you forgot to change "UseHeight" to "UseWidth" on the second case of the black bar size's definition]
|
|
[1:08:09][@deravadom][Two parter, if that's okay: A) I'd like to start working on a homemade 3D game engine of my own. How much of what you have done here transfers over? B) When do you define how long a second is in the game? How does the lighting work in regards to time?]
|
|
[1:09:08][@danyguag][How would you suggest a younger developer to get into OpenGL and all of its useful extensions?[ref
|
|
site="NVIDIA GameWorks"
|
|
page="OpenGL like Vulkan"
|
|
url="https://developer.nvidia.com/opengl-vulkan"]]
|
|
[1:11:08][@rohit_n][Did you ever go through the NSight plugin on stream?]
|
|
[1:11:29][@snoringtortoise][Off-topic: Which keyboard layout do you use? Have you tried the various layouts? I've read that QWERTY can be a bit less efficient for programming, what do you think?]
|
|
[1:11:57][@danyguag][I have some experience in OpenGL but not with the extensions]
|
|
[1:17:07][win32_handmade.cpp: Make Win32MainWindowCallback() handle fixed aspect ratio window resizing based on Raymond Chen's advice[ref
|
|
site="The Old New Thing"
|
|
page="Use WM_WINDOWPOSCHANGING to intercept window state changes"
|
|
url="https://blogs.msdn.microsoft.com/oldnewthing/20080116-00/?p=23803"]]
|
|
[1:23:56][Blackboard: Calculating that new window height]
|
|
[1:25:58][Run the game and try resizing the window]
|
|
[1:26:31][win32_handmade.cpp: Make Win32MainWindowCallback() only do aspect ratio constrained resize if the shift key is held down]
|
|
[1:27:30][Run the game and try resizing with the shift key held down]
|
|
[1:29:57][Debugger: Break into Win32MainWindowCallback() to determine what the cx and cy are, and investigate what is happening with the flicker]
|
|
[1:35:59][Debugger: Run the game and observe our WM_WINDOWPOSCHANGING output]
|
|
[1:37:35][win32_handmade.cpp: Make Win32MainWindowCallback() set the NewPos based on which coordinate is closer]
|
|
[1:38:53][Run the game and see if that helps]
|
|
[1:40:10][win32_handmade.cpp: Make Win32MainWindowCallback() output the aspect ratio]
|
|
[1:40:57][Run the game and observe that aspect ratio]
|
|
[1:41:46][win32_handmade.cpp: Make Win32MainWindowCallback() adjust the aspect ratio to ignore the window decorations]
|
|
[1:43:16][Blackboard: Computing the aspect ratio for the ClientRect]
|
|
[1:46:59][Run the game and see what that does]
|
|
[1:48:56][Blackboard: Double-check the maths]
|
|
[1:49:16][win32_handmade.cpp: Make Win32MainWindowCallback() compute the NewCx and NewCy differently]
|
|
[1:50:41][win32_handmade.cpp: Make Win32MainWindowCallback() set GetWindowRect, run the game and see that it works]
|
|
[1:52:03][@hayai][Yes, it helps]
|
|
[1:52:14][@cubercaleb][For AdjustWindowRect you should pass WS_OVERLAPPEDWINDOW which is different from WS_OVERLAPPED, although perhaps you meant that?]
|
|
[1:52:43][Wrap it up][:speech]
|
|
[/video]
|