Skip to content

Commit b7fb4ba

Browse files
committed
keep console open on the recorder
1 parent 251adc4 commit b7fb4ba

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/recorder.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22
#include <sstream>
33
#include <CCGL.h>
44
#include <filesystem>
5+
#include <fstream>
56

67
Recorder::Recorder() : m_width(1280), m_height(720), m_fps(60) {}
78

89
void Recorder::start(const std::string& path) {
10+
#ifndef SHOW_CONSOLE
11+
static bool has_console = false;
12+
if (!has_console) {
13+
has_console = true;
14+
AllocConsole();
15+
static std::ofstream conout("CONOUT$", std::ios::out);
16+
std::cout.rdbuf(conout.rdbuf());
17+
}
18+
#endif
919
m_recording = true;
1020
m_finished_level = false;
1121
m_last_frame_t = m_extra_t = 0;
@@ -51,9 +61,8 @@ void Recorder::start(const std::string& path) {
5161
std::cout << "ffmpeg errored :(" << std::endl;
5262
return;
5363
}
54-
std::cout << "should be done now!" << std::endl;
64+
std::cout << "video should be done now" << std::endl;
5565
if (!m_include_audio || !std::filesystem::exists(song_file)) return;
56-
std::cout << "sike" << std::endl;
5766
char buffer[MAX_PATH];
5867
if (!GetTempFileNameA(std::filesystem::temp_directory_path().string().c_str(), "rec", 0, buffer)) {
5968
std::cout << "error getting temp file" << std::endl;
@@ -82,6 +91,7 @@ void Recorder::start(const std::string& path) {
8291
}
8392
std::filesystem::remove(path);
8493
std::filesystem::rename(temp_path, path);
94+
std::cout << "video + audio should be done now!" << std::endl;
8595
}).detach();
8696
}
8797

0 commit comments

Comments
 (0)