A glass affects a drink in one way that has nothing to do with its shape: if there is anything on the inside surface, it will show in the glass.
What residue does
Fats and surfactants disrupt the protein structures that hold foam together. A trace of either collapses a beer head or the foam on an egg white sour within seconds.
They also dull aroma, since much of it is carried in the foam and released as bubbles burst.
Detergent is designed to break down fat by interfering with surface tension, which is precisely the property that ruins foam if any is left behind.
The rinse aid problem
The most common cause and the least known.
Rinse aid works by leaving a thin film on the surface so water sheets off rather than beading into spots. That film is exactly what destroys foam.
This is why bars use dedicated glass washers with non-rinse-aid detergent rather than ordinary dishwashers.
At home, either run glasses through a cycle without rinse aid, or wash them by hand.
Hand washing
Use a dedicated brush and minimal detergent, or hot water alone for glasses used only for beer.
Rinse thoroughly in hot water. This is the step most often skimped and the one that matters.
Do not dry with a tea towel that has been through fabric conditioner, since the residue transfers directly.
Better still, do not dry with a cloth at all. Let glasses air dry inverted on a rack so water runs out.
Storing them
Upright, once completely dry.
A glass stored upside down on a shelf traps stale air and picks up whatever the cupboard smells of, and the drink will carry it. This is a genuine effect and easily demonstrated by smelling a glass that has been inverted in a kitchen cupboard for a month.
Store them somewhere they are not touching, since contact points chip rims, and a chipped rim is unpleasant to drink from and a hazard.
Testing whether a glass is clean
Four tests, all quick.
Wet the empty glass: water should sheet evenly down the inside rather than beading into droplets.
Pour a beer and look at the inside below the surface. Bubbles clinging in patches indicate residue.
Watch the head. If it collapses quickly in a beer that should hold it, suspect the glass.
Look for lacing as the level drops. Clean rings of foam adhering to the glass indicate a clean surface.
Cloudy glasses
Two quite different causes.
Limescale from hard water is a deposit and can be removed by soaking in a solution of white vinegar and water for an hour, then washing normally.
Etching is permanent damage to the glass surface, caused by repeated dishwasher cycles with harsh detergent, high temperatures and soft water. It cannot be reversed.
The test is the vinegar soak: if it clears, it was limescale; if not, the glass is etched.
Preventing etching means using less detergent, lower temperatures and hand washing anything you care about.
Polishing
For glassware that needs to look presentable, hold the glass over steam briefly and polish with a lint-free microfibre cloth.
Hold the bowl rather than twisting the stem, which is how most stemmed glasses break.
For anything used with beer or foamed cocktails, polishing risks reintroducing residue, so air drying and leaving it alone is safer.
The summary
Minimal detergent, thorough rinsing, air dry inverted, store upright, no rinse aid, no fabric-conditioned cloths.
All of it is free and it matters more than which shape you bought.
Glasses used for different drinks
Residual aroma transfers, which is why a glass that held a peated whisky will affect the next thing in it.
Washing normally removes most of it. For anything strongly aromatic, a rinse with hot water and a longer air dry helps.
Keeping a couple of glasses reserved for whisky is worth doing if you drink much of it, since the alternative is a gin and tonic that tastes faintly of smoke.