FastUIDraw
varying_list.hpp
Go to the documentation of this file.
1 /*!
2  * \file varying_list.hpp
3  * \brief file varying_list.hpp
4  *
5  * Copyright 2016 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 
20 #ifndef FASTUIDRAW_VARYING_LIST_HPP
21 #define FASTUIDRAW_VARYING_LIST_HPP
22 
23 #include <fastuidraw/util/util.hpp>
26 
27 namespace fastuidraw
28 {
29  namespace glsl
30  {
31 /*!\addtogroup GLSL
32  * @{
33  */
34  /*!
35  * \brief
36  * A varying_list lists all the in's of a frag shader (and
37  * their names) which is the same as the out's of the vertex
38  * shader which which it is paired.
39  *
40  * A varying is ALWAYS a SCALAR. The varyings of shaders should
41  * -never- be declared in the shader code. Instead, each varying
42  * should be declared in the \ref varying_list object passed to
43  * the shader object's ctor. The \ref GLSL module will share the
44  * varyings across different shaders within the uber-shader.
45  * Indeed, the number of varying the uber-shader has is not the
46  * sum of the varyings across all the shaders, but rather is the
47  * maximum number of varyings across the shaders present in the
48  * uber-shader.
49  */
51  {
52  public:
53  /*!
54  * \brief
55  * Enumeration to define the interpolator type of a varying
56  */
58  {
59  interpolator_smooth, /*!< corresponds to "smooth" of type float in GLSL */
60  interpolator_noperspective, /*!< corresponds to "noperspective" of type float in GLSL */
61  interpolator_flat, /*!< corresponds to "flat" of type float in GLSL */
62  interpolator_uint, /*!< corresponds to "flat" of type uint in GLSL */
63  interpolator_int, /*!< corresponds to "flat" of type int in GLSL */
64 
65  interpolator_number_types,
66  };
67 
68  /*!
69  * Ctor.
70  */
71  varying_list(void);
72 
73  /*!
74  * Copy ctor.
75  * \param rhs value from which to copy
76  */
77  varying_list(const varying_list &rhs);
78 
79  ~varying_list();
80 
81  /*!
82  * Assignment operator.
83  * \param rhs value from which to copy
84  */
86  operator=(const varying_list &rhs);
87 
88  /*!
89  * Swap operation
90  * \param obj object with which to swap
91  */
92  void
93  swap(varying_list &obj);
94 
95  /*!
96  * Returns the names of the varyings of the
97  * specified interpolator type.
98  * \param q interpolator type
99  */
101  varyings(enum interpolator_type_t q) const;
102 
103  /*!
104  * Returns the alias names of the aliases, i.e.
105  * the values of the first argument of calls
106  * to \ref add_varying_alias().
107  */
109  alias_varying_names(void) const;
110 
111  /*!
112  * Returns the source names of the aliases, i.e.
113  * the values of the second argument of calls to
114  * \ref add_varying_alias().
115  */
117  alias_varying_source_names(void) const;
118 
119  /*!
120  * Add a varying
121  * \param pname name by which to reference the varying
122  * \param q interpolator type of the varying
123  */
124  varying_list&
126 
127  /*!
128  * Add an uint varying, equivalent to
129  * \code
130  * add_varying(pname, interpolator_uint);
131  * \endcode
132  */
133  varying_list&
135  {
136  return add_varying(pname, interpolator_uint);
137  }
138 
139  /*!
140  * Add an uint varying, equivalent to
141  * \code
142  * add_varying(pname, interpolator_int);
143  * \endcode
144  */
145  varying_list&
147  {
148  return add_varying(pname, interpolator_int);
149  }
150 
151  /*!
152  * Add an uint varying, equivalent to
153  * \code
154  * add_varying(pname, interpolator_smooth);
155  * \endcode
156  */
157  varying_list&
159  {
160  return add_varying(pname, interpolator_smooth);
161  }
162 
163  /*!
164  * Add an uint varying, equivalent to
165  * \code
166  * add_varying(pname, interpolator_flat);
167  * \endcode
168  */
169  varying_list&
171  {
172  return add_varying(pname, interpolator_flat);
173  }
174 
175  /*!
176  * Add an uint varying, equivalent to
177  * \code
178  * add_varying(pname, interpolator_noperspective);
179  * \endcode
180  */
181  varying_list&
183  {
185  }
186 
187  /*!
188  * Add an alias to a varying. The use case being if a fixed
189  * varying is used in two different roles and aliasing the
190  * name makes the GLSL shader code more readable.
191  * \param name the new identifier to reference an existing varying
192  * \param src_name the varying referenced by name, which should
193  * be a string value that has been passed as
194  * the first argument to \ref add_varying() or
195  * \ref add_varying_alias().
196  */
197  varying_list&
198  add_varying_alias(c_string name, c_string src_name);
199 
200  private:
201  void *m_d;
202  };
203 /*! @} */
204 
205  }
206 }
207 
208 #endif
A varying_list lists all the in&#39;s of a frag shader (and their names) which is the same as the out&#39;s o...
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
varying_list & add_float_noperspective(c_string pname)
varying_list & add_uint(c_string pname)
c_array< const c_string > alias_varying_names(void) const
varying_list & add_varying_alias(c_string name, c_string src_name)
c_array< const c_string > varyings(enum interpolator_type_t q) const
varying_list & add_varying(c_string pname, enum interpolator_type_t q)
c_array< const c_string > alias_varying_source_names(void) const
file c_array.hpp
varying_list & add_float(c_string pname)
file util.hpp
varying_list & operator=(const varying_list &rhs)
A c_array is a wrapper over a C pointer with a size parameter to facilitate bounds checking and provi...
Definition: c_array.hpp:43
const char * c_string
Conveniant typedef for C-style strings.
Definition: util.hpp:135
file string_array.hpp
void swap(varying_list &obj)
varying_list & add_float_flat(c_string pname)
varying_list & add_int(c_string pname)
interpolator_type_t
Enumeration to define the interpolator type of a varying.