1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00

Remove screenshot functionality, as it's broken.

This commit is contained in:
Daniel Evans 2016-06-23 22:40:26 +01:00
parent 465bd26d9d
commit 9aaeb2ceda
7 changed files with 0 additions and 64 deletions

View File

@ -72,7 +72,6 @@ find_package(MAD REQUIRED)
find_package(GLM REQUIRED)
find_package(LibSndFile REQUIRED)
find_package(SDL2 REQUIRED)
find_package(PNG REQUIRED)
include_directories(
${SDL2_INCLUDE_DIR}

View File

@ -166,8 +166,6 @@ public:
virtual void invalidate() = 0;
virtual unsigned char* readPixels(const glm::ivec2& size) const { return nullptr; };
/**
* Resets all per-frame counters.
*/
@ -274,8 +272,6 @@ public:
void invalidate();
unsigned char* readPixels(const glm::ivec2& size) const;
virtual void pushDebugGroup(const std::string& title);
virtual const ProfileInfo& popDebugGroup();

View File

@ -420,14 +420,6 @@ void OpenGLRenderer::invalidate()
currentUBO = 0;
}
unsigned char* OpenGLRenderer::readPixels(const glm::ivec2& size) const
{
unsigned char* buffer = new unsigned char[size.x * size.y * 3];
glReadPixels(0, 0, size.x, size.y, GL_RGB, GL_UNSIGNED_BYTE, buffer);
return buffer;
}
void OpenGLRenderer::pushDebugGroup(const std::string& title)
{
#if RW_PROFILER

View File

@ -34,7 +34,6 @@ target_link_libraries(rwgame
${OPENGL_LIBRARIES}
${BULLET_LIBRARIES}
${SDL2_LIBRARY}
${PNG_LIBRARIES}
)
install(TARGETS rwgame RUNTIME DESTINATION bin)

View File

@ -54,44 +54,6 @@ void GameWindow::hideCursor()
}
void GameWindow::captureToFile(const std::string& path, GameRenderer* renderer)
{
Logger log;
std::ofstream file(path);
if (!file.is_open()) {
log.error("Game", "Could not open screenshot file!");
return;
}
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
nullptr, nullptr, nullptr);
png_infop info_ptr = png_create_info_struct(png_ptr);
png_set_write_fn(png_ptr, &file, {
[](png_structp png_ptr, png_bytep data, png_size_t length) {
reinterpret_cast<std::ofstream*>(png_get_io_ptr(png_ptr))->
write(reinterpret_cast<char*>(data), length);
} }, { [](png_structp) { } } );
auto size = getSize();
png_set_IHDR(png_ptr, info_ptr, size.x, size.y, 8, PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_write_info(png_ptr, info_ptr);
unsigned char* buffer = renderer->getRenderer()->readPixels(size);
for (int y = size.y-1; y >= 0; y--)
png_write_row(png_ptr, &buffer[y * size.x * 3]);
png_write_end(png_ptr, nullptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
delete[] buffer;
}
glm::ivec2 GameWindow::getSize() const
{
int x, y;

View File

@ -22,8 +22,6 @@ public:
void showCursor();
void hideCursor();
void captureToFile(const std::string& path, GameRenderer* renderer);
glm::ivec2 getSize() const;
void swap() const

View File

@ -804,16 +804,6 @@ void RWGame::globalKeyEvent(const SDL_Event& event)
case SDLK_F3:
showDebugPhysics = ! showDebugPhysics;
break;
case SDLK_F12: {
auto homedir = getenv("HOME");
if( homedir == nullptr ) {
std::cerr << "Unable to determine home directory for screenshot" << std::endl;
break;
}
window.captureToFile(std::string(homedir) + "/screenshot.png", renderer);
break;
}
default: break;
}
}