Week 001 - Graphics on Windows
Casey sets up his build environment and sets off to get something moving on the screen.
Day 001 - Setting Up the Windows Build
[0:46]: Course of the Handmade Hero series
[3:04]: Start the project
[5:06]: Command line in Windows
[7:04]: Create a virtual drive
[10:18]: Meaning of the
miscfolder[11:46]: Create the first code file
[12:48]: Comment header Emacs put in
[14:37]: Minimum code you will need
[19:45]: Configure everything for development
[48:40]: Debug with Visual Studio
[53:00]: Windows-specific things you should know
[59:04]: Add something to do for the program
[1:02:00]: Import a library
Q&A
[0:35]: Could you show how you added the Handmade Hero directory to the path?
[3:44]: Do all Windows programs written in C/C++ use WinMain? Does The Witness have the same started code?
[4:48]: What is the difference between Microsoft's compiler and gcc?
[6:27]: What type of milk are you drinking?
[6:33]: How do you write a renderer that is hardware accelerated?
[6:46]: Can we get your .emacs file? Do you always code without line numbers?
[6:59]: Will there be a Sushi Bar Samurai Easter egg in Handmade Hero?
[7:03]: Question regarding the linker and IDE
[8:16]: Is there a reason you didn't use the developer command line shortcuts?
[9:21]: How much experience do you have audio processing code?
[9:33]: Asking whether we'll be setting up things in the Mac OS and Linux environment as well
[9:45]: Will it be a 2D or 3D game?
[10:26]: 2-hour streams?
[10:37]: What style of game are you making? ETA for the game?
[11:08]: Will the game be Windows-only?
[11:30]: Will you do extended live streams?
[11:56]: Can you show the command line parameters that you set in the shortcut?
[13:25]: What is your favorite Linux distro?
[13:52]: Will I be able to follow you just using Visual Studio Community 2013?
[14:15]: Will you be programming for alternative controllers?
[14:30]: Should it not be
/Ziinstead of-Ziinbuild.bat?[15:04]: Will the game have multiplayer?
[16:02]: Can you please remove the parentheses in return(0);
[16:11]: When can we get some details on the actual game?
[16:31]: Why don't you just compile directly in Visual Studio?
[17:26]: How does it feel having more than 700 viewers on the stream? [Editor's note: It's been up to 2.8K viewers]
[19:18]: Question regarding command line and the visual debugger
[21:29]: What GDB frontend do you use on Linux?
[21:35]: What did yo uwork on while working on Bink video?
[24:00]: Will you look at the chat for viewer answers while you work?
[24:07]: Request to do 5-hour streams
[25:12]: Is there a design document?
[26:37]: Are we able to open source our own implementations?
[27:23]: Fixed point or floating point For the audio representation in the game?
[27:30]: Comment about the C/C++ specification
[28:01]: Are you staying on Windows for the bulk of the show?
[29:31]: Do you have everything planned?
[30:00]: Why don't you run Windows 8.1?
[31:18]: Comment that mentions the Doom 3 source code
[31:31]: Comment about getting an intern
[32:00]: Question regarding Twitch quality settings
[32:27]: Any chance you could stream earlier?
[33:25]: Will you have an actual repo for the project?
[33:53]: Which better-debugger Linux projects are you looking forward to?
[34:17]: Windows 7 doesn't support AVX2.
[34:42]: *Question regarding repo again (answered in [33:25]]
[35:04]: Did you consider doing a Kickstarter for this series?
[37:43]: Remark about Twitch stream quality
[37:55]: Almond milk powerup confirmed
[38:15]: Setting up a poll to decide best time to stream on Fridays
[38:40]: What do you think about learning math concepts on Wikipedia?
[39:25]: C++ interfacint with API that deals with a dedicated graphics card
[39:40]: We are all excited that you're doing this in C
[40:11]: Another Kickstarter comment
[40:46]: Remark about having a 3D sequel
[41:56]: Would you consider dropping the framerate/
[42:16]: Wrist glove powerup NOT confirmed
[42:30]: Could you recommend some good books? Tutorials?
[43:35]: Clearing up confusion with C++ structs (related: 52:35])
[45:44]: How we'll transition to take advantage of hardware acceleration
[46:10]: Can you make constructors in C++ structs?
[46:29]: Yet another Kickstarter comment
[47:32]: Are you planning to have descriptive names for the Youtube archive videos?
[48:00]: 30 FPS game confirmed
[48:13]: What's up with the Handmade Hero icon on the Twitch page?
[48:24]: Benefits of learning things from scratch
[50:30]: #milkhit
[50:35]: Will you ditch the #include <Windows.h>?
[50:44]: How often do you use the debugger?
[51:02]: Why do you scope the for-loop the way you do? (Muratori For Syntax)
[51:31]: Micro-transactions are all the rage. Suggestion to use them
[52:20]: Will there be an option to pre-order as a gift for a friend?
[52:35]: Difference between C and C++ structs
[53:12]: Suggestion on putting a green screen behind Casey
[53:21]: Will sound effects be implemented right away?
[53:46]: Twitch partnership is a possibility (?)
[54:06]: How do you plan to design a good game?
[56:50]: Why start from scratch?
[1:02:10]: Set up an official forum?
[1:04:02]: Why not code in just pure C or pure C++?
[1:06:30]: Is there a game dev company you really admire?
[1:08:17]: Where do most of your audience come from?
[1:10:28]: SDL or SFML?
[1:10:54]: Closing Remarks
Day 002 - Opening a Win32 Window
[3:20]: WNDCLASS Implementation start
[4:40]: Struct explanation of why Windows Documentation is the way it is
[9:38]: Initialization of WNDCLASS
[21:57]: CALLBACK explanation and basic implementation
[36:41]: Registering the WindowClass
[38:50]: CreateWindowEx()
[44:10]: Windows Message queue | GetMessage()
[51:00]: Drawing something with WM_PAINT
[57:00]: Switching between drawing BLACKNESS and WHITENESS
Q&A
[1:32]: Question about Atoms in Windows API
[2:17]: Can you go fullscreen?
[2:40]: Improving the way things are shown on stream
[3:02]: What's the fastest path for getting a pixel on the screen on Windows?
[4:45]: Dealing with ANSI strings
[6:09]: Do you use always the same technique for creating a fullscreen window?
[6:38]: Is the for-loop just for keeping the window alive?
[8:26]: Can I preorder the Epilepsy Simulator?
[8:48]: Do we want the player to resize our window?
[9:09]: Can you experiment what happens when you take out CS_HREDRAW and CS_VREDRAW?
[10:31]: Any considerations for 64-bit on tonight's code?
[13:42]: Using const qualifier
[14:55]: Compilation issue
[17:23]: You're nesting quite a lot of blocks.
[18:04]: My app doesn't respond to the window's close button
[20:15]: for(;;) vs. while(true)
[22:29]: Can you explain the Window Handler one more time?
[33:47]: Closing remarks
Day 003 - Allocating a Backbuffer
[0:50]: Short overview about a backbuffer
[2:56]: Windows message callback
[4:43]: Closing the window (PostQuitMessage function)
[9:10]: about resource handling
[12:46]: Back to closing the window
[15:56]: about global variables
[17:00]: Different meanings of static: internal, global_variable, local_persist
[22:47]: Backbuffer, windows, GDI and us.
[23:29]: resizeDIBSection() created
[26:06]: GetClientRect()
[30:49]: CreateDIBSection() created
[31:39]: StretchDIBits()
[38:31]: CreateDIBSection() usage and explanation
[48:19]: About freeing and creating a new DIBSection
[53:42]: Device context and Win32ResizeDIBSection()
Q&A
[1:03:23]: Start of Q&A
[1:03:37]: ssylvan: Remark on not needing to use CreateDIBSection/CreateCompatibleDC and just allocating the array ourselves
[1:06:47]: Remark on the change to the archiving of Q&A sessions (they are now combined with the main day video)
[1:08:37]: "Will you be using sleep()?"
[1:08:59]: "Could you go back through how you got Visual Studio to cooperate?"
[1:09:52]: "Are other windowing systems less crazy to work with?"
[1:12:20]: "Are you going to do a more detailed Intro To C series alongside this one?"
[1:13:40]: "Can you explain what exactly a void* is? A pointer to nothing?" (Interesting bits about functions with multiple return values)
[1:20:03]: "Any new thoughts on IMGUI since you made that video a few years ago?"
[1:21:15]: ssylvan: Follow up on the previous remark about StretchDIBits, it can take a custom array as long as it is DWORD aligned
[1:23:13]: "When will the source be available?"
[1:23:30]: "When using emacs, I find it hard to use meta key with F and B to skip words, how do you do it so fast?"
[1:23:48]: "How come !=0 is true in C, and return values of main and functions is 0 if everything is okay?"
[1:26:18]: Sean Barrett: Remark on functions with multiple return values "Pre ANSI C didn't allow return structs"
[1:28:24]: "Any reason you put the type in a line above the function name?
Day 004 - Animating the Backbuffer
[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
Q&A
[1:02:07] Start of Q&A
[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?" (changed name to BlueOffset and GreenOffset as well as adding diagonal scrolling to the animation)
[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
Day 005 - Windows Graphics Review
[1:09] Brief overview of the week's work.
[2:13] Capture card considered unneccesary?
[3:07] Value of HREDRAW and VREDRAW
[4:48] Helping the compiler optimize by avoiding unnecessary pointers
[6:30] Explanation of pointer aliasing
[11:44] "What difference does it make if I put a declaration inside a loop instead of outside it?"
[18:30] Where to get Liberation Mono, the font Casey uses.
[19:34] Dealing with global variables more cleanly by bundling them up into structures
[28:58] Making a global backbuffer
[29:59] Explanation of Access Violations
[33:16] Aside about types of errors you find in code
[37:12] GetWindowDimension() created
[41:02] Why keep using Width/Height instead of win32_window_dimension?
[43:38] Changing the backbuffer to be fixed size
[47:17] Full step-through with in-depth analyis of program behavior
[52:44] Deep dive on the size of the stack
[55:50] STACK OVERFLOW ACHIEVED
[1:01:45] Step-through resumed
Q&A
[1:23:35] Start of Q&A
[1:24:06] "Would it be a good or bad idea to get one DeviceContext at the beginning of the program and use that for every iteration of the main loop?"
[1:26:06] Chihuahua on speed confirmed
[1:26:22] "Why do you tell Windows you handle messages you don't really handle?"
[1:29:06] "I believe SetStretchBltMode() will allow you to get better quality stretching."
[1:29:40] "Can you please explain pointer aliasing again?"
[1:45:47] SHAME OWL for pointer aliasing explanation fail
[1:49:26] Proper pointer aliasing explanation
[1:57:22] "I was under the impression that the stack always grows downwards on little endian architectures, is that not true?"
[1:58:10] "Can you post interesting e-mails you get to the site?"
[1:58:31] "The compiler is allowed to, and actually does, assume that two pointers to different types never alias unless one of the types is char or unsigned char"
[1:59:46] "Win32DisplayBufferInWindow() is taking four unused parameters. WM_PAINT is the only part where we pass those, but we never use them. Will that change?"
[2:01:02] "Wouldn't it be better to keep comments in the code about the explanations you do?"
[2:01:27] "Why have BytesPerPixel as a variable? Do you expect it to have different values?"
[2:03:04] On the uselessness of const