1#include "ExportTexture.h"
4#include <stb/stb_image_write.h>
6void ExportTexture(
int fbo, std::string path,
int w,
int h)
13 if (path.find(
".png") == std::string::npos)
18 unsigned char *data =
new unsigned char[w * h * 3];
19 glReadBuffer(GL_COLOR_ATTACHMENT0);
20 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
21 glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, data);
22 glBindFramebuffer(GL_FRAMEBUFFER, 0);
23 stbi_flip_vertically_on_write(
true);
24 stbi_write_png(path.c_str(), w, h, 3, data, w * 3);