/** * \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()
/** * \brief Sets the shader program to apply for the next render commands. * \param p The program to apply. */ void bear::visual::gl_screen::push_shader( const shader_program& p ) { m_shader.push_back( p ); if ( p.is_valid() ) use_program( p ); } // gl_screen::push_shader()
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() ) ); }