(CNN) The teenager who allegedly used a shotgun and a revolver to kill 10 people and wound 10 others at a Texas high school Friday admitted he didn't shoot people he liked and meant to kill the ones he did target, a probable cause affidavit says.

Suspect Dimitrios Pagourtzis , 17, has cooperated with police, said Galveston County Magistrate Mark Henry said. Henry denied bail for the student, who is accused of capital murder of multiple people and aggravated assault on a public servant.

Students at Santa Fe High School, not far from Houston in southeastern Texas, scrambled for safety after they heard shots just after class began Friday morning. Nine students and one teacher were killed, a law enforcement official told CNN.

Pagourtzis said little during a video court appearance, answering "Yes, sir" when asked whether he wanted a court-appointed attorney. He was not asked to enter a plea.

The probable cause affidavit says he told an investigator he spared people he liked because he wanted his story told.

The alleged shooter used a shotgun and a .38 revolver that were legally owned by his father, Gov. Greg Abbott told reporters. Two school resource officers were on the campus and confronted the shooter "early on in the process," Abbott said.

Latest developments

• A student who survived being shot in the head tweeted: "I'm so greatful and blessed that god spared me today." Rome Shubert showed CNN affiliate KTRK where a bullet went in the back of his head and came out near his left ear.

• A Pakistani exchange student, Sabika Sheikh, was killed, the country's embassy in Washington said.

• Substitute teacher Cynthia Tisdale was also killed, her family said.

• One classmate told CNN the alleged shooter was "really quiet and he wore like a trench coat almost every day."

• Abbott said investigators have found journals on a computer and cell phone owned by the suspect.

• The governor offered his sympathies to the victims then called for lawmakers and others to come together to prevent more tragedies. "We need to do more than just pray for the victims and their families. It's time in Texas that we take action to step up and make sure this tragedy is never repeated ever again."

• Henry, the Galveston County magistrate, said the suspect told investigators he acted alone.

• Retired Houston Police officer John Barnes was one of the people shot at Santa Fe High School, a hospital official said. Houston's police chief tweeted that he visited the hospital where Barnes was being treated and that Barnes was "hanging in there." The officer was working as a Santa Fe officer, a police union official tweeted.

Early morning attack

Gunfire erupted at the school, about 20 miles outside Galveston, not long after classes began around 7:30 a.m. CT, officials said. Authorities later found explosive devices -- including pipe bombs and pressure cookers -- in and near the school, a law enforcement official said.

Henry told reporters that the suspect had devices but none was functional. One was a pressure cooker with an alarm clock and nails, but no explosive material. There was also an unlit Molotov cocktail found, he said.

A second person -- also believed to be a student -- has been detained as well, Harris County Sheriff Ed Gonzalez said earlier.

This is the 22nd US school shooting since the beginning of the year, and the third instance in eight days in which a gunman was on a school campus.

Witnesses described students running from the school as they heard gunshots; they also described hearing an alarm at the school, though the sequence of events wasn't immediately clear.

Authorities found explosive devices in the high school and in adjacent areas, said Walter Braun, Santa Fe Independent School District police chief. It wasn't immediately clear if any had exploded.

Santa Fe High School junior Guadalupe Sanchez, 16, cries in the arms of her mother, Elida Sanchez, after reuniting with her at a meeting point at a nearby fitness center after Friday's shooting.

Because the devices were found, Braun urged people in the city of about 13,000 people to "not touch any items that look out of place, and call 911" if they see something suspicious.

Investigators Friday afternoon were searching a trailer where they believe the devices were assembled, a law enforcement source said.

Witness: Shooter fired gun in an art class

Daymon Rabon was in class when he heard a loud bang next door.

"We thought maybe someone was banging on the shop door or maybe something fell," the senior said. Rabon said he followed his teacher, who went to investigate.

They heard three more bangs and saw the shooter come out off of an art room.

"At this point we knew this was ... really happening to us," Rabon said.

They went back into their classroom and told others to help barricade the door.

Rabon said he heard more than a dozen shots.

"You could hear him getting closer," he said. "Everyone was crying, in complete tears, just in utter disbelief."

Rabon said he heard someone shooting back and they gave them some hope, but the shooting seemed right outside their door.

Victims were being treated at three hospitals, authorities said. Eight people went to Clear Lake Regional Medical in Webster, Texas; two patients were treated at Mainland Medical Center in Texas City; and four patients went to John Sealy University of Texas Medical Branch in Galveston. It is unclear whether they were all wounded or some were treated for other injuries.

Six of the eight patients at Clear Lake Regional were discharged by Friday afternoon.

Witnesses describe hearing an alarm as well as gunfire

"We were all standing (outside), but not even five minutes later, we started hearing gunshots," she said. "And then everybody starts running, but, like, the teachers are telling us to stay put, but we're all just running away."

"I didn't see anybody shooting, but like (the gunshots) were kind of spaced," Angelica said, adding she heard about four shots.

A witness who spoke to KTRK also said she heard an alarm. She didn't specify if that was before or after the gunfire she described in the art class.

She said she couldn't describe the shooter.

"I didn't look. I just ran," she said.

Police officers work a checkpoint in front of Santa Fe High School in response to the shooting.

Another student, Dakota Shrader, told CNN affiliate KPRC that she heard gunshots only after hearing an alarm in the school.

"I was in the history hallway, and as soon as we heard the alarms, everybody just started leaving following the same procedure as ... (a) practice fire drill," Shrader said, breaking into tears. "And next thing you know, we just hear ... three gunshots, loud explosions, and all the teachers are telling us to run."

Santa Fe High School student Dakota Shrader is comforted by her mother Susan Davidson after Friday's shooting.

The high school has about 1,400 students, according to GreatSchools.org.

Houston police chief: 'I've hit rock bottom'

Houston Police Chief Art Acevedo wrote an emotional post on Facebook late Friday evening saying he was "not ashamed to admit I've shed tears of sadness, pain and anger." Acevedo spoke directly to gun-rights enthusiasts in his post.

"I know some have strong feelings about gun rights, but I want you to know I've hit rock bottom and I am not interested in your views as it pertains to this issue," he said, adding he would "de-friend" anyone who posted anything about "guns aren't the problem" and "there's little we can do."

Acevedo said he would continue to speak up and "stand up for what my heart and my God commands me to do."

"I assure you it he hasn't instructed me that gun-rights are bestowed by him," he said.

Now, Acevedo said, was not the time for prayers, study or inaction.

"It's a time for prayers, action and the asking of God's forgiveness for our inaction (especially the elected officials that ran to the cameras today, acted in a solemn manner, called for prayers, and will once again do absolutely nothing)," he said.

President Trump: Mass shootings have been 'going on too long in our country'

President Donald Trump addressed the school shooting, saying that mass shootings have been "going on too long."

"Unfortunately, I have to begin by expressing our sadness and heartbreak over the deadly shooting at Santa Fe High School in Texas," Trump said from the East Room of the White House. "This has been going on too long in our country. Too many years. Too many decades now."

Trump said federal authorities are coordinating with local officials.

"We grieve for the terrible loss of life and send our support to everyone affected by this absolutely horrific attack," Trump said.

Trump has ordered US flags at federal facilities be flown at half-staff.