예제 #1
0
/**
 * \brief Enables a given shader.
 * \param p The shader to enable.
 */
void bear::visual::gl_screen::use_program( const shader_program& p ) const
{
  const gl_shader_program* const s
    ( static_cast<const gl_shader_program*>(p.get_impl()) );

  glUseProgram( s->program_id() );
  VISUAL_GL_ERROR_THROW();

  shader_program::variable_visitor_type visitor;
  shader_program::input_variable_map vars( p.get_variables() );
  visitor.run( vars, uniform_setter( s->program_id() ) );
} // gl_screen::use_program()
예제 #2
0
void bear::visual::detail::apply_shader( const shader_program& shader )
{
  assert ( shader.is_valid() );

  const gl_shader_program* const s
    ( static_cast<const gl_shader_program*>( shader.get_impl() ) );

  assert( s->program_id() != 0 );
  
  glUseProgram( s->program_id() );
  VISUAL_GL_ERROR_THROW();

  shader_program::variable_visitor_type visitor;
  shader_program::input_variable_map vars( shader.get_variables() );
  visitor.run( vars, uniform_setter( s->program_id() ) );
}