Screen rotation

BlitzMax Forums/BlitzMax Programming/Screen rotation

tonyg(Posted 2007) [#1]
This might be of use to somebody.
Although DX only I'm sure the OGL equivalent is very similar.
If anybody wants to clean it up, add to it or comment feel free.
I haven't put it in the Code Archives yet as I'm not too sure how much use it is in a real situation. I haven't put too much thought into it either.
Thanks to Noel for his Math3D lib in the Code Archives.


<edit> The viewport and setscale could be slicker plus mouse movement would need adjusting. However, it's the screen rotation I was most interested in doing.


ImaginaryHuman(Posted 2007) [#2]
Wow this is pretty complicated, it's much easier in OpenGL ;-D

Cool tho.


tonyg(Posted 2007) [#3]
Wow this is pretty complicated, it's much easier in OpenGL ;-D


That's good to hear. Can you add the Bmax GL driver version of the same thing to this post so it's in the same place?


ImaginaryHuman(Posted 2007) [#4]
Since I dont have DX/Windows I dont know exactly what your code is doing. Are you just trying to allow the game content to be displayed at like 90 degress so the user has to stand their monitor on its side in order to see a tall view of the game?


xlsior(Posted 2007) [#5]
Wow! *very* nice one!

Thanks for sharing!


tonyg(Posted 2007) [#6]
Since I dont have DX/Windows I dont know exactly what your code is doing

It's rotating the projection matrix so the viewed screen and anything drawn on it is rotated.


Grey Alien(Posted 2007) [#7]
neat thanks! My screen must have non-square pixels even though I'm in 1024z768 as I'm sure it warps a bit as it spins.


tonyg(Posted 2007) [#8]
... I think it does as well unless it's an optical illusion.


ImaginaryHuman(Posted 2007) [#9]
Ok.

Yes, if you rotate the general `orientation` of the display then you have to switch around your aspect ratio otherwise it will be out of proportion and you'll get the stretching that Grey Alien is seeing. So instead of doing like width/height you have to do height/width.

And you also should not rotate the projection matrix if you are using OpenGL - it will create texturing and lighting problems later. The texturing/lighting systems do not take into account the rotation or position of the camera. You should rotate or translate the MODELVIEW matrix instead. Move the game world in front of the camera, do not move the projection itself. The projection matrix is meant to ONLY be used to define the `projection` - the conversion of 3D coordinates to flat 2D coordinates.