LibCarna Version 3.4.0
Loading...
Searching...
No Matches
TestFramebuffer.hpp
1/*
2 * Copyright (C) 2010 - 2016 Leonid Kostrykin
3 *
4 * Chair of Medical Engineering (mediTEC)
5 * RWTH Aachen University
6 * Pauwelsstr. 20
7 * 52074 Aachen
8 * Germany
9 *
10 *
11 * Copyright (C) 2021 - 2025 Leonid Kostrykin
12 *
13 */
14
15#pragma once
16
17#include <LibCarna/LibCarna.hpp>
19#include <boost/current_function.hpp>
20
21class QImage;
22
23namespace LibCarna
24{
25
26namespace testing
27{
28
29
30
31// ----------------------------------------------------------------------------------
32// TestFramebuffer
33// ----------------------------------------------------------------------------------
34
35class TestFramebuffer
36{
37
38 const std::unique_ptr< QImage > frame;
39 const std::unique_ptr< base::Texture< 2 > > renderTexture;
40 const std::unique_ptr< base::Framebuffer > fbo;
41 const std::unique_ptr< base::Framebuffer::Binding > fboBinding;
42
43 void grabFrame() const;
44
45public:
46
47 const static double DEFAULT_EPSILON;
48
49 base::GLContext& glContext;
50
51 double epsilon;
52
53 std::size_t numIgnore;
54
55 TestFramebuffer( base::GLContext& glContext, unsigned int width, unsigned int height );
56
57 ~TestFramebuffer();
58
59 unsigned int width() const;
60
61 unsigned int height() const;
62
63 void verifyFramebuffer( const std::string& signature ) const;
64
65 void verifyFramebuffer
66 ( const std::string& expectedImageFilename
67 , const std::string& failureImageOutputFilename ) const;
68
69private:
70
71 static bool areSimilar( const QImage&, const QImage&, double epsilon, std::size_t n_ignore = 0 );
72
73 static bool saveActualResult( const QImage& frame, const std::string& filename );
74
75}; // TestFramebuffer
76
77
78
79// ----------------------------------------------------------------------------------
80// VERIFY_FRAMEBUFFER
81// ----------------------------------------------------------------------------------
82
83#define VERIFY_FRAMEBUFFER_EX( testFramebuffer, name ) \
84 ( testFramebuffer ).verifyFramebuffer( name );
85
86#define VERIFY_FRAMEBUFFER( testFramebuffer ) \
87 VERIFY_FRAMEBUFFER_EX( testFramebuffer, BOOST_CURRENT_FUNCTION );
88
89
90
91} // namespace testing
92
93} // namespace LibCarna
Defines LibCarna::base::Framebuffer.
Contains forward-declarations.
T epsilon()
Defines the maximum difference of two objects treated as equal.
Definition math.hpp:102