Ignore:
Timestamp:
Jan 28, 2013, 2:23:57 PM (8 years ago)
Author:
sam
Message:

easymesh: interface the shiny shader with new Light objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/easymesh/easymesh.cpp

    r2277 r2289  
    8080    m_gpu.normalmat = m_gpu.shader->GetUniformLocation("in_NormalMat");
    8181    m_gpu.damage = m_gpu.shader->GetUniformLocation("in_Damage");
     82    m_gpu.lights = m_gpu.shader->GetUniformLocation("u_Lights");
    8283    m_gpu.coord = m_gpu.shader->GetAttribLocation("in_Vertex",
    8384                                          VertexUsage::Position, 0);
     
    126127
    127128    m_gpu.shader->Bind();
     129
     130    /* FIXME: this should be hidden in the shader */
     131    /* FIXME: the 4th component of the position can be used for other things */
     132    Array<Light *> const lights = Scene::GetDefault()->GetLights();
     133    Array<vec4> light_data;
     134    for (int i = 0; i < lights.Count(); ++i)
     135        light_data << lights[i]->GetPosition() << lights[i]->GetColor();
     136    while (light_data.Count() < 8)
     137        light_data << vec4(0.f) << vec4(0.f);
     138    m_gpu.shader->SetUniform(m_gpu.lights, light_data);
     139
    128140    m_gpu.shader->SetUniform(m_gpu.modelview, modelview);
    129141    m_gpu.shader->SetUniform(m_gpu.view, Scene::GetDefault()->GetViewMatrix());
Note: See TracChangeset for help on using the changeset viewer.