diff --git a/src/graphic/Fast3D/gfx_opengl.cpp b/src/graphic/Fast3D/gfx_opengl.cpp index df8efc611..fba025df6 100644 --- a/src/graphic/Fast3D/gfx_opengl.cpp +++ b/src/graphic/Fast3D/gfx_opengl.cpp @@ -1021,7 +1021,9 @@ gfx_opengl_get_pixel_depth(int fb_id, const std::set>& c Framebuffer& fb = framebuffers[fb_id]; - if (coordinates.size() == 1) { + // When looking up one value and the framebuffer is single-sampled, we can read pixels directly + // Otherwise we need to blit first to a new buffer then read it + if (coordinates.size() == 1 && fb.msaa_level <= 1) { uint32_t depth_stencil_value; glBindFramebuffer(GL_FRAMEBUFFER, fb.fbo); int x = coordinates.begin()->first; diff --git a/src/graphic/Fast3D/gfx_sdl2.cpp b/src/graphic/Fast3D/gfx_sdl2.cpp index 96afd84ba..852608096 100644 --- a/src/graphic/Fast3D/gfx_sdl2.cpp +++ b/src/graphic/Fast3D/gfx_sdl2.cpp @@ -319,6 +319,7 @@ static void gfx_sdl_init(const char* game_name, const char* gfx_api_name, bool s if (use_opengl) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); } else { SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");