diff --git a/src/internal.c b/src/internal.c index 91a52db..46f96e5 100644 --- a/src/internal.c +++ b/src/internal.c @@ -500,7 +500,9 @@ SYMBOL_INTERNAL void ClearScreen(struct Game* game) { al_set_target_backbuffer(game->display); al_reset_clipping_rectangle(); al_clear_to_color(al_map_rgb(0, 0, 0)); - al_clear_depth_buffer(1.0); + if (game->viewport_config.depth_buffer) { + al_clear_depth_buffer(1.0); + } al_set_clipping_rectangle(game->_priv.clip_rect.x, game->_priv.clip_rect.y, game->_priv.clip_rect.w, game->_priv.clip_rect.h); } diff --git a/src/libsuperderpy.c b/src/libsuperderpy.c index 9d6ff2c..df79e08 100644 --- a/src/libsuperderpy.c +++ b/src/libsuperderpy.c @@ -204,7 +204,9 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char* al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS, ALLEGRO_DISPLAY_ORIENTATION_PORTRAIT, ALLEGRO_SUGGEST); #endif - al_set_new_display_option(ALLEGRO_DEPTH_SIZE, 24, ALLEGRO_SUGGEST); + if (viewport.depth_buffer) { + al_set_new_display_option(ALLEGRO_DEPTH_SIZE, 24, ALLEGRO_SUGGEST); + } #ifdef ALLEGRO_WINDOWS al_set_new_window_position(20, 40); // workaround nasty Windows bug with window being created off-screen diff --git a/src/libsuperderpy.h b/src/libsuperderpy.h index 68c3d6e..0eadb4f 100644 --- a/src/libsuperderpy.h +++ b/src/libsuperderpy.h @@ -81,6 +81,7 @@ struct Viewport { float aspect; /*!< When set instead of width/height pair, makes the viewport side fluid; when non-zero, locks its aspect ratio. */ bool integer_scaling; /*!< Ensure that the viewport is zoomed only with integer factors. */ bool pixel_perfect; /*!< Ensure that the resulting image is really viewport-sized and (potentially) rescaled afterwards, as opposed to default transformation-based scaling. */ + bool depth_buffer; /*!< Request a depth buffer for the framebuffer's render target. */ }; /*! \brief Main struct of the game. */