Skip to content

Commit f43086f

Browse files
committed
fix: fix the color format of the sdl surface + do a correct sdl render loop, so that the image gets cleared correctly
1 parent a2531a9 commit f43086f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/graphics/video_renderer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,17 @@ std::optional<std::string> VideoRenderer::render(
8383
while (not all_games_finished()) {
8484
progress_callback(progress);
8585

86+
m_renderer->clear();
87+
8688
for (const auto& game : m_games) {
8789
if (not game->is_game_finished()) {
8890
game->update();
8991
game->render(*this);
9092
}
9193
}
9294

95+
m_renderer->present();
96+
9397
backend.add_frame(m_surface.get());
9498
m_clock->increment_simulation_step_index();
9599

src/graphics/video_renderer_linux.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,10 @@ std::optional<std::string> VideoRendererBackend::setup(u32 fps, shapes::UPoint s
5757

5858
//TODO(Totto): support audio, that loops the music as in the main game
5959
int ret =
60-
execlp("ffmpeg", "ffmpeg", "-loglevel", "verbose", "-y",
61-
62-
"-f", "rawvideo", "-pix_fmt", "rgba", "-s", resolution.c_str(), "-r", framerate.c_str(), "-i",
63-
"-", "-c:v", "libx264", "-vb", "2500k", "-c:a", "aac", "-ab", "200k", "-pix_fmt", "yuv420p",
64-
m_destination_path.c_str(), static_cast<char*>(nullptr));
60+
execlp("ffmpeg", "ffmpeg", "-loglevel", "verbose", "-y", "-f", "rawvideo", "-pix_fmt", "bgra", "-s",
61+
resolution.c_str(), "-r", framerate.c_str(), "-i", "-", "-c:v", "libx264", "-vb", "2500k",
62+
"-c:a", "aac", "-ab", "200k", "-pix_fmt", "yuv420p", m_destination_path.c_str(),
63+
static_cast<char*>(nullptr));
6564
if (ret < 0) {
6665
std::cerr << "FFMPEG CHILD: could not run ffmpeg as a child process: " << strerror(errno) << "\n";
6766
std::exit(1);

0 commit comments

Comments
 (0)