16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

Fix screenshot manager on OpenGL renderers

This commit is contained in:
2025-09-17 17:34:53 +02:00
parent 57d4087ef5
commit c6c042aa52
2 changed files with 58 additions and 58 deletions

View File

@@ -339,7 +339,7 @@ if (WIN32)
set(SOURCES ${SOURCES} "windows.cpp" "Console.cpp" "Console/LPT.cpp" "Console/PoKeys55.cpp") set(SOURCES ${SOURCES} "windows.cpp" "Console.cpp" "Console/LPT.cpp" "Console/PoKeys55.cpp")
#set(GLFW3_INCLUDE_DIR ${GLFW3_INCLUDE_DIR} "${DEPS_DIR}/glfw/include/") #set(GLFW3_INCLUDE_DIR ${GLFW3_INCLUDE_DIR} "${DEPS_DIR}/glfw/include/")
#set(PNG_INCLUDE_DIRS ${PNG_INCLUDE_DIRS} "${DEPS_DIR}/libpng/include/") set(PNG_INCLUDE_DIRS ${PNG_INCLUDE_DIRS} "${DEPS_DIR}/libpng/include/")
#set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIR} "${DEPS_DIR}/zlib/") #set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIR} "${DEPS_DIR}/zlib/")
set(OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} "${DEPS_DIR}/openal/include") set(OPENAL_INCLUDE_DIR ${OPENAL_INCLUDE_DIR} "${DEPS_DIR}/openal/include")
set(LIBSNDFILE_INCLUDE_DIR ${LIBSNDFILE_INCLUDE_DIR} "${DEPS_DIR}/libsndfile/include") set(LIBSNDFILE_INCLUDE_DIR ${LIBSNDFILE_INCLUDE_DIR} "${DEPS_DIR}/libsndfile/include")
@@ -358,7 +358,7 @@ if (WIN32)
set (PREFIX "-${ARCH}") set (PREFIX "-${ARCH}")
#set(GLFW3_LIBRARIES ${GLFW3_LIBRARIES} "${DEPS_DIR}/glfw/lib/${ARCH}/glfw3dll.lib") #set(GLFW3_LIBRARIES ${GLFW3_LIBRARIES} "${DEPS_DIR}/glfw/lib/${ARCH}/glfw3dll.lib")
#set(PNG_LIBRARIES ${PNG_LIBRARIES} "${DEPS_DIR}/libpng/lib/${ARCH}/libpng16.lib") set(PNG_LIBRARIES ${PNG_LIBRARIES} "${DEPS_DIR}/libpng/lib/${ARCH}/libpng16.lib")
set(OPENAL_LIBRARY ${OPENAL_LIBRARY} "${DEPS_DIR}/openal/lib/${ARCH}/OpenAL32.lib") set(OPENAL_LIBRARY ${OPENAL_LIBRARY} "${DEPS_DIR}/openal/lib/${ARCH}/OpenAL32.lib")
set(LIBSNDFILE_LIBRARY ${LIBSNDFILE_LIBRARY} "${DEPS_DIR}/libsndfile/lib/${ARCH}/libsndfile-1.lib") set(LIBSNDFILE_LIBRARY ${LIBSNDFILE_LIBRARY} "${DEPS_DIR}/libsndfile/lib/${ARCH}/libsndfile-1.lib")
set(LUAJIT_LIBRARIES ${LUAJIT_LIBRARIES} "${DEPS_DIR}/luajit/lib/${ARCH}/lua51.lib") set(LUAJIT_LIBRARIES ${LUAJIT_LIBRARIES} "${DEPS_DIR}/luajit/lib/${ARCH}/lua51.lib")
@@ -463,11 +463,11 @@ if (WITH_PYTHON)
endif() endif()
if (NOT WIN32) if (NOT WIN32)
#find_package(PNG 1.6 REQUIRED) find_package(PNG 1.6 REQUIRED)
#target_link_libraries(${PROJECT_NAME} PNG::PNG) target_link_libraries(${PROJECT_NAME} PNG::PNG)
else() else()
#include_directories(${PNG_INCLUDE_DIRS}) include_directories(${PNG_INCLUDE_DIRS})
#target_link_libraries(${PROJECT_NAME} ${PNG_LIBRARIES}) target_link_libraries(${PROJECT_NAME} ${PNG_LIBRARIES})
endif() endif()
find_package(Threads REQUIRED) find_package(Threads REQUIRED)

View File

@@ -2,66 +2,66 @@
#include "screenshot.h" #include "screenshot.h"
#include "Globals.h" #include "Globals.h"
#include "Logs.h" #include "Logs.h"
//#include <png.h> #include <png.h>
void screenshot_manager::screenshot_save_thread( char *img, int w, int h ) void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
{ {
// png_image png; png_image png;
// memset(&png, 0, sizeof(png_image)); memset(&png, 0, sizeof(png_image));
// png.version = PNG_IMAGE_VERSION; png.version = PNG_IMAGE_VERSION;
// png.width = w; png.width = w;
// png.height = h; png.height = h;
//
// int stride; int stride;
// if (Global.gfx_usegles) if (Global.gfx_usegles)
// { {
// png.format = PNG_FORMAT_RGBA; png.format = PNG_FORMAT_RGBA;
// stride = -w * 4; stride = -w * 4;
//
// for (int y = 0; y < h; y++) for (int y = 0; y < h; y++)
// for (int x = 0; x < w; x++) for (int x = 0; x < w; x++)
// img[(y * w + x) * 4 + 3] = 0xFF; img[(y * w + x) * 4 + 3] = 0xFF;
// } }
// else else
// { {
// png.format = PNG_FORMAT_RGB; png.format = PNG_FORMAT_RGB;
// stride = -w * 3; stride = -w * 3;
// } }
//
// char datetime[64]; char datetime[64];
// time_t timer; time_t timer;
// struct tm* tm_info; struct tm* tm_info;
// time(&timer); time(&timer);
// tm_info = localtime(&timer); tm_info = localtime(&timer);
// strftime(datetime, 64, "%Y-%m-%d_%H-%M-%S", tm_info); strftime(datetime, 64, "%Y-%m-%d_%H-%M-%S", tm_info);
//
// uint64_t perf; uint64_t perf;
//#ifdef _WIN32 #ifdef _WIN32
// QueryPerformanceCounter((LARGE_INTEGER*)&perf); QueryPerformanceCounter((LARGE_INTEGER*)&perf);
//#elif __unix__ #elif __unix__
// timespec ts; timespec ts;
// clock_gettime(CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
// perf = ts.tv_nsec; perf = ts.tv_nsec;
//#endif #endif
//
// std::string filename = Global.screenshot_dir + "/" + std::string(datetime) + std::string filename = Global.screenshot_dir + "/" + std::string(datetime) +
// "_" + std::to_string(perf) + ".png"; "_" + std::to_string(perf) + ".png";
//
// if (png_image_write_to_file(&png, filename.c_str(), 0, img, stride, nullptr) == 1) if (png_image_write_to_file(&png, filename.c_str(), 0, img, stride, nullptr) == 1)
// WriteLog("saved " + filename); WriteLog("saved " + filename);
// else else
// WriteLog("failed to save " + filename); WriteLog("failed to save " + filename);
delete[] img; delete[] img;
} }
void screenshot_manager::make_screenshot() void screenshot_manager::make_screenshot()
{ {
// char *img = new char[Global.fb_size.x * Global.fb_size.y * 4]; 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); 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 //m7t: use pbo
//
// std::thread t(screenshot_save_thread, img, Global.fb_size.x, Global.fb_size.y); std::thread t(screenshot_save_thread, img, Global.fb_size.x, Global.fb_size.y);
//t.detach(); t.detach();
} }