Пример #1
0
void
Uniform<UniformSymbol>::apply(ProgramPtr prog, const RenderContext& ctx)
{
  assert_gl("Uniform<UniformSymbol>::apply:enter");
  switch(m_value)
  {
    case UniformSymbol::NormalMatrix:
      prog->set_uniform(m_name, glm::mat3(ctx.get_view_matrix() * ctx.get_model_matrix()));
      break;

    case UniformSymbol::ViewMatrix:
      prog->set_uniform(m_name, ctx.get_view_matrix());
      break;

    case UniformSymbol::ModelMatrix:
      prog->set_uniform(m_name, ctx.get_model_matrix());
      break;

    case UniformSymbol::ModelViewMatrix:
      prog->set_uniform(m_name, ctx.get_view_matrix() * ctx.get_model_matrix());
      break;

    case UniformSymbol::ProjectionMatrix:
      prog->set_uniform(m_name, ctx.get_projection_matrix());
      break;

    case UniformSymbol::ModelViewProjectionMatrix:
      prog->set_uniform(m_name, ctx.get_projection_matrix() * ctx.get_view_matrix() * ctx.get_model_matrix());
      break;

    default:
      log_error("unknown UniformSymbol %d", static_cast<int>(m_value));
      break;
  }
  assert_gl("Uniform<UniformSymbol>::apply:exit");
}
Пример #2
0
 void apply(ProgramPtr prog, const RenderContext& ctx)
 {
     prog->set_uniform(m_name, m_value);
 }