Skip to content

Commit

Permalink
Fix crash on OSX because of pick fbo
Browse files Browse the repository at this point in the history
Since we use the cache, the fbo wasn't properly unbound after use.

Maybe we should revert to the last currently bound fbo instead of zero.
  • Loading branch information
guillaumechereau committed Jul 4, 2024
1 parent 9af58a3 commit 0545faa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/goxel.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ static void update_pick_fbo(const int view_size[2], const volume_t *volume)
render_settings_t rend_settings;
float view_mat[4][4];
float proj_mat[4][4];
int view_size[2];
} key_t;

key_t key = {0};
Expand All @@ -216,6 +217,7 @@ static void update_pick_fbo(const int view_size[2], const volume_t *volume)
.rend_settings = goxel.rend.settings,
.view_mat = MAT4_COPY(goxel.rend.view_mat),
.proj_mat = MAT4_COPY(goxel.rend.proj_mat),
.view_size = {view_size[0], view_size[1]},
};

if (memcmp(&key, &cache_key, sizeof(key_t)) == 0) {
Expand Down Expand Up @@ -269,6 +271,7 @@ static bool goxel_unproject_on_volume(
if (x < 0 || x >= view_size[0] ||
y < 0 || y >= view_size[1]) return false;
GL(glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel));
GL(glBindFramebuffer(GL_FRAMEBUFFER, 0));

unpack_pos_data(pixel, voxel_pos, &face, &tile_id);
if (!tile_id) return false;
Expand Down

0 comments on commit 0545faa

Please sign in to comment.