Added screenshot feature (F2 key)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <iostream>
|
||||
#include "Window.h"
|
||||
#include "Events.h"
|
||||
#include "../graphics/ImageData.h"
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
@@ -180,4 +181,10 @@ void Window::swapBuffers(){
|
||||
|
||||
double Window::time() {
|
||||
return glfwGetTime();
|
||||
}
|
||||
|
||||
ImageData* Window::takeScreenshot() {
|
||||
ubyte* data = new ubyte[width * height * 3];
|
||||
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||
return new ImageData(ImageFormat::rgb888, width, height, data);
|
||||
}
|
||||
+3
-1
@@ -10,6 +10,7 @@
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class GLFWwindow;
|
||||
class ImageData;
|
||||
|
||||
class Window {
|
||||
static GLFWwindow* window;
|
||||
@@ -33,8 +34,9 @@ public:
|
||||
static void resetScissor();
|
||||
|
||||
static void clear();
|
||||
|
||||
static double time();
|
||||
|
||||
static ImageData* takeScreenshot();
|
||||
};
|
||||
|
||||
#endif /* WINDOW_WINDOW_H_ */
|
||||
|
||||
Reference in New Issue
Block a user