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

25 lines
670 B
C++
Raw Permalink Normal View History

2024-05-26 03:16:23 +00:00
#include <test-common.h>
#include <glerminal.h>
#include <glad/glad.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h>
namespace
{
2024-05-28 17:23:49 +00:00
unsigned char pixels[(GRID_WIDTH * CELL_SCALE * 8) * (GRID_HEIGHT * CELL_SCALE * 8) * 3];
2024-05-26 03:16:23 +00:00
}
void glerminal_test_save_image()
{
2024-05-27 17:07:50 +00:00
// -- DIRTY HACK --
//
// GL_TEXTURE_2D is not rebound after setting up screen framebuffer
// This code will break if this behavior changes
2024-05-28 17:11:39 +00:00
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
2024-05-26 03:16:23 +00:00
stbi_flip_vertically_on_write(true);
2024-05-28 17:23:49 +00:00
stbi_write_png("image.png", GRID_WIDTH * CELL_SCALE * 8, GRID_HEIGHT * CELL_SCALE * 8, 3, pixels, GRID_WIDTH * CELL_SCALE * 8 * 3);
2024-05-26 03:16:23 +00:00
}