From 4f66b4d1f5e102604caf81f09c845fa8f60a777c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Mon, 7 Oct 2013 10:50:49 +0000 Subject: [PATCH] EZMesh : Default uniform test, cause emscripten failed AGAIN. --- src/easymesh/easymesh.cpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/easymesh/easymesh.cpp b/src/easymesh/easymesh.cpp index 675de6e5..68d6acb7 100644 --- a/src/easymesh/easymesh.cpp +++ b/src/easymesh/easymesh.cpp @@ -119,24 +119,27 @@ DefaultShaderData::DefaultShaderData(uint16_t vert_decl_flags, Shader* shader, b SetupDefaultData(with_UV); } +static const String DefaultUniforms[7] = +{ + String("u_Lights"), + String("in_ModelView"), + String("in_View"), + String("in_Inv_View"), + String("in_Proj"), + String("in_NormalMat"), + String("in_Damage") +}; //----------------------------------------------------------------------------- void DefaultShaderData::StoreUniformNames() { - m_uniform_names << String("u_Lights"); - m_uniform_names << String("in_ModelView"); - m_uniform_names << String("in_View"); - m_uniform_names << String("in_Inv_View"); - m_uniform_names << String("in_Proj"); - m_uniform_names << String("in_NormalMat"); - m_uniform_names << String("in_Damage"); } //----------------------------------------------------------------------------- void DefaultShaderData::SetupDefaultData(bool with_UV) { UNUSED(with_UV); - for (int i = 0; i < m_uniform_names.Count(); i++) - AddUniform(m_uniform_names[i].C()); + for (int i = 0; i < 7; i++) + AddUniform(DefaultUniforms[i].C()); } //----------------------------------------------------------------------------- @@ -160,14 +163,14 @@ void DefaultShaderData::SetupShaderDatas(mat4 const &model) light_data << vec4::zero << vec4::zero; int i = 0; - m_shader->SetUniform(*GetUniform(m_uniform_names[i++].C()), light_data); - - m_shader->SetUniform(*GetUniform(m_uniform_names[i++].C()), modelview); - m_shader->SetUniform(*GetUniform(m_uniform_names[i++].C()), view); - m_shader->SetUniform(*GetUniform(m_uniform_names[i++].C()), inverse(view)); - m_shader->SetUniform(*GetUniform(m_uniform_names[i++].C()), proj); - m_shader->SetUniform(*GetUniform(m_uniform_names[i++].C()), normalmat); - m_shader->SetUniform(*GetUniform(m_uniform_names[i++].C()), f); + m_shader->SetUniform(*GetUniform(DefaultUniforms[i++].C()), light_data); + + m_shader->SetUniform(*GetUniform(DefaultUniforms[i++].C()), modelview); + m_shader->SetUniform(*GetUniform(DefaultUniforms[i++].C()), view); + m_shader->SetUniform(*GetUniform(DefaultUniforms[i++].C()), inverse(view)); + m_shader->SetUniform(*GetUniform(DefaultUniforms[i++].C()), proj); + m_shader->SetUniform(*GetUniform(DefaultUniforms[i++].C()), normalmat); + m_shader->SetUniform(*GetUniform(DefaultUniforms[i++].C()), f); } //-----------------------------------------------------------------------------