BMax and monitor rotation.

BlitzMax Forums/BlitzMax Programming/BMax and monitor rotation.

TeaVirus(Posted 2006) [#1]
I've been playing around with running my game on a monitor that can be rotated between landscape and portrait modes. BMax really doesn't seem to like portrait very much! If the screen is rotated while a BMax app with a graphics context is running (full or windowed) I am greeted with instant blue screen and reboot. If I try to open a graphics context when already in portrait, it will open the window with the proper rotation but the graphics are 90 degrees off.

MaxGUI stuff doesn't seem to like this very much either. I can open MaxIDE and it will survive being rotated but when in portrait mode is extremely sluggish when doing anything with it. This includes resizing the window and moving the splitter. If rotated back to landscape it it back to normal performance.

Anyway, I thought it would be cool to be able to offer screen rotation support for BMax games. Seems like it would be a great feature for vert. shooters as they are a perfect match for 3:4, 9:16, or 10:16 aspect ratios.

Anyone know what might need to be done for this to work? At the very least, it would be nice if it didn't reboot the user's PC if they happen to rotate their screen. =)


ImaginaryHuman(Posted 2006) [#2]
First of all, please explain what you are using to make the screen rotate. Is this a feature in the o/s? Is it a feature purely of your monitor? Is it some extra tool that you installed on your computer? So far it's a bit hard to understand exactly HOW you are getting the screen to rotate at all.

Max internally doesn't do rotated displays as the projection matrix is not set up that way. However, at least for OpenGL, lines such as:

glMatrix(GL_PROJECTION)
glRotatef(90.0,0,0,1) 'or -90, not sure of the format
glMatrix(GL_MODELVIEW)

might take care of it. This would make the max screen be rotated regardless of whether any other apps are. I presume however that you have some kind of other hardware or software thing that does rotation of ALL displays regardless? If you have problems with that it's the fault of that feature, not of blitzmax.


TeaVirus(Posted 2006) [#3]
Screen rotation is a feature of the NVidia (and I would guess ATI) drivers. You can rotate the screen at the driver level regardless of the type of monitor being used. In this case, rotation is automatically triggered by a utility supplied by the monitor manufacturer. When the panel is physically rotated the screen matches it's orientation. Admittedly, I have yet to do any OGL/D3D testing outside of BMax with this so it may behave the same way with other games/engines. Rotation does work well with other GUI apps such as Firefox and Thunderbird.

Thanks for the projection matrix info. That may be what I need to do to display my graphics correctly but I think BMax would need to support rotation in some way. Maybe it would need to somehow trap a screen rotation (or maybe just desktop resolution change) event to allow the app to recreate the graphics context at the appropriate resolution.


TeaVirus(Posted 2006) [#4]
Just did a little testing. When a B3D application is confronted with either rotation or desktop resolution change it simply MAVs. I also tried the new Sam N Max game. If the screen is rotated to portrait it displays a blank window and doesn't draw anything. If rotated back to landscape it resumes normal operation. It handles a desktop resolution change with no problem. Anyway, I know it's not critical for BMax to be able to do the rotation stuff but it would be a cool feature. I think the important thing would be to handle changes like this gracefully without blue screen/reboot.


ImaginaryHuman(Posted 2006) [#5]
I don't know how common place screen rotation is at the driver level, I never heard of it before and I'm pretty sure a huge percentage of `customers` would likely have no clue about how to do it and it certainly doesn't sound like something that is even working correctly in the driver, so there isn't anything blitzmax can likely do to overcome that. I suggest sticking to a non-rotated desktop and then using the projection matrix to allow in-game rotation of everything, that way it will behave perfectly even with a resolution change. That's the approach I am taking.


TeaVirus(Posted 2006) [#6]
Yeah, good point. I'll use your matrix suggestion and if the screen rotation thing comes up I'll just have to say it's unsupported. Doesn't seem to work with much anyway. Thanks for the advice.


BlitzSupport(Posted 2006) [#7]
Do you get the same list of available modes after rotating the display? Eg. is 640 x 480 listed as 480 x 640 when rotated or do you still get 640 x 480 offered?

You might have to call EndGraphics before changing, then ask for a list of display modes before calling Graphics[3D] again. Presumably it's going into a different screenmode when it rotates... he said, cluelessly.

Does this put out exactly the same information, in the same order, when run in each rotation mode?

For mode = 0 Until CountGraphicsModes ()

	GetGraphicsMode (mode, width, height, depth, hertz)

	Print "Mode " + mode + ": " + width + " x " + height + " @ " + depth + "-bit (" + hertz + " Hz)"
	
Next



TeaVirus(Posted 2006) [#8]
The output is the same when run in either screen orientation. Here's the list of available modes:


Looks like it always has both landscape and portrait modes listed, although not for all modes. I run my desktop at 1920x1200X32 however there isn't a 1200x1920x32 mode listed. I know my system is capable of displaying that mode since that's what is used for the desktop when I rotate the monitor.


Punksmurf(Posted 2006) [#9]
I tried this also. I get different modes when I have my display rotated.

My graphics card is a GeForce 4 mx400 (I know, that's a tad classic now). I cannot find my driver version, but since I reinstalled my whole system only 3 weeks ago and downloaded the newest drivers, I'm sure it's a recent version.

My display is a 24" dell, at 1920×1200 resolution (or 1200×1920 in portrait mode).

I used my videocard driver to rotate the display. I don't think one should use any other solutions, if the driver offers such a feature.

Normal (landscape) modes:


Portrait modes: