Handmade Hero»Episode Guide
Enabling the OpenGL Depth Buffer
?
?

Keyboard Navigation

Global Keys

[, < / ], > Jump to previous / next episode
W, K, P / S, J, N Jump to previous / next marker
t / T Toggle theatre / SUPERtheatre mode
V Revert filter to original state Y Select link (requires manual Ctrl-c)

Menu toggling

q Quotes r References f Filter y Link c Credits

In-Menu Movement

a
w
s
d
h j k l


Quotes and References Menus

Enter Jump to timecode

Quotes, References and Credits Menus

o Open URL (in new tab)

Filter Menu

x, Space Toggle category and focus next
X, ShiftSpace Toggle category and focus previous
v Invert topics / media as per focus

Filter and Link Menus

z Toggle filter / linking mode

Credits Menu

Enter Open URL (in new tab)
1:32Run the game, recap and set the stage for the day
1:32Run the game, recap and set the stage for the day
1:32Run the game, recap and set the stage for the day
4:55Blackboard: Using the Z-buffer to sort ground tiles
4:55Blackboard: Using the Z-buffer to sort ground tiles
4:55Blackboard: Using the Z-buffer to sort ground tiles
6:35Blackboard: Slanting the upright sprites to make them occlude each other properly
6:35Blackboard: Slanting the upright sprites to make them occlude each other properly
6:35Blackboard: Slanting the upright sprites to make them occlude each other properly
13:55Run the game and illustrate why this scheme will be important for debugging purposes
13:55Run the game and illustrate why this scheme will be important for debugging purposes
13:55Run the game and illustrate why this scheme will be important for debugging purposes
14:08"We're going to write some code and hope that it's right"α
14:08"We're going to write some code and hope that it's right"α
14:08"We're going to write some code and hope that it's right"α
14:56Determine to turn on the Z-buffer1
14:56Determine to turn on the Z-buffer1
14:56Determine to turn on the Z-buffer1
15:36handmade_opengl.cpp: Make OpenGLRenderCommands() enable GL_DEPTH_TEST and call glDepthMask()2 and glColorMask()
15:36handmade_opengl.cpp: Make OpenGLRenderCommands() enable GL_DEPTH_TEST and call glDepthMask()2 and glColorMask()
15:36handmade_opengl.cpp: Make OpenGLRenderCommands() enable GL_DEPTH_TEST and call glDepthMask()2 and glColorMask()
21:40win32_handmade.cpp: Make Win32SetPixelFormat() set cDepthBits3
21:40win32_handmade.cpp: Make Win32SetPixelFormat() set cDepthBits3
21:40win32_handmade.cpp: Make Win32SetPixelFormat() set cDepthBits3
25:00win32_handmade.cpp: Make Win32SetPixelFormat() specify the colour bits4
25:00win32_handmade.cpp: Make Win32SetPixelFormat() specify the colour bits4
25:00win32_handmade.cpp: Make Win32SetPixelFormat() specify the colour bits4
28:39Run the game, see nothing on the screen and investigate why
28:39Run the game, see nothing on the screen and investigate why
28:39Run the game, see nothing on the screen and investigate why
29:24handmade_opengl.cpp: Make OpenGLRenderCommands() pass GL_DEPTH_BUFFER_BIT to glClear()
29:24handmade_opengl.cpp: Make OpenGLRenderCommands() pass GL_DEPTH_BUFFER_BIT to glClear()
29:24handmade_opengl.cpp: Make OpenGLRenderCommands() pass GL_DEPTH_BUFFER_BIT to glClear()
31:56Run the game to see that we're getting Z-tested drawing
31:56Run the game to see that we're getting Z-tested drawing
31:56Run the game to see that we're getting Z-tested drawing
32:42Blackboard: Preventing fully transparent pixels from entering the Z-buffer
32:42Blackboard: Preventing fully transparent pixels from entering the Z-buffer
32:42Blackboard: Preventing fully transparent pixels from entering the Z-buffer
36:25handmade_opengl.cpp: Make OpenGLRenderCommands() enable and call glAlphaFunc()5
36:25handmade_opengl.cpp: Make OpenGLRenderCommands() enable and call glAlphaFunc()5
36:25handmade_opengl.cpp: Make OpenGLRenderCommands() enable and call glAlphaFunc()5
38:24handmade_opengl.cpp: Temporarily make glAlphaFunc() operate for alpha values greater than 0
38:24handmade_opengl.cpp: Temporarily make glAlphaFunc() operate for alpha values greater than 0
38:24handmade_opengl.cpp: Temporarily make glAlphaFunc() operate for alpha values greater than 0
39:04Blackboard: No blending if sprites happen to be drawn in the wrong order
39:04Blackboard: No blending if sprites happen to be drawn in the wrong order
39:04Blackboard: No blending if sprites happen to be drawn in the wrong order
42:06handmade_opengl.cpp: Make OpenGLRenderCommands() call glDepthFunc()6
42:06handmade_opengl.cpp: Make OpenGLRenderCommands() call glDepthFunc()6
42:06handmade_opengl.cpp: Make OpenGLRenderCommands() call glDepthFunc()6
43:19Run the game to see that the drawing order is being respected, but that the sort is unstable
43:19Run the game to see that the drawing order is being respected, but that the sort is unstable
43:19Run the game to see that the drawing order is being respected, but that the sort is unstable
46:05Determine to process the Z-values7
46:05Determine to process the Z-values7
46:05Determine to process the Z-values7
50:46Blackboard: Near and Far Clip (Planes)
50:46Blackboard: Near and Far Clip (Planes)
50:46Blackboard: Near and Far Clip (Planes)
53:50Blackboard: Mapping the Z-values in the correct direction to the -1 to 1 range
53:50Blackboard: Mapping the Z-values in the correct direction to the -1 to 1 range
53:50Blackboard: Mapping the Z-values in the correct direction to the -1 to 1 range
56:27Blackboard: Determining the structure of the mapping function
56:27Blackboard: Determining the structure of the mapping function
56:27Blackboard: Determining the structure of the mapping function
59:08Blackboard: Solve these equations for a and b
59:08Blackboard: Solve these equations for a and b
59:08Blackboard: Solve these equations for a and b
1:02:11Blackboard: Verify these equations
1:02:11Blackboard: Verify these equations
1:02:11Blackboard: Verify these equations
1:08:49Blackboard: Solve the equations again, passing in the correct values
1:08:49Blackboard: Solve the equations again, passing in the correct values
1:08:49Blackboard: Solve the equations again, passing in the correct values
1:17:44handmade_math.h: Make PerspectiveProjection() compute d and e to pass to the matrix
1:17:44handmade_math.h: Make PerspectiveProjection() compute d and e to pass to the matrix
1:17:44handmade_math.h: Make PerspectiveProjection() compute d and e to pass to the matrix
1:19:02Run the game to see the finer grained Z-fighting
1:19:02Run the game to see the finer grained Z-fighting
1:19:02Run the game to see the finer grained Z-fighting
1:20:03handmade_render_group.cpp: Enable PushBitmap() to increase the sprites' height relative to their Z
1:20:03handmade_render_group.cpp: Enable PushBitmap() to increase the sprites' height relative to their Z
1:20:03handmade_render_group.cpp: Enable PushBitmap() to increase the sprites' height relative to their Z
1:22:52Run the game to see the slanted sprites, and consider why we must take the camera into account for shearing
1:22:52Run the game to see the slanted sprites, and consider why we must take the camera into account for shearing
1:22:52Run the game to see the slanted sprites, and consider why we must take the camera into account for shearing
1:25:03handmade_render_group.cpp: Make PushBitmap() also modify the sprites' Y and X values
1:25:03handmade_render_group.cpp: Make PushBitmap() also modify the sprites' Y and X values
1:25:03handmade_render_group.cpp: Make PushBitmap() also modify the sprites' Y and X values
1:27:21Consider using the camera's relative position to compute these modifications
1:27:21Consider using the camera's relative position to compute these modifications
1:27:21Consider using the camera's relative position to compute these modifications
1:28:48Q&A
🗩
1:28:48Q&A
🗩
1:28:48Q&A
🗩
1:29:20ratchetfreak When adjusting the sprite like that, don't you need to interpolate the texture coordinates in screenspace instead of clipspace (the default)?
🗪
1:29:20ratchetfreak When adjusting the sprite like that, don't you need to interpolate the texture coordinates in screenspace instead of clipspace (the default)?
🗪
1:29:20ratchetfreak When adjusting the sprite like that, don't you need to interpolate the texture coordinates in screenspace instead of clipspace (the default)?
🗪
1:30:29macielda What is Alpha to Coverage? Any good references on that?
🗪
1:30:29macielda What is Alpha to Coverage? Any good references on that?
🗪
1:30:29macielda What is Alpha to Coverage? Any good references on that?
🗪
1:31:48k1ng_k3v1n Would an orthogonal projection matrix be applicable for your game?
🗪
1:31:48k1ng_k3v1n Would an orthogonal projection matrix be applicable for your game?
🗪
1:31:48k1ng_k3v1n Would an orthogonal projection matrix be applicable for your game?
🗪
1:32:19sharlock93 Is the -n and -f because OpenGL has the camera on the negative -z?
🗪
1:32:19sharlock93 Is the -n and -f because OpenGL has the camera on the negative -z?
🗪
1:32:19sharlock93 Is the -n and -f because OpenGL has the camera on the negative -z?
🗪
1:33:06magik603 Why are you using legacy OpenGL?
🗪
1:33:06magik603 Why are you using legacy OpenGL?
🗪
1:33:06magik603 Why are you using legacy OpenGL?
🗪
1:34:49cvaucher Do you typically use an infinite far plane for increased precision? Shawn McGrath mentioned it in his stream awhile back
🗪
1:34:49cvaucher Do you typically use an infinite far plane for increased precision? Shawn McGrath mentioned it in his stream awhile back
🗪
1:34:49cvaucher Do you typically use an infinite far plane for increased precision? Shawn McGrath mentioned it in his stream awhile back
🗪
1:36:20macielda Would it be simpler to use Orthographic transforms for upright objects? Are you not simply undoing the Perspective Projection there?
🗪
1:36:20macielda Would it be simpler to use Orthographic transforms for upright objects? Are you not simply undoing the Perspective Projection there?
🗪
1:36:20macielda Would it be simpler to use Orthographic transforms for upright objects? Are you not simply undoing the Perspective Projection there?
🗪
1:37:28pepevel Would it be possible to use a shader to do the Z-buffer rendering?
🗪
1:37:28pepevel Would it be possible to use a shader to do the Z-buffer rendering?
🗪
1:37:28pepevel Would it be possible to use a shader to do the Z-buffer rendering?
🗪
1:40:17sharlock93 So the near and far plane are linearly mapped. I have read somewhere where the mapping is not linear, in which case do we not make them linear?
🗪
1:40:17sharlock93 So the near and far plane are linearly mapped. I have read somewhere where the mapping is not linear, in which case do we not make them linear?
🗪
1:40:17sharlock93 So the near and far plane are linearly mapped. I have read somewhere where the mapping is not linear, in which case do we not make them linear?
🗪
1:43:13Blackboard: Accounting for the -z in our coefficients
1:43:13Blackboard: Accounting for the -z in our coefficients
1:43:13Blackboard: Accounting for the -z in our coefficients
1:48:15Consult the OpenGL spec8
1:48:15Consult the OpenGL spec8
1:48:15Consult the OpenGL spec8
1:52:24sharlock93 Oh yeah, sorry, I mixed two things up
🗪
1:52:24sharlock93 Oh yeah, sorry, I mixed two things up
🗪
1:52:24sharlock93 Oh yeah, sorry, I mixed two things up
🗪
1:52:34Blackboard: Computing a and b, accounting for the -z
1:52:34Blackboard: Computing a and b, accounting for the -z
1:52:34Blackboard: Computing a and b, accounting for the -z
2:02:30handmade_math.h: Try to make PerspectiveProjection() compute the non-perspective corrected terms for orthographic
2:02:30handmade_math.h: Try to make PerspectiveProjection() compute the non-perspective corrected terms for orthographic
2:02:30handmade_math.h: Try to make PerspectiveProjection() compute the non-perspective corrected terms for orthographic
2:05:23End it there
🗩
2:05:23End it there
🗩
2:05:23End it there
🗩