Hey Scooby,
Unrelated folks can live together harmoniously but remember a mortgage is a contract, so you guys need to sit down and put into legally binding writing some points that will protect you both. For example, there should be a buyout clause allowing one of you to buy out the other, stating under what terms one of you may be forced to sell to the other (for example, what if one of you falls on hard times and the other has to cover the full mortgage for a length of time).
For example, I almost bought a house with a friend in 1984 (would have been a hell of an investment...California prime real estate..that $174K property then is worth close to a mil and a half now!) The deal fell through so we rented another house. I met my future ex-husband about a month after we moved into the new house and we were married in April of 1985. I certainly was not in a relationship when we contemplated the purchase, but lo and behold..... I shortly thereafter made one of the biggest mistakes of my life! LOL!
Other legal issues relate to the sharing of equity and whether or not there is a limited term to the joint contract. You also should consider that if one of you wants to move out, does the remaining partner have to buy you out; can you sell your interest to anther person and does your partner need to approve of that in advance; do you both have to sell if one of you wants out, etc. The sharing of costs for repairs, under what conditions is either of you allowed to refinance or borrow equity, etc.
Lastly you should both purchase term insurance (at least 20 year) that covers the balance of the mortgage (it would be nice if it covered the whole mortgage, even if that is a gift to your partner). Buy a real policy, not mortgage insurance. Mortgage life insurance usually costs more and decreases in value (only pays off the mortgage), whereas a real life policy pays cash to the beneficiary, who can then buy out your heirs for your half of the house, and then opt to either pay off the rest of the mortgage or use the cash for other things.
I suspect it wouldn't be tough to find examples of similar contracts or find a good lawyer who is experienced in drafting them.
And before you commit, take a really good look at your respective life styles. Are your preferences for tidiness, noise, clutter, pets and even furniture harmonious? Discuss the roommate rules, like what if one of you wants to move in a partner? (mutual boyfriends..giggling...)
As to straight gal/gay dude - I don't see why not. I hate having roommates but when I have, I've found guys to be much better roommates, and my guy friends say the same about women. I think it helps when you aren't on a competitive level, which guy/guy, girl/girl combos are to some extent.
Best of luck.
oops...forgot to add another legal issue - inheritance, what happens to your respective halves if one of you dies.