Skip to content

Commit

Permalink
fix opengl framebuffer depth reads (Kenix3#426) (#7)
Browse files Browse the repository at this point in the history
(cherry picked from commit 21a5df5)
  • Loading branch information
Archez authored Feb 25, 2024
1 parent ace86f4 commit 70a5fc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/graphic/Fast3D/gfx_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,9 @@ gfx_opengl_get_pixel_depth(int fb_id, const std::set<std::pair<float, float>>& 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;
Expand Down
1 change: 1 addition & 0 deletions src/graphic/Fast3D/gfx_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,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");
Expand Down

0 comments on commit 70a5fc3

Please sign in to comment.