SGCT master (487fac4)
Simple Graphics Cluster Toolkit
Loading...
Searching...
No Matches
screencapture.h
Go to the documentation of this file.
1/*****************************************************************************************
2 * SGCT *
3 * Simple Graphics Cluster Toolkit *
4 * *
5 * Copyright (c) 2012-2026 *
6 * For conditions of distribution and use, see copyright notice in LICENSE.md *
7 ****************************************************************************************/
8
9#ifndef __SGCT__SCREENCAPTURE__H__
10#define __SGCT__SCREENCAPTURE__H__
11
12#include <sgct/sgctexports.h>
13
14#include <sgct/math.h>
15#include <cstdint>
16#include <memory>
17#include <mutex>
18#include <string>
19#include <thread>
20#include <vector>
21
22namespace sgct {
23
24class Image;
25class Window;
26
30class SGCT_EXPORT ScreenCapture {
31public:
35 enum class CaptureSource { Texture, BackBuffer, LeftBackBuffer, RightBackBuffer };
37
39 std::string filename;
40 std::unique_ptr<Image> frameBufferImage;
41 std::unique_ptr<std::thread> captureThread;
42 std::mutex* mutex = nullptr;
43 bool isRunning = false; // needed for test if running without join
44 };
45
46 ScreenCapture(const Window& window, ScreenCapture::EyeIndex ei, int bytesPerColor,
47 unsigned int colorDataType, bool addAlpha);
49
55 void resize(ivec2 resolution);
56
64 void saveScreenCapture(unsigned int textureId,
66
67private:
68 std::string createFilename(uint64_t frameNumber);
69 int availableCaptureThread();
70 Image* prepareImage(int index, std::string file);
71
72 std::mutex _mutex;
73 std::vector<ScreenCaptureThreadInfo> _captureInfos;
74
75 const unsigned int _nThreads;
76 unsigned int _pbo = 0;
77 const unsigned int _downloadType;
78 int _dataSize = 0;
79 ivec2 _resolution = ivec2{ 0, 0 };
80 const int _bytesPerColor;
81 const bool _addAlpha;
82
83 const EyeIndex _eyeIndex;
84 const Window& _window;
85};
86
87} // namespace sgct
88
89#endif // __SGCT__SCREENCAPTURE__H__
Definition image.h:19
EyeIndex
Definition screencapture.h:36
ScreenCapture(const Window &window, ScreenCapture::EyeIndex ei, int bytesPerColor, unsigned int colorDataType, bool addAlpha)
void saveScreenCapture(unsigned int textureId, CaptureSource capSrc=CaptureSource::Texture)
This function saves the images to disc.
void resize(ivec2 resolution)
Initializes the PBO or re-sizes it if the frame buffer size have changed.
CaptureSource
The different file formats supported.
Definition screencapture.h:35
@ Texture
Definition screencapture.h:35
Definition window.h:46
Definition actions.h:16
@ Mono
Definition definitions.h:24
@ StereoRight
Definition definitions.h:26
@ StereoLeft
Definition definitions.h:25
std::unique_ptr< Image > frameBufferImage
Definition screencapture.h:40
bool isRunning
Definition screencapture.h:43
std::string filename
Definition screencapture.h:39
std::mutex * mutex
Definition screencapture.h:42
std::unique_ptr< std::thread > captureThread
Definition screencapture.h:41
Definition math.h:17