155 ShaderInterface shaderInterface;
156 const ShaderValue& operator=(Eigen::Vector2f val)
const;
157 const ShaderValue& operator=(Eigen::Vector3f val)
const;
158 const ShaderValue& operator=(Eigen::Vector4f val)
const;
160 const ShaderValue& operator=(Eigen::Matrix2f val)
const;
161 const ShaderValue& operator=(Eigen::Matrix3f val)
const;
162 const ShaderValue& operator=(Eigen::Matrix4f val)
const;
163 const ShaderValue& operator=(Eigen::Affine3f val)
const;
164 const ShaderValue& operator=(Eigen::Projective3f val)
const;
173 const ShaderValue& operator=(
const std::vector<Eigen::Vector3f>& arr)
const;
176 const ShaderValue& set_array(
const float* data,
int n)
const;
177 const ShaderValue& set_array(
const int* data,
int n)
const;
178 const ShaderValue& set_array(
const unsigned int* data,
int n)
const;
184 const ShaderValue& set_vectors(
const Eigen::Vector2f* data,
int n)
const;
185 const ShaderValue& set_vectors(
const Eigen::Vector3f* data,
int n)
const;
186 const ShaderValue& set_vectors(
const Eigen::Vector4f* data,
int n)
const;
187 const ShaderValue& set_matrices(
const Eigen::Matrix2f* data,
int n,
bool transpose =
false)
189 const ShaderValue& set_matrices(
const Eigen::Matrix3f* data,
int n,
bool transpose =
false)
191 const ShaderValue& set_matrices(
const Eigen::Matrix4f* data,
int n,
bool transpose =
false)
193 const ShaderValue& set_matrices(
const Eigen::Affine3f* data,
int n,
bool transpose =
false)
216class LA_UI_API Shader
219 Shader(
const std::string& code,
const ShaderDefines& defines);
222 static void unbind();
224 const ShaderValue& operator[](
const std::string& name);
226 const std::string& get_source()
const;
227 std::string& get_source();
229 const ShaderDefines& get_defines()
const;
231 const std::unordered_map<StringID, ShaderValue>& uniforms()
const {
return m_uniforms; }
232 const std::unordered_map<StringID, ShaderValue>& attribs()
const {
return m_attribs; }
233 const std::unordered_map<StringID, std::string>& names()
const {
return m_names; }
235 const std::string& name(StringID
id)
const {
return m_names.at(
id); }
237 const ShaderValue& uniform(
const std::string& name)
const {
return uniform(string_id(name)); }
241 auto it = m_uniforms.find(
id);
242 if (it == m_uniforms.end())
return ShaderValue::none;
246 const ShaderValue& attrib(
const std::string& name)
const {
return attrib(string_id(name)); }
250 auto it = m_attribs.find(
id);
251 if (it == m_attribs.end())
return ShaderValue::none;
255 const std::unordered_map<StringID, int>& sampler_indices()
const {
return m_sampler_indices; }
257 const std::unordered_map<StringID, ShaderTextureProperty>& texture_properties()
const
259 return m_texture_properties;
262 const std::unordered_map<StringID, ShaderFloatProperty>& float_properties()
const
264 return m_float_properties;
267 const std::unordered_map<StringID, ShaderColorProperty>& color_properties()
const
269 return m_color_properties;
272 const std::unordered_map<StringID, ShaderVectorProperty>& vector_properties()
const
274 return m_vector_properties;
277 const std::unordered_map<StringID, ShaderBoolProperty>& bool_properties()
const
279 return m_bool_properties;
282 const std::unordered_map<StringID, ShaderIntProperty>& int_properties()
const
284 return m_int_properties;
287 void upload_default_values();
290 void process_properties(std::string& source);
293 std::unordered_map<StringID, ShaderValue> m_uniforms;
294 std::unordered_map<StringID, ShaderValue> m_attribs;
295 std::unordered_map<StringID, int> m_sampler_indices;
296 std::string m_source;
297 ShaderDefines m_defines;
299 std::unordered_map<StringID, ShaderTextureProperty> m_texture_properties;
300 std::unordered_map<StringID, ShaderFloatProperty> m_float_properties;
301 std::unordered_map<StringID, ShaderColorProperty> m_color_properties;
302 std::unordered_map<StringID, ShaderVectorProperty> m_vector_properties;
303 std::unordered_map<StringID, ShaderBoolProperty> m_bool_properties;
304 std::unordered_map<StringID, ShaderIntProperty> m_int_properties;
305 std::unordered_map<StringID, std::string> m_names;