An NFL player has promised to pay for the funerals of all 10 victims who died when a teenage gunman burst into an art class and opened fire at his Texas school.

Students said Dimitrios Pagourtzis, a 17-year-old student at Santa Fe High School, unleashed a barrage of bullets on Friday after running into a classroom armed with a shotgun and pistol.

The mass shooting became the latest in a long line of fatal attacks on campuses in the US.

On Friday evening, NFL side the Houston Texans confirmed star player JJ Watt would pay for the funerals of the dead. Shortly after the shooting, Watt tweeted: “Absolutely horrific”.

Last year Watt launched a fundraiser which raised more than $37 million (£24m) for those affected by flooding from Hurricane Harvey.

Only weeks ago, a dozen students from Santa Fe High School offered support for survivors of the Parkland, Florida, school shooting by taking part in a nationwide walkout seeking stricter gun control.

On Friday, it was Parkland students who declared their solidarity with teens in Santa Fe. It was the nation's deadliest such attack since the Florida massacre that killed 17 and energized the teenage-led gun-control movement.

Student Kyle Harris, who took part in the walkout last month, was in first period when a fire alarm went off. Then he heard teachers urging him to flee.

"The scariest thing is hearing a teacher who knows your name personally call you by your name and tell you to run," Mr Harris tweeted.

The suspected shooter, who was in custody on murder charges, also had explosive devices that were found in the school and nearby, said Greg Abbott, governor of Texas.

Investigators offered no motive. In a probable-cause affidavit, they said the suspect admitted to the shooting.

The gunman told police that when he opened fire, he avoided shooting students he liked "so he could have his story told," the affidavit said.

The governor said the assailant intended to kill himself but gave up and told police that he did not have the courage to take his own life.

The deaths were all but certain to reignite the debate over gun regulations, coming just three months after the Florida attack.

"It's been happening everywhere. I've always kind of felt like that eventually it was going to happen here too," Santa Fe student Paige Curry told Houston television station KTRK. "I don't know. I wasn't surprised. I was just scared."

Although most of the dead had not been publicly identified, relatives and acquaintances said the fatalities included a substitute teacher and a foreign exchange student from Pakistan.

Another 10 people were wounded at the school in Santa Fe, a city of about 13,000 people roughly 30 miles southeast of Houston, the governor said. The wounded included a school police officer shot in the arm who was the first to confront the suspect.

Hospitals reported treating a total of 14 people for injuries related to the shooting. Two were listed in critical condition Saturday at the University of Texas Medical Branch, the hospital tweeted.

Zachary Muehe, a sophomore at the school of roughly 1,400 students, was in his art class when he heard three loud booms.

Mr Muehe told The New York Times that a student he knew from football was armed with a shotgun and was wearing a shirt emblazoned with the slogan "Born to Kill."

"It was crazy watching him shoot and then pump. I remember seeing the shrapnel from the tables, whatever he hit. I remember seeing the shrapnel go past my face," he told the Times.

Michael Farina, 17, heard the fire alarm and thought it was a drill. He was holding a door open for special education students in wheelchairs when a principal came bounding down the hall, telling everyone to run. Another teacher yelled out, "It is real!"

Students were led to take cover behind a car shop across the street from the school. Some still did not feel safe and began jumping the fence behind the shop to run even farther away, Mr Farina said.

"I debated doing that myself," he said.

The gunman yelled "Surprise" before he started shooting, according to Texas congressman Michael McCaul, the chairman of the House Homeland Security Committee.

The suspect appeared to have no prior arrests or confrontations with law enforcement.

Mr Pagourtzis made his initial court appearance Friday by video link from the Galveston County Jail. A judge denied bond and took his application for a court-appointed attorney.

Mr McCaul, a former federal prosecutor, said he expects the Justice Department to pursue additional charges, possibly involving weapons of mass destruction.

Mr Pagourtzis played on the junior varsity football team and was a member of a dance squad with a local Greek Orthodox church. Acquaintances described him as quiet and unassuming, an avid video game player who routinely wore a black trench coat and black boots to class.

The suspect obtained the shotgun and a .38-caliber handgun from his father, who owned them legally, Mr Abbott said. It was not clear whether the father knew his son had taken them.