Renewable electricity sources such as solar and wind are gaining on gas for a share of the worldwide energy market.