anm2ed-cli and render tests: look at animations without the editor
- anm2ed-cli info|frame|render: a text summary, one frame as a PNG, or the whole animation as a contact sheet, PNG sequence, GIF or video, drawn by the editor's OpenGL renderer in a hidden window (render::HeadlessGL). - render::animation_frame_render / animation_record draw an animation's layers over its bounds (Canvas::layers_render, also used by About) and record them through the existing Recorder. - The editor's code builds as anm2ed_app, shared by the editor, the CLI and anm2ed_render_tests, which checks a fixture's pixels and golden PNGs (with tolerance; skipped without OpenGL) and leaves its renders in build/renders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
356d74ebb6
commit
2dbbfa5e86
13 files changed
+643
-27
No files matched your search
@@ -8,11 +8,25 @@
|
||||
#include "audio_stream.hpp"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
struct SDL_Window;
|
||||
struct SDL_GLContextState;
|
||||
|
||||
namespace anm2ed
|
||||
{
|
||||
class Canvas;
|
||||
class Document;
|
||||
}
|
||||
|
||||
namespace anm2ed::model
|
||||
{
|
||||
struct Animation;
|
||||
}
|
||||
|
||||
namespace anm2ed::resource
|
||||
{
|
||||
class Shader;
|
||||
}
|
||||
|
||||
namespace anm2ed::render
|
||||
{
|
||||
#define RENDER_LIST \
|
||||
@@ -111,6 +125,25 @@ namespace anm2ed::render
|
||||
return {rows, columns};
|
||||
}
|
||||
|
||||
// An OpenGL context with no visible window, for drawing animations outside the editor (the CLI, render tests).
|
||||
class HeadlessGL
|
||||
{
|
||||
SDL_Window* window{};
|
||||
SDL_GLContextState* context{};
|
||||
|
||||
public:
|
||||
HeadlessGL();
|
||||
~HeadlessGL();
|
||||
bool is_valid() const;
|
||||
};
|
||||
|
||||
// The area an animation covers over all its frames (or a default one when it draws nothing).
|
||||
glm::vec4 animation_bounds_get(const Document&, const model::Animation&, bool);
|
||||
// One frame drawn over `bounds` at `scale`, as premultiplied RGBA rows from the top.
|
||||
std::vector<uint8_t> animation_frame_render(Canvas&, resource::Shader&, Document&, const model::Animation&, float,
|
||||
glm::vec4, float, glm::vec4, bool);
|
||||
void pixels_unpremultiply(std::vector<uint8_t>&);
|
||||
|
||||
struct RecorderOptions
|
||||
{
|
||||
Type type{};
|
||||
@@ -151,6 +184,11 @@ namespace anm2ed::render
|
||||
std::vector<int> soundIds{};
|
||||
int soundTime{-1};
|
||||
};
|
||||
|
||||
// Records a whole animation with these options (bounded and isolated), each frame drawn as animation_frame_render
|
||||
// draws it; false when a frame or the output can't be written.
|
||||
bool animation_record(const RecorderOptions&, Canvas&, resource::Shader&, Document&, const model::Animation&,
|
||||
glm::vec4, float, glm::vec4, bool);
|
||||
}
|
||||
|
||||
namespace anm2ed
|
||||
|
||||
Reference in new issue
Block a user