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

53 lines
4.0 KiB
Plaintext

[video output=day004 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Animating the Back Buffer" vod_platform=youtube id=hNKU8Jiza2g annotator=jacebennett annotator=Miblo]
[0:30][Correction about StretchDIBits()/BitBlt()]
[5:20][Writing our custom BitmapMemory allocator. (Note about aligned/unaligned byte access)]
[7:13][Basic math to determine the bytes needed for BitmapMemorySize. 'Width * Height * BytesPerPixel']
[7:57][Description and usage of VirtualAlloc(), the WIN32 memory allocation function we will be using]
[13:15][Making sure we free any allocated memory before we resize, using VirtualFree()]
[15:20][Aside about VirtualProtect(), useful to prevent stale pointers and "use after free" bugs]
[16:49][Step through of Win32ResizeDIBSection()]
[17:45][Changing Win32UpdateWindow() to use BitmapMemory]
[19:30][Adding Bitmap dimensions as global variables (temporarily)]
[20:00][Setting Bitmap Width/Height and using them in Win32ResizeDIBSection()]
[20:20][Setting Window Width/Height in Win32UpdateWindow()]
[21:57][Notes on storing a 2D image inside a 1D "block" of memory. Pitch/Stride.]
[24:30][Setting biHeight to a negative number to ensure the window framebuffer uses a top-down coordinate system with its origin in the top left corner]
[25:59][Note on getting MSVC to give full paths to files in the build output log. (Add -FC to build.bat) Allows emacs to jump between build errors]
[27:00][BUGFIX: Win32UpdateWindow() definition change]
[27:45][Drawing pixels into the bitmap]
[29:05][Adding typedefs for specific type sizes]
[30:39][Casting void* to different size types to make pointer arithmetic simpler for bitmap access]
[33:36][Pixel component layout in memory on Win32. Flipped to read RGB when viewed in the memory registers.]
[38:10][Drawing pixel colors based on the X and Y]
[40:10][Moving bitmap rendering into RenderWeirdGradient()]
[42:40][Adding animation and switching GetMessageA() for PeekMessage() so that Windows doesn't block]
[45:23][Making sure we handle WM_QUIT inside our PeekMessage() loop]
[46:23][Adding XOffset/YOffset variables to the main loop, ++1 them each time through the loop]
[47:40][BUGFIX: Adding our window blitting function (Win32UpdateWindow()) to the main loop, so the bitmap will blit each time through the loop]
[50:25][Changing "WindowHandle" to "Window" and "WindowRect" to "ClientRect"]
[51:56][FINALLY ANIMATION!]
[54:25][Changing DrawWeirdGradient() to use a 32-bit pointer and write each pixel in one call using bitwise operations]
[58:38][Verification of lack of memory leaks]
[59:44][TOTAL SYSTEM MELTDOWN]
[1:02:07][Q&A][:speech]
[1:02:10][Is there a reason you prefer using 0 instead of NULL?]
[1:03:18][Clarification about sized typedefs]
[1:04:58][What would happen if you called malloc() instead of VirtualAlloc()?]
[1:05:32][What's the difference between malloc and new and HeapAlloc()?]
[1:06:27][Do you think you could go as slow as you did previous days in the future?]
[1:07:27][Are we going to use Valgrind in the future?]
[1:07:43][Is the project going to take 2 years?]
[1:08:10][Can you explain why we are using the user32.lib and gdi.lib in the build.bat?]
[1:08:42][Would there be a significant performance increase if we allocated the memory for the bitmap on the stack instead of the heap?]
[1:10:27][Do you know what the PAGE_WRITECOPY Memory Protection flag does?]
[1:15:52][About bytes per pixel and bitmap memory layout. Pitch/Stride. Pitch is byte offset between rows.]
[1:19:49][You mentioned xxBBGGRR because of little endian, why was the blue channel set in this case instead of the padding?]
[1:21:30][Could the padding byte be used as an alpha channel here?]
[1:22:06][Why are we having a wait symbol on the window?]
[1:22:50][Could you explain the offset to X and Y?]
[1:24:00][About the global_variables and the static keyword]
[1:28:15][Static doesn't give you zero on initialization?]
[1:29:38][Do you consider overflowing numbers to be a good coding practice?]
[1:30:23][Note about statics and extern global variables being initialized to zero]
[/video]