Some people have said that a well written gay character is just a well written character that's gay, which would be true in an ideal world, but I think given our current societal circumstances, gay characters need to be a little more than just that.
Essentially, what I think you need, is of course a generally interesting character, but you need to not overemphasize the fact that he/she is gay. Because then you usually end up with a character whose single notable feature is that they're gay, and everything relates to that, or is lost amongst it.
But having said that, if you avoid really relating to the fact that they're gay, and just make it known that he/she is, then you run into the problem of tokenism. An example of that is with the whole "dumbledore is gay" thing. It's never really hinted at in the books, and announcing after everything is finished is kind of irrelevant, and achieves nothing.
Cortez is a good example, because they found a balance. He's not just gay, he's also grieving and suffering from survivors guilt, and he's a great pilot, and he has a sort of antagonistic friendship with Vega, which is quite a bit of info for a relatively minor character. But they don't overplay the fact that he's gay.
Bioware have some other reasonable examples from dragon age, but I don't think they're quite as good as Cortez.