SetVirtualResolution With Aspect Correction?

BlitzMax Forums/BlitzMax Programming/SetVirtualResolution With Aspect Correction?

CyBeRGoth(Posted 2010) [#1]
Hi

It has been a while since I checked but has anyone come up with a soloution for using SetVirtualResolution with aspect correction.

For example creating your game to work widescreen at say 1280 x 800, then using SetVirtualResolution to allow people with non-widescreen monitors to play the game at 800 x 600 with black borders at the top/bottom of their screen?


ima747(Posted 2010) [#2]
I don't know much about virtual resolution so apologies if this is off track. I think you could use SetViewPort to create the resolution frame... would probably have to have an offset as well to have it centered, but SetOrigin() should cover that...

Perhaps there's some catch with virtual resolution I'm unaware of.


MGE(Posted 2010) [#3]
I thought for sure this would have been added in the latest fix. Maybe the next one if we all beg Mark? Please?


BlitzSupport(Posted 2010) [#4]
Me too!


Russell(Posted 2010) [#5]
I just use SetOrigin() and use the x and y offsets as the parameters. For example, if your game is developed in 1280 x 720 (a nice 16:9 ratio), but the user has a 4:3 display (likely!), then you can set the actual display to, say, 1280 x 960 and SetOrigin would be SetOrigin(0,120). {120 is half of the difference between 960 and 720}.

SetVirtualResolution() is awesome, except that depending on how far the display has to be stretched (the backbuffer is scaled to the actual display when you flip(), I'm guessing) the resulting graphics can be a little fuzzy. (You'll notice this fuzziness in other programs, too, like MAME in fullscreen mode).

If you use the SetOrigin method, keep in mind that this only affects drawing operations. SetViewPort(), for example, will have to take this into account by adding the x offset and y offset to the x/y parameters. The payoff is that the display is much cleaner.

Automatic letterboxing/pillarboxing would be nice, but this is easily done.

Russell


Oddball(Posted 2010) [#6]
You mean something like this?


I literally just spewed the code into the ide so haven't tested it that much. Let me know if anything needs correcting or adding.

EDIT: Just corrected a couple of bugs.

Enjoy!


CyBeRGoth(Posted 2010) [#7]
Cheers guys and thanks to oddball for the code, that is some nice stuff and does exactly what we need :)

I am just wondering now though if creating a game that is developed from the ground up to be played at a 16:9 aspect is a good idea, seeing as we mostly make casual games, do the people who buy casual games generally have access to widescreen?

I know the steam statistics thing released a while ago suggested that a lot of people do use 16:9, on steam, but then casual buyers tend not to be hardcore like a lot of people who play stuff on steam.

Anyhoo just rambling, thanks again for the soloution :)


therevills(Posted 2010) [#8]
For the past casual games Ive made Ive stuck with 800 x 600 (although I did do Gunslinger originally as 1024 x 768) as most casual games do this res...

@Oddball, nice code there - my only issue is that you are using SetViewport and there have been reported problems with this...


GfK(Posted 2010) [#9]
I am just wondering now though if creating a game that is developed from the ground up to be played at a 16:9 aspect is a good idea, seeing as we mostly make casual games, do the people who buy casual games generally have access to widescreen?

Widescreen is probably the de-facto standard now, although 16:10 (or 8:5, if you like) is more common than 16:9 as far as computer resolutions are concerned.

That said, I still code for 4:3 as there is still a not insignificant number of 4:3 monitors out there.


Oddball(Posted 2010) [#10]
On the subject of which ratio to target when developing I always go for 16:9 so that on almost all other shape monitors it'll black band at the top and bottom, which most casual gamers are already used to seeing on films.

therevills wrote:
@Oddball, nice code there - my only issue is that you are using SetViewport and there have been reported problems with this...
The only issue that should occur with this is when using ASPECT_BESTFIT_BORDER and DirectX as it sometimes does not clip two of the sides. All other modes should be fine and work consistently across all systems. If I get a little time I might convert this into a module and also a module tweak for Max2D.


Oddball(Posted 2010) [#11]
Sorry to double post, but I made this into a module for those that find them more convenient.

>>Get it here<<

Enjoy!


therevills(Posted 2010) [#12]
work consistently across all systems


I was under the impression that the SetViewPort commands doesnt work consistently across all graphics cards - esp old ones and the on-board intels ones...

OT: Can you remind how your "IF" statements are working:

If _mode&4


Thanks!


Oddball(Posted 2010) [#13]
SetViewport works on every machine I've tested it on in both DirectX and OpenGL, but I have been told that it only clips two sides when using DirectX on some machines. I have no reason to suspect they are lying hence my proviso on best fit with borders. The code is there so feel free to test it on any machine you can get your hands on. I'd certainly be interested to know how widespread this issue is. Either way only the two bordered modes use SetViewport if you feel this is an issue stick with the other modes and draw your own borders just before flipping.

That if statement is merely performing a bit flag test on the third bit of _mode. The best fit constants both have the third bit on and both bordered modes have the first bit set to on. The code just tests the individual bit to see if it is set. So _mode&4 is true if _mode is either of the best fit modes and _mode&1 is true if it is either of the bordered modes.


MGE(Posted 2010) [#14]
SetViewPort is not something you should rely on in a commercial game, according to everything I've read on it at least.


Grafos(Posted 2010) [#15]
I had problems with setviewport on the DX7 drivers, but it seems to work great with the dx9 one on my machnine


Chapman7(Posted 2016) [#16]
Sorry for bringing back an old thread but I am trying to get this to work with MaxGUI and I am having some issues with it...



any idea?


Chapman7(Posted 2016) [#17]
I got it