add an overdraw buffer to allow for layered rendering

This commit is contained in:
2026-10-10 10:33:56 +02:00
parent 9deb40d080
commit ea1e99f022
14 changed files with 176 additions and 38 deletions
+6 -4
View File
@@ -358,7 +358,8 @@ client_update_framebuffer()
// 20, 20, 2, 2, 3, 0x000000, 0xFFFF00
// );
clear_framebuffer(0x000000);
// FIXME: why?
//clear_framebuffer(BASE, 0x000000);
uint32_t tile_size = game_state->width / SIZE;
uint8_t border_width = 10;
@@ -373,7 +374,8 @@ client_update_framebuffer()
uint32_t w = tile_size - border_width;
uint32_t h = tile_size - border_width;
uint32_t background_color = colors(game.area[j][i]);
put_rect(x, y, w, h, background_color);
put_rect(BASE, x, y, w, h, 0xFFFFFF);
put_rect(OVERDRAW, x, y, w, h, background_color);
// number in foreground
uint32_t foreground_color = 0x000000;
@@ -389,7 +391,7 @@ client_update_framebuffer()
uint32_t n_rev = numrev(n);
uint32_t digit_offset = 1;
if (n != 0) {
put_string(n_str, x + border_width, y + border_width, font_size, digit_offset, 12, foreground_color, background_color);
put_string(OVERDRAW, n_str, x + border_width, y + border_width, font_size, digit_offset, 12, foreground_color, background_color);
}
}
}
@@ -402,7 +404,7 @@ client_update_framebuffer()
alloced = true;
sprintf(score_text, "score: %6d", game.score);
put_string(score_text, border_width / 2, tile_size * SIZE + border_width / 2, 6, 1, 12, 0xFFFFFF, 0x000000);
put_string(OVERDRAW, score_text, border_width / 2, tile_size * SIZE + border_width / 2, 6, 1, 12, 0xFFFFFF, 0x000000);
if (alloced) {
free(n_str);
+4 -4
View File
@@ -1,8 +1,8 @@
add_executable(game_snake snake.c)
target_link_libraries(game_snake PRIVATE dangerzone_engine)
#add_executable(game_snake snake.c)
#target_link_libraries(game_snake PRIVATE dangerzone_engine)
add_executable(game_2048 2048.c)
target_link_libraries(game_2048 PRIVATE dangerzone_engine)
add_executable(game_window window.c)
target_link_libraries(game_window PRIVATE dangerzone_engine)
#add_executable(game_window window.c)
#target_link_libraries(game_window PRIVATE dangerzone_engine)