For decades, gays and lesbians were almost invisible in film and television. Homosexuality in the larger culture was draped in code words, and onscreen depictions either disguised gays and lesbians or treated them as objects of ridicule or scorn.
Then things started to change. In 1969, the Stonewall riots triggered by a police raid in New York's Greenwich Village created the modern gay rights movement, and the next year William Friedkin's "The Boys in the Band" became the first studio movie to center on gay characters.
From that start, pop culture has slowly but steadily helped bring gay people into the mainstream, from Lance Loud in the groundbreaking 1973 PBS documentary "An American Family" to Tom Hanks' Oscar-winning role as a dying lawyer in "Philadelphia" in 1993 to Pedro Zamora, the AIDS-stricken housemate on the 1994 edition of MTV's reality series "The Real World."
The Supreme Court on Friday legalized same-sex marriage nationwide. But years before that 5-4 decision, film and TV helped spur Americans' acceptance of gays and lesbians.
"Movies and television have played an immense role in getting us here — and I'm going to take some credit for the TV side," said Michael Lombardo, the programming president of HBO, which brought the gay-themed plays "Angels in America" and "The Normal Heart" to television, and has prominently featured gay characters on such series as "Six Feet Under," "Sex and the City" and "Looking," about the relationships of a group of gay friends in San Francisco.
"TV has been a powerful influence because it brings the lives of gays and lesbians into people's homes and that has increased people's understanding," added Lombardo, who is gay.
Perhaps the watershed moment was the 1997 episode of ABC's sitcom "Ellen," in which star Ellen DeGeneres came out to 42 million viewers (and some advertiser backlash). But there are many other examples of popular film and TV shows that have influenced public opinion.
Vice President Joe Biden famously said in 2012 that the NBC sitcom "Will & Grace" had "done more to educate the public" about gay issues than nearly anything else.
The message of inclusiveness has often been told through comedy, as when Mitch and Cam, the ever-bickering couple on ABC's "Modern Family," finally got married last year. The Bravo reality series "Queer Eye for the Straight Guy" humorously featured a team of gay experts offering clueless heterosexual men tips on culture, fashion and other topics.
A 2012 survey conducted by an independent polling firm for the Hollywood Reporter found that support for same-sex marriage was increasing because of shows such as "Modern Family" and "Glee." Forty-two percent of those polled — and 55% of those younger than 35 — said that depictions of same-sex marriage on TV shows had made them more aware of the issue.
Many in Hollywood saw the Supreme Court decision as a belated confirmation of an issue already resolved by ordinary Americans.
"I'm surprised the decision wasn't more one-sided because public opinion already seemed to be overwhelmingly there," said Bob Greenblatt, the chairman of NBC Entertainment, in a statement. He also happens to be gay. "I'm privileged to work in an industry that has always worked to portray positive images of LGBT people and tell their human stories, which I believe has played an important part in advancing the conversation."
That conversation has come a long way since July 1985, when movie icon Rock Hudson appeared in public looking gaunt and sick, shocking fans and sparking rumors that he was suffering from AIDS. Hudson's publicist later confirmed the diagnosis and the star died that October, followed by revelations about his life as a closeted gay man.
Fundraising for AIDS research spiked after Hudson's death, but popular acceptance of gays and lesbians was slow in coming. Prior to the 1970s, homosexuality was almost never directly addressed in pop culture; even the plays of Tennessee Williams, considered groundbreaking in their day, shrouded the issue in euphemism.
The 1972 TV movie "That Certain Summer," with Hal Holbrook and Martin Sheen, was the first to deal sympathetically with a gay character within the medium that dominated the American living room. But such portrayals were few and far between during that decade.
Conservatives were outraged when Billy Crystal played a gay man on the racy sitcom "Soap," which ran from 1977 through 1981 — although that character later reversed himself and became straight.
The AIDS crisis, for years seen as a "gay plague," changed hearts and minds. The media were filled with obituaries of Hudson and other celebrities who died of the disease, forcing some Americans to reconsider their opposition to gay rights on moral or religious grounds.
As a matter of public health and disease prevention, sexual matters once considered unmentionable became part of everyday discourse. Activists, borrowing from the civil rights movement, pointed out the ways in which high-flown rhetoric about human rights and dignity did not match official responses to the gay health crisis.
In pop culture, a key turning point may have been the 1994 season 3 telecast of "The Real World," which featured Zamora, a Cuban-American AIDS educator and activist.
Zamora's public struggle with the illness prompted a supportive phone call from President Clinton and was instrumental in shaping the views of millennials, who subsequently became strong supporters of the movement to legalize same-sex marriage.
What followed were an increasing number of series that offered gay characters from countless perspectives, such as "Queer as Folk" and "The L-Word."
Youth-skewing series such as "Everwood" and the teen hit "Degrassi" joined in. And a growing number of stars came out, including DeGeneres, Rosie O'Donnell and Neil Patrick Harris.
Such revelations have not always been greeted warmly. The American Family Assn., a conservative advocacy group, urged a boycott of "Ellen," and several large companies, including Wendy's and J.C. Penney, shied away from the series (DeGeneres, ironically, later became a spokeswoman for J.C. Penney, sparking more protests from right-wing groups).
"Star Trek's" George Takei came out in 2005, partly as a protest against then-Gov. Arnold Schwarzenegger's veto of same-sex marriage legislation.
"These landmarks helped push the conversation forward," said Matt Kane, the director of entertainment media for GLAAD, a gay-rights advocacy group that grew out of its founders' unhappiness with depictions of gays and lesbians in mass media.
Indeed, some experts see the same change happening this year with the transgender community. Caitlyn Jenner, who transitioned to a woman recently after four decades of celebrity as the former Olympian Bruce Jenner, will star in the upcoming E! series "I Am Cait."
Such moments point once again to Hollywood's unique role in reflecting changing social attitudes.
As Robert Thompson, a TV scholar at Syracuse University, put it: "You don't necessarily have to point to a Jackie Robinson moment. It's the cumulative effect of all these portrayals."