Virtual?

BlitzMax Forums/BlitzMax Beginners Area/Virtual?

Brucey(Posted 2015) [#1]
Hi folks!

I have a game here that is hard-coded to run at 800x600.
I'd like to be able to run it against different resolutions, for example 1024x768, and have everything just scale to fit the screen, and have the mouse work as if it was still 800x600.

Would this be a load of work, or is it quite simple to implement? (like a couple of magic lines in the right place).

Thanks ;-)


TomToad(Posted 2015) [#2]
SetVirtualResolution will map an 800x600 screen to the graphics size, automatically scaling everything properly. You do have to use VirtualMouseX() and VirtualMouseY() to map the mouse clicks properly. Only real caveat is that pixmaps will not be scaled to the virtual resolution. You will have to load them into Timages before drawing if you want them the correct size.

On other words, Call SetVertualResolution 800,600 right after the graphics command. Change all MouseX() and MouseY() to VirtualMouseX() and VirtualMouseY(). All DrawPixmap pixmap,x,y needs to be changed to image = LoadImage(pixmap); DrawImage image,x,y. Shouldn't need to do anything else.


Derron(Posted 2015) [#3]
Of course this means you should import the virtualResolution-file, else you wont have the required functions.

http://www.blitzbasic.com/codearcs/codearcs.php?code=2879


Also think about the letterboxes you might get (if you scale 800x600 - which is 4:3 to eg. 1920x1080, which is 16:9).


As you know my Dig-Framework, you might know some parts of it:
GetGraphicsManager().SetVsync(FALSE)
GetGraphicsManager().SetResolution(840,480)
GetGraphicsManager().SetDesignedResolution(800,600)
GetGraphicsManager().SetFullscreen(True)
GetGraphicsManager().InitGraphics()

Similar it should be done with the virtual graphics setup.

Please make sure to have a look at the "throw"s the TVirtualGFX-Class has, as some of them disable "ingame windowed/fullscreen switching" (if I remember correctly...).


bye
Ron


Brucey(Posted 2015) [#4]
Cool. That worked well :-)

I added SetVirtualResolution(800, 600), and converted the mouse stuff to use the virtual mouse functions, and it all just works! Yay!

Thanks :o)


Wiebo(Posted 2015) [#5]
Hi, Brucey

You can take a look at my framework, and example code, to see how I do it using James Boyd's code. My ScrambleRND code is online, you can check out the setup of that. It is running at a low resolution, buy toy can play it full-screen.

https://github.com/wiebow/scramblernd.game2d