The theory is that wings may have evolved not through gliding but through assistance in running and climbing.
Prof. Kenneth Dial at U. Montana has studied prairie chickens that use wings to help ascend smooth, steep sufaces by providing a combination of propulsion and normal force into the wall. Some dinosaurs may have evolved similar mechanisms.
PDF of article in Science: http://dart.stanford.edu:88/Get/File-4509/kennethdial.pdf
This article has also attracted some interest in the popular media...