Regarding the two older examples cited on this page Edward II and James VI & I: what you need to keep in mind is that the view of sexuality in the Middle Ages and the early modern period was very different to our own and indeed to each over. It's fine to talk about the modern royals metioned on this thread (modern being the nineteenth century onwards) as being gay/straight/bi etc... but that's a product of the enlightenment and anything prior to that time period was very different to our own, and even then that's to ignore situational sexuality (that's what the boarding school and army/navy jibes are about - although with the rise of co-ed education and women serving in the military....)
The first thing is that regarding sexual activity in history the only concrete way of knowing that somone engaged in sexual activity is if she becomes pregnant.# Everything else is open to conjecture and interpretion and this unsurprisingly makes determining homosexual activity all the more tricky as there is also the issue of social taboos, both contempary and of later historians, as well as notions of what actually constuites sexual intercourse. It's a much tricker topic than what it looks like on the surface.
For example in the Middle Ages the main sexual divide was between the celibate and the non-celibate - all other sexual acts, which were phallocentric due to the fact that what constituted "sex" was based on what a mostly male clergy thought, were equally sinful and those for having children was seen as a necessary evil - in other words one of the side effects was that there was no conception of female homosexuality in this time period and the oddity of somthing like feliatio being regarded as a form of sodomy* but cunnilingus was not due to it not involving penile penetration. However this was also the great age of courtly love and chivalrous botherhood as well so make of that what you will. Regarding Edward, the sodomy allegations (its not accurate to talk about him as being 'gay' in this time period) were really more about the fact that his favorites hogged his patronage and blocked out other great magnates of the realm who Edward depended on to help him run the country, from offering him their council and guidance. It also alienated Isabella as these men, Hugh Despencer in particular, were a threat to her status and wealth - that's what angered her more not the sex.
Kathryn Warner has a blog about Edward and has written biographies of him and Isabella which goes into this in more detail:
Edward II. There are also a number of lectures on YouTube about sexuality in the Middle Ages in Europe - they're actually about sexuality in Game of Thrones but they go into detail about the RL Middle Ages and are well worth listening to for more information.
By James's time period attitudes were beginning to shift more toward what we might recognize in our own time period due to a shift away from the emphasis on celibacy - a byproduct of the population decrease caused by the Black Death, the questions raised by the reformation, and the development of an alternative discourse on sexuality based on classical learning - to what we would now recognize as the homo/heterosexual divide, it's no coincidence that this was the time period when men finally began to figure out how women could have sex with one another as well. In James's case there was also the fact that his sexuality was seen as linked to his foreign policy choices, James was somthing rare for the time period in that he was a pacifist in principle and fact, when warfare was seen as the correct occupation of kings and gentlemen, and was pursuing what a large number viewed as a policy of appeasement against the catholic powers. The fact that James seems to have prefers these pretty-boys to his wife and natural children was also a problem to many of his contemporaries as it looked like he was mocking marriage and the family unit - when you consider that James's political thinking was based on this kind of familial metaphor, it just looked like the worst kind of hypocracy imgainable. However that said James wasn't as "out" as he's often made out being and did try and keep things on the sly as much as was possible.
The literature on the subject of LGBT in the early modern period and James's importance to it is vast and there are too many books and articles to mention here but Michael B Young's
James I and the History of Homosexuality has a comprehensive look at James's sexuality and it's impact on both the politics of the time and posterity. It does go into detail and can be quite explicit so its not a easy or comfortable read as it discusses child sex abuse allegations with James as both victim and perpetrator - in short Trigger Warning: Sexual Abuse and Pederasty. David Bergeron and Roger Lockyer (a biographer of one of the more important favorites and James himself) are also good as well.
What's intersting is the interplay not only of biology and society, but also how its been viewed and reinterpreted over time.
* Sodomy has meant a variety of things over time and wasn't always a derogatory synonym for male homosexual behavior. It actually had a meaning closer to perverted rather than queer.
# The exception to this rule being the conception of Our Lord and Saviour obviously

.
__________________