The shift in public opinion and the simple question — Are you having children? — is nothing short of a marvel to some gay men, perhaps even more so than to lesbians, for whom giving birth has always been an option.

Greg Moore, 62, a retired corporate manager in Fort Lauderdale, Fla., shakes his head with wonder when he sees young male couples chattering about their toddlers. That possibility seemed hopelessly out of reach when he and his 74-year-old husband, who have been together for 44 years and married in 2008, dreamed of having children. “Gay people didn’t have kids,” he said wistfully. “Straight people had kids.”

Popular culture is helping rewrite that script. Gay men who have children, or are considering having children, are becoming increasingly visible on network television. In “Modern Family,” the nation’s most popular television show, the couple Mitchell and Cameron considered adopting a second child this past season. In “Scandal,” a new ABC series, a middle-aged White House staff member groused about his partner’s desire to adopt a baby from Ethiopia. And this fall, a new NBC sitcom called “The New Normal” will feature a gay couple and their surrogate.

The shift is also reflected in census data. Between 2000 and 2010, among same-sex couples raising children, the percentage of couples with adopted children increased to 20 percent from 9 percent, according to an analysis by Gary Gates, a demographer at the Williams Institute at the University of California, Los Angeles. (Most same-sex couples with adopted children are lesbians, but gay men make up a growing share, accounting for nearly a third of such couples in 2010, up from a fifth in 2000.)

“The definition of family is unquestionably evolving,” Dr. Gates said.

But he also noted that many Americans remain deeply opposed to gay parents raising children. Same-sex couples are explicitly prohibited from adopting in two states — Utah and Mississippi — and they face significant legal hurdles in about half of all other states, particularly because they cannot legally marry in those states. And some religious leaders have refused to provide adoption services to gay couples.

Roman Catholic bishops in Washington, D.C., Illinois and Massachusetts have shuttered adoption services rather than comply with requirements that they consider same-sex couples as adoptive parents.

As a result, even in Democratic strongholds like Washington, some gay men keep their dreams of having children mostly to themselves.