Why is it that when bullets (from guns) hits glass, sometimes it merely makes a hole but other it shatters it?

Why is it that when gunshots hits glass, sometimes it merely makes a hole but other times it shatters the whole damn thing?
Does it depend on the type of glass, speed / mass of bullet ,etc?