The attacker, who was arrested and charged with murder, was identified as Dimitrios Pagourtzis, a 17-year-old pupil at Santa Fe High School.
He allegedly used a shotgun and a revolver taken from his father, who legally owned the weapons.
Most of the dead are students, police said.
Texas Governor Greg Abbott said "various kinds of explosive devices" had been found at the school, 40 miles (65km) south of Houston, and off-campus. They included "a CO2 device" and "a Molotov cocktail", he said.
Mr Abbott said police found information on the suspect's diary, computer, and mobile phone suggesting that he planned the attack and intended to kill himself afterwards.
The governor said the teenager "gave himself up" because "he didn't have the courage to commit the suicide".
How the attack unfolded
Students said the shooter entered an art class and opened fire shortly before 08:00 (13:00 GMT)."There was someone that walked in with a shotgun and started shooting," one witness told KTRK-TV, "and this girl got shot in the leg."
One student told local network KHOU-11 that a teacher who realised what was happening activated a fire alarm to evacuate the building.
Dakota Shrader, a student, told CBS News that everyone began running outside when the alarms went off.

