Sense of "darkness, obscurity" is first recorded 1629 in Milton's poetry; that of "melancholy, dejection, cloudiness or cheerless heaviness of mind" is from 1744; but gloomy with a corresponding sense is attested from 1580s.
1570s, "to look at furtively," probably a variant of earlier glout "to gaze attentively, stare, scowl, look glum, pout" (mid-15c.), from a Scandinavian source such as Old Norse glotta "to grin, smile scornfully and show the teeth," Swedish dialectal glotta "to peep;" or from Middle High German glotzen "to stare, gape," from the Germanic group of *gl- words that also includes glower, from PIE root *ghel- (2) "to shine." Sense of "to look at with malicious satisfaction, ponder with pleasure something that satisfies an evil passion" first recorded 1748. Johnson didn't recognize the word, and OED writes that it was probably "taken up in the 16th c. from some dialect." Related: Gloated; gloating. As a noun, from 1640s with sense of "side-glance;" 1899 as "act of gloating."
Whosoever attempteth anything for the publike ... the same setteth himselfe upon a stage to be glouted upon by every evil eye. [translators' "note to the reader" in the 1611 King James Bible]