Sam Mendes said he had completed the royal “hat-trick” as his film 1917 opened in London with the Prince of Wales and the Duchess of Cornwall in the audience.

The First World War epic is the James Bond director’s third film to premiere in the presence of members of the royal family.

Charles and Camilla were among a parade of stars to attend the premiere of Skyfall while the Duke of Sussex and the Duke and Duchess of Cambridge were present at Spectre’s opening.

Mendes, 54, told the PA news agency it was right the film – which features an all-star cast including Colin Firth, Richard Madden, Benedict Cumberbatch and Andrew Scott – opened in London.

Royal Film Performance of ‘1917
The Prince of Wales and Duchess of Cornwall (Isabel Infantes/PA)

He said: “Indeed, this is the third time. This is the hat-trick. I am really excited that the world premiere is in London.

“It was made in England, it’s an English film in almost every respect – English crew, English actors. So it feels absolutely right that it should start its journey here.”

1917 was inspired by Mendes’s grandfather, Alfred Mendes, an acclaimed British-Trinidadian novelist who spent two years on the Belgian front volunteering for Britain.

1917 World Premiere – London
Sam Mendes with George MacKay and Dean-Charles Chapman (Ian West/PA)

It follows two young men (George MacKay and Dean-Charles Chapman) as they cross enemy territory and deliver a message that will stop a deadly attack on a battalion.

Mendes said he had felt “vulnerable” making a film inspired by his own family history.

“It’s not about my grandfather – it is inspired by my grandfather,” he said.

“It is because of my grandfather that I wanted to make a movie about this.

“We constructed a story that was completely original. It’s a fiction based on a fact.

1917 World Premiere – London
Andrew Scott and Richard Madden at the premiere (Ian West/PA)

“But it still feels very personal and you do feel more vulnerable when you have written it and it’s part of your family history, in a way.

“It’s a different experience for me.”

Mendes said he wanted young people to experience war “viscerally not intellectually”.

He said: “You do want people to understand this war viscerally not intellectually – not the idea of it or historically.

“You want people feel it and, in that sense, you want to construct an experience more than just… otherwise I would just write an essay. It’s something you have to live through.”

1917 opened as a Royal Film Performance in aid of the Film And TV Charity.

Mendes, who recently won both an Olivier and Tony award for directing Jez Butterworth’s play The Ferryman, penned the screenplay with Krysty Wilson-Cairns, the writer behind Penny Dreadful.