diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c
index 0ed10463fc79734e004abdfdb960d56630168abf..b1bf68bceb5477eafddc41579557a2798761de13 100644
--- a/src/sdl/i_video.c
+++ b/src/sdl/i_video.c
@@ -1620,6 +1620,11 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
 #ifdef HWRENDER
 	if (vid.glstate == VID_GL_LIBRARY_LOADED)
 		flags |= SDL_WINDOW_OPENGL;
+
+	// Without a 24-bit depth buffer many visuals are ruined by z-fighting.
+	// Some GPU drivers may give us a 16-bit depth buffer since the
+	// default value for SDL_GL_DEPTH_SIZE is 16.
+	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
 #endif
 
 	// Create a window