1 /**************************************************************************/
2 /* Copyright 2012 Tim Day */
3 /* */
4 /* This file is part of Evolvotron */
5 /* */
6 /* Evolvotron is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* Evolvotron is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with Evolvotron. If not, see <http://www.gnu.org/licenses/>. */
18 /**************************************************************************/
19
20 /*! \file
21 \brief Interface for class RenderParameters
22 */
23
24 #ifndef _render_parameters_h_
25 #define _render_parameters_h_
26
27 #include "common.h"
28
change(T & dst,const T & src)29 template <typename T> bool change(T& dst,const T& src)
30 {
31 const T previous=dst;
32 dst=src;
33 return (dst!=previous);
34 }
35
36 //! Class encapsulating things affecting rendering
37 class RenderParameters : public QObject
38 {
39 Q_OBJECT;
40
41 public:
42 RenderParameters(bool jitter,uint multisample,QObject* parent);
43 ~RenderParameters();
44
45 //! Accessor.
jittered_samples()46 bool jittered_samples() const
47 {
48 return _jittered_samples;
49 }
50
51 //! Accessor.
jittered_samples(bool v)52 void jittered_samples(bool v)
53 {
54 if (change(_jittered_samples,v)) report_change();
55 }
56
57 //! Accessor.
multisample_grid()58 uint multisample_grid() const
59 {
60 assert(_multisample_grid>=1);
61 return _multisample_grid;
62 }
63
64 //! Accessor.
multisample_grid(uint v)65 void multisample_grid(uint v)
66 {
67 assert(v>=1);
68 if (change(_multisample_grid,v)) report_change();
69 }
70
71 signals:
72 void changed();
73
74 protected:
75 void report_change();
76
77 private:
78
79 //! Whether sample points should be randomized.
80 bool _jittered_samples;
81
82 //! Grid for multisampling.
83 /*! Default is 1. 4 would be 16 samples in a 4x4 grid.
84 */
85 uint _multisample_grid;
86 };
87
88
89 #endif
90