Jonathan Groff and Raul Castillo in HBO’s “Looking.” (John P. Johnson/HBO)

Years too late but welcome all the same, HBO’s somewhat engaging half-hour series “Looking” (premiering Sunday night) is about three variously lovelorn gay men in San Francisco, each one treading over the ground already trod by so many thousands before him.

The show is set in the present and feels adequately fresh enough, neatly depicting both the city’s grittiness and tech-driven hipness in the early 21st century. But a strangely sad and somewhat haunted quality hangs over “Looking” as well. In its shadows one detects everything from dog-eared Armistead Maupin paperbacks and the Harvey Milk assassination of the 1970s to the still-evident hurt of the AIDS epidemic during the ’80s and ’90s. If you’re looking for a show in which being a gay man in the “post-gay” era seems like a lot of fun, this isn’t exactly it.

Lacking the soapy aspect of other shows about gay or lesbian characters (Showtime’s Americanized adaptation of “Queer as Folk” in the 2000s comes to mind — only because nothing else does — or maybe a bit of the “The L Word”), “Looking” is more of a piece with HBO’s other recent shows in the comedy-drama format.

Comparisons to Lena Dunham’s “Girls” are tempting (“Looking” airs directly after “Girls” and speaks a similar visual language), but I’m reminded more of the network’s short-lived 2010-11 series “How to Make It in America,” which was about young straight guys in New York who desperately believed that starting a line of trendy jeans would get them to the other side of the velvet rope. A sense of longing runs through all these shows, each of which aims to deliver a realistic take on young, modern, urban life.

“Looking” stars Jonathan Groff (from Broadway’s “Spring Awakening”) as Patrick, a 29-year-old video-game designer who is idealistically navigating the gay dating scene in an era when instant gratification with dating sites and phone apps (such as OkCupid and the brutally efficient Grindr) all but obliterate the old-fashioned fantasy of simply running into the love of your life or intuiting the passing glances of your next sexual conquest. The show is built around Patrick’s unease with meeting men and impressing them enough to win more than their momentary interest; the last man who dumped him is now engaged, which makes Patrick feel like he’s flunking Gay 101.

He shares an apartment with Agustin (Frankie J. Alvarez), a 31-year-old frustrated artist who decides to move across the bay to Oakland to try out domestic bliss with his boyfriend. Rounding out the trio is Dom (Murray Bartlett), a handsome waiter who is staring down 40 and quietly worrying that his better days are behind him. Agustin and Dom act as both friends and necessary tormentors in Patrick’s life, urging the younger man to sow his oats while there’s still time, with as many casual encounters as he can manage.

In some ways, “Looking” (created by Michael Lannan and Andrew Haigh) is the gay-themed show that gay male viewers waited in vain for back when it would have really mattered, when there were few, if any, gay characters on TV.

Closets are now so emptied — and gay culture is increasingly seen in perspective rather than merely as a topic — that “Looking” can spare itself the broad declarations of identity or liberty. For so long, film and TV projects about gay men involved obligatory scenes of bigotry and despair, in which the good times were unfailingly interrupted by requisite suffering. It was always a short hop from the disco floor to the hospital bed.

In 2014, “Looking” skillfully brushes past most of that to focus on people instead of issues, even though a self-consciousness about being a “gay show” is still evident, mostly in the writing. The first three episodes are primarily character sketches — studies in heartache with an underlying theme of loneliness. “Looking” also has an abiding interest in putting the sex back in homosexuality — including a scene in the much-maligned bathhouse, where, in one of the show’s better moments, Dom stumbles into a conversation with an older man (Scott Bakula) about the inevitability of age.

“Looking” seems to be quietly looking for a solution to what a single gay man is supposed to do with himself now that marriage is seen as the only worthy finish line. For when it comes to recent reversals in popular and legal opinions, there is no way American gays and lesbians can repay the debt owed to Mitchell and Cam, the fictional soon-to-be-married gay daddies on ABC’s hit sitcom “Modern Family.” To a large swath of mainstream TV watchers, Mitchell and Cam are the homosexual ideal. They keep things light and charming and (it’s worth noting) chaste — so far, viewers have never seen them have anything approaching sex.

As you’d expect from premium cable, “Looking” is filled with sex, and it has the audacity to suggest that not everyone’s a Mitchell and Cam. More impressively, the show isn’t populated with variations on Adonis; perhaps in the spirit of Dunham’s proudly lumpy nudity on “Girls,” the men of “Looking” are shabbier, sometimes hairy and half-sculpted, which is another way of saying they’re real. But even in this age of enlightenment, the sex scenes will shoo away a number of viewers. (I’m thinking here of all the proudly progressive straight fellows I know who nevertheless took a pass on seeing “Brokeback Mountain” and “Milk,” whose tolerance level never extends past the safety of Jerry Seinfeld’s “Not that there’s anything wrong with that . . .”)

Somewhat unfairly, the clock ticks a little faster on “Looking’s” spotty chance at luring viewers with compelling stories and strong performances. The show makes an admirable effort at transcending gayness without compromising it. Groff is fine but not fascinating as the naive yet manipulative Patrick, and Alvarez gives Agustin a certain bohemian flair. The real standout — and best-realized character so far — is Bartlett’s Dom.

Actually, the more I think about it, the show’s real standout is San Francisco itself. “Looking” is not concerned with portraying the city as a techie utopia of sustainable lifestyles and locavore groceries. Instead, those things are seen as a demographic burden to bear, right along with being gay and young and old and whatever else, right along with the drudgeries of making the rent and catching the bus. For all its focus on sex, “Looking” is best when it’s about the city.


(30 minutes) premieres Sunday at 10:30 p.m. on HBO.