Light energy and heat energy are both, 'electromagnetic waves'. Heat and light come in tiny packets called photons that work like particles in some ways. They also act like waves, vibrating back and forth very fast. Heat can't escape a greenhouse because glass is a non-gray body. Its optical properties are functions which vary with frequency.