mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
Allow to set game window's background (clear) color
This commit is contained in:
parent
d26adecc8e
commit
446a63693a
5 changed files with 13 additions and 4 deletions
|
@ -26,7 +26,7 @@
|
|||
|
||||
SYMBOL_INTERNAL void SimpleCompositor(struct Game* game) {
|
||||
struct Gamestate* tmp = GetNextGamestate(game, NULL);
|
||||
ClearToColor(game, al_map_rgb(0, 0, 0));
|
||||
ClearToColor(game, game->_priv.bg);
|
||||
while (tmp) {
|
||||
if (IsGamestateVisible(game, tmp)) {
|
||||
al_draw_bitmap(GetGamestateFramebuffer(game, tmp), game->clip_rect.x, game->clip_rect.y, 0);
|
||||
|
@ -52,7 +52,7 @@ SYMBOL_INTERNAL void DrawGamestates(struct Game* game) {
|
|||
SetFramebufferAsTarget(game);
|
||||
if (game->_priv.params.handlers.compositor) { // don't clear when uncomposited
|
||||
al_reset_clipping_rectangle();
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0)); // even if everything is going to be redrawn, it optimizes tiled rendering
|
||||
al_clear_to_color(game->_priv.bg); // even if everything is going to be redrawn, it optimizes tiled rendering
|
||||
}
|
||||
tmp->api->draw(game, tmp->data);
|
||||
// TODO: save and restore more state for careless gamestating
|
||||
|
@ -66,7 +66,7 @@ SYMBOL_INTERNAL void DrawGamestates(struct Game* game) {
|
|||
SetFramebufferAsTarget(game);
|
||||
if (game->_priv.params.handlers.compositor) {
|
||||
al_reset_clipping_rectangle();
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||
al_clear_to_color(game->_priv.bg);
|
||||
}
|
||||
game->_priv.loading.gamestate->api->draw(game, game->_priv.loading.gamestate->data);
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ SYMBOL_INTERNAL void RemoveTimeline(struct Game* game, struct Timeline* timeline
|
|||
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_to_color(game->_priv.bg);
|
||||
if (game->_priv.params.depth_buffer) {
|
||||
al_clear_depth_buffer(1.0);
|
||||
}
|
||||
|
|
|
@ -580,6 +580,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
|
|||
}
|
||||
DestroyShaders(game);
|
||||
|
||||
SetBackgroundColor(game, al_map_rgb(0, 0, 0));
|
||||
ClearScreen(game);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
{
|
||||
|
|
|
@ -273,6 +273,8 @@ struct Game {
|
|||
|
||||
int samplerate;
|
||||
|
||||
ALLEGRO_COLOR bg;
|
||||
|
||||
#ifdef ALLEGRO_MACOSX
|
||||
char cwd[MAXPATHLEN];
|
||||
#endif
|
||||
|
|
|
@ -723,3 +723,7 @@ SYMBOL_EXPORT bool ToggleMute(struct Game* game) {
|
|||
SYMBOL_EXPORT double GetGameSpeed(struct Game* game) {
|
||||
return game->_priv.speed;
|
||||
}
|
||||
|
||||
SYMBOL_EXPORT void SetBackgroundColor(struct Game* game, ALLEGRO_COLOR bg) {
|
||||
game->_priv.bg = bg;
|
||||
}
|
||||
|
|
|
@ -101,4 +101,6 @@ bool ToggleMute(struct Game* game);
|
|||
|
||||
double GetGameSpeed(struct Game* game);
|
||||
|
||||
void SetBackgroundColor(struct Game* game, ALLEGRO_COLOR bg);
|
||||
|
||||
#endif /* LIBSUPERDERPY_UTILS_H */
|
||||
|
|
Loading…
Reference in a new issue