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.

JJ Watt kneels before a game against the New England Patriots (Getty Images)

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.

Texas official responds to Santa Fe shooting by calling for fewer school doors

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."

Texas shooting: scene at Santa Fe high school Show all 15 1 /15 Texas shooting: scene at Santa Fe high school Texas shooting: scene at Santa Fe high school Santa Fe High School staff react as they gather in the parking lot of a gas station The Galveston County Daily News via AP Texas shooting: scene at Santa Fe high school An active shooter incident was reported at Santa Fe High School in Texas KTRK-TV ABC13 via AP Texas shooting: scene at Santa Fe high school People embrace outside the Alamo Gym where students and parents wait to reunite following a shooting at Santa Fe High School Houston Chronicle via AP Texas shooting: scene at Santa Fe high school Law enforcement officers responding at Santa Fe High School HCSO via Reuters Texas shooting: scene at Santa Fe high school Santa Fe High School student Dakota Shrader is comforted by her mother Susan Davidson following a shooting at the school Stuart Villanueva/The Galveston County Daily News via AP Texas shooting: scene at Santa Fe high school School staff members sit in a school bus to be transported to another school The Galveston County Daily News via AP Texas shooting: scene at Santa Fe high school A Santa Fe Police officer consoles others after the shooting The Galveston County Daily News via AP Texas shooting: scene at Santa Fe high school Emergency personnel and law enforcement officers respond to claims that an active shooter was reported on campus KTRK-TV ABC13 via AP Texas shooting: scene at Santa Fe high school Police officers work a check point in front of Santa Fe High School The Galveston County Daily News via AP Texas shooting: scene at Santa Fe high school A woman prays in the grass outside the Alamo Gym where parents wait to reunite with their kids following a shooting at Santa Fe High School Houston Chronicle via AP Texas shooting: scene at Santa Fe high school Santa Fe High School freshman Caitlyn Girouard, center, hugs her friend outside the Alamo Gym Houston Chronicle via AP Texas shooting: scene at Santa Fe high school A Pearland Police armored vehicle stands in front of Santa Fe High School The Galveston County Daily News via AP Texas shooting: scene at Santa Fe high school Emergency responders from multiple agencies work at the scene The Galveston County Daily News via AP Texas shooting: scene at Santa Fe high school In this image taken from video law enforcement officers respond to a high school near Houston after an active shooter was reported on campus, Friday, May 18, 2018, in Santa Fe, Texas. The Santa Fe school district issued an alert Friday morning saying Santa Fe High School has been placed on lockdown. (KTRK-TV ABC13 via AP) KTRK-TV ABC13 via AP Texas shooting: scene at Santa Fe high school In this image taken from video law enforcement officers respond to a high school near Houston after an active shooter was reported on campus, Friday, May 18, 2018, in Santa Fe, Texas. The Santa Fe school district issued an alert Friday morning saying Santa Fe High School has been placed on lockdown. (KTRK-TV ABC13 via AP) KTRK-TV ABC13 via AP

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.

Investigators were determining whether the shotgun's shortened barrel was legal, Texas senator John Cornyn said.

The assailant's homemade explosives included pipe bombs, at least one Molotov cocktail and pressure-cooker bombs similar to those used in the Boston Marathon attack, authorities said.