The statute does not make a distinction between illegal, prescription, and over-the-counter drugs for DWI purposes. If a person takes a legal substance prescribed by a doctor. If that legal prescription affected his or her ability to safely operate a motor vehicle. Then the individual is guilty of driving while intoxicated under Texas law.
This is true even if the medication is a normal over-the-counter substance like Benadryl. For example, a person may take a drug that makes them drowsy, and they are pulled over by police for drifting over the centerline. Police conduct field sobriety tests. If they determine the individual lost the normal use of their mental or physical faculties. They could be arrested for DWI.