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