mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 22:39:19 +02:00
AnimModel.cpp reaches cParser through the simulation core, not a direct import, so the previous pass missed it; the propagation now follows the whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call Console:: inside _WIN32 guards without importing eu07.console - invisible on Linux, where those blocks are skipped.
93 lines
2.0 KiB
C++
93 lines
2.0 KiB
C++
module;
|
|
#include <array>
|
|
#include <chrono>
|
|
#include <cstddef>
|
|
#include <deque>
|
|
#include <limits>
|
|
#include <mutex>
|
|
#include <sstream>
|
|
#include <type_traits>
|
|
#include <unordered_map>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include <ostream>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include "utilities/Globals_macros.h"
|
|
#include <png.h>
|
|
#include "glad/glad.h"
|
|
#include <cstring>
|
|
#include <thread>
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#endif
|
|
|
|
module eu07.rendering.screenshot;
|
|
import eu07.utilities.globals;
|
|
import eu07.utilities.logs;
|
|
|
|
#ifdef _WIN32
|
|
#endif
|
|
|
|
void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
|
|
{
|
|
png_image png;
|
|
memset(&png, 0, sizeof(png_image));
|
|
png.version = PNG_IMAGE_VERSION;
|
|
png.width = w;
|
|
png.height = h;
|
|
|
|
int stride;
|
|
if (Global.gfx_usegles)
|
|
{
|
|
png.format = PNG_FORMAT_RGBA;
|
|
stride = -w * 4;
|
|
|
|
for (int y = 0; y < h; y++)
|
|
for (int x = 0; x < w; x++)
|
|
img[(y * w + x) * 4 + 3] = 0xFF;
|
|
}
|
|
else
|
|
{
|
|
png.format = PNG_FORMAT_RGB;
|
|
stride = -w * 3;
|
|
}
|
|
|
|
char datetime[64];
|
|
time_t timer;
|
|
struct tm* tm_info;
|
|
time(&timer);
|
|
tm_info = localtime(&timer);
|
|
strftime(datetime, 64, "%Y-%m-%d_%H-%M-%S", tm_info);
|
|
|
|
uint64_t perf;
|
|
#ifdef _WIN32
|
|
QueryPerformanceCounter((LARGE_INTEGER*)&perf);
|
|
#elif __unix__
|
|
timespec ts;
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
perf = ts.tv_nsec;
|
|
#endif
|
|
|
|
std::string filename = Global.screenshot_dir + "/" + std::string(datetime) +
|
|
"_" + std::to_string(perf) + ".png";
|
|
|
|
if (png_image_write_to_file(&png, filename.c_str(), 0, img, stride, nullptr) == 1)
|
|
WriteLog("saved " + filename);
|
|
else
|
|
WriteLog("failed to save " + filename);
|
|
|
|
delete[] img;
|
|
}
|
|
|
|
void screenshot_manager::make_screenshot()
|
|
{
|
|
char *img = new char[Global.fb_size.x * Global.fb_size.y * 4];
|
|
glReadPixels(0, 0, Global.fb_size.x, Global.fb_size.y, Global.gfx_usegles ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
|
|
//m7t: use pbo
|
|
|
|
std::thread t(screenshot_save_thread, img, Global.fb_size.x, Global.fb_size.y);
|
|
t.detach();
|
|
}
|
|
|