When the display hardware is physically rotated 90 degrees, your graphics can still be rendered with the correct side up. Where is this rotation accomplished? I can imagine a few possibilities:
A) The code for every low-level graphics primitive contains something to converts its arguments, like
if (portrait) {
swap(x,y);
}
(or perhaps multiplying every coordinate with a matrix)
B) The part of the graphics card that continuously scans its memory to create a video signal reads the data in a different order.
C) The monitor paints the received data column by column instead of row by row
A and B sounds like they would be inefficient and C means that it would only work on monitors that has special hardware-support for rotation. Which one is it?