2 * Copyright © 2012-2021 VMware, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
44 : mType(BuiltIn
), mLocation(0)
48 Variable(const std::string
& name
, Type type
, const Value
& value
)
49 : mType(type
), mName(name
), mValue(value
), mLocation(0)
53 const std::string
& name() const
58 std::string
toGLSL() const
60 if (mType
== UniformSampler
) {
61 return std::string("uniform sampler2D ") + mName
;
62 } else if (mType
== Uniform
) {
63 return std::string("uniform ") + mValue
.toTypeString() + " " + mName
;
64 } else if (mType
== Varying
) {
65 return std::string("varying ") + mValue
.toTypeString() + " " + mName
;
66 } else if (mType
== Attribute
) {
67 return std::string("attribute ") + mValue
.toTypeString() + " " + mName
;
69 return mValue
.toTypeString() + " " + mName
;
78 unsigned int location()
83 void setType(Type type
)
88 void setLocation(unsigned int location
)
95 return isAttribute() || isVarying() || isUniform();
98 bool isAttribute() const
100 return mType
== Attribute
;
103 bool isUniform() const
105 return mType
== Uniform
|| mType
== UniformSampler
;
108 bool isVarying() const
110 return mType
== Varying
;
121 return mValue
.valuePtr
<T
>();
127 return mValue
.value
<T
>();
130 Variable
& operator=(const Value
& rhs
)
140 unsigned int mLocation
;