A former soldier raped his ex-girlfriend "out of spite" 13 days after she dumped him during the triple murder of a BBC racing commentator's family, a court has heard.