mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Added screenshot feature (F2 key)
This commit is contained in:
parent
d42d2dc294
commit
3723cf491f
9 changed files with 113 additions and 11 deletions
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue