ObservableSetting

This commit is contained in:
MihailRis
2024-04-26 02:43:10 +03:00
parent 4861fedf1e
commit 6650e27737
4 changed files with 47 additions and 99 deletions
+6 -4
View File
@@ -312,11 +312,13 @@ DisplaySettings* Window::getSettings() {
return settings;
}
ImageData* Window::takeScreenshot() {
ubyte* data = new ubyte[width * height * 3];
std::unique_ptr<ImageData> Window::takeScreenshot() {
auto data = std::make_unique<ubyte[]>(width * height * 3);
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
return new ImageData(ImageFormat::rgb888, width, height, data);
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data.get());
return std::make_unique<ImageData>(
ImageFormat::rgb888, width, height, data.release()
);
}
const char* Window::getClipboardText() {
+2 -2
View File
@@ -5,7 +5,7 @@
#include <stack>
#include <vector>
#include <memory>
#include <glm/glm.hpp>
class ImageData;
@@ -58,7 +58,7 @@ public:
return glm::vec2(width, height);
}
static ImageData* takeScreenshot();
static std::unique_ptr<ImageData> takeScreenshot();
};
#endif /* WINDOW_WINDOW_H_ */