glerminal/tests/test-common/test-common.cpp

21 lines
519 B
C++

#include <test-common.h>
#include <glerminal.h>
#include <glad/glad.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
namespace
{
unsigned char pixels[1280 * 800 * 3];
}
void glerminal_test_save_image()
{
glReadBuffer(GL_LEFT);
glReadPixels(0, 0, GRID_WIDTH * CELL_SCALE * 8, GRID_HEIGHT * CELL_SCALE * 8, GL_RGB, GL_UNSIGNED_BYTE, pixels);
stbi_flip_vertically_on_write(true);
stbi_write_png("image.png", GRID_WIDTH * CELL_SCALE * 8, GRID_HEIGHT * CELL_SCALE * 8, 3, pixels, 1280 * 3);
}