Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Why SetVirtualResolution

Author
Message
BobH0905
19
Years of Service
User Offline
Joined: 3rd Feb 2005
Location: Portsmouth
Posted: 9th Feb 2014 23:28
I'm a new user of AppGameKit, and I just can't get past this question.
If I set up a window of 800 x 600, and create an image of 800 x 600, why do I need to use SetVirtualResolution to make the image appear correctly.
The window's 800 x 600, the image is 800 x 600, why doesn't it fit perfectly? I know how to make it work, what I want to know is why it doesn't work without any additional code other than "put the image in the window".
Zwarteziel
13
Years of Service
User Offline
Joined: 22nd Jan 2011
Location: Netherlands
Posted: 10th Feb 2014 09:09 Edited at: 10th Feb 2014 16:58
The command can be very useful if you want your program to run on different OS-es and devices, and don't know the window-size of a player's device. So, if you make a game with a virtual resolution of 800x600, the game will look the same on all devices*, whether they have a 'real' 800x600 display or not. In days of yore, coders and graphic artists had to take all kinds of resolutions and window-sizes in account, creating a lot of extra work. AppGameKit scales the stuff you create, making sure everything looks the same.

Also, if you don't use the command, AppGameKit will use a percentage-based system. Instead of specifying at what pixel-coordinates stuff needs to appear, you specify X and Y percentages of the screen. It's down to personal preference, really. The net result is the same: your program will scale on displays of different devices.

* = with that aspect ratio. Other ratios will show black borders on the side unless you use a command like SetScissor(0,0,0) or have code to take care of that yourself.
BobH0905
19
Years of Service
User Offline
Joined: 3rd Feb 2005
Location: Portsmouth
Posted: 10th Feb 2014 12:28
Thank you for your response. I know how useful SetVirtualResolution is in transferring programs to different devices (or at least, I think I do when I've got my head around it). I think I misrepresented my question. What I don't understand is why a (say) real 800 x 600 bitmap becomes huge and won't just display perfectly in a real 800 x 600 window without an additional command like (say) SetVirtualResolution.
My problem is that I don't like just doing something because that makes it work. I want to know why it doesn't work when the graphic and the window are the same size. Usually, knowing why something doesn't operate as I expect it to helps my understanding of why I need to do something to make it work.
I'm sure that my question has a perfectly obvious explanation to experienced AppGameKit users, but I simply can't see it.
I should have added that I'm new to AppGameKit, but not to programming or to some variant of BASIC. I just play with programming for myself nowadays, but I still like to know why things work (or not, in this case).
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 10th Feb 2014 14:18
I would guess it got something to do with AGK's percent based system. So I guess that what you see is actually 100x100. You can test my theory by creating a 100x100 image or sprite

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Feb 2014 16:00
There's not much else that TGC could do - even just looking at iOS devices, the resolutions are all over the place.

Having a virtual resolution compared to doing it yourself in C++ or C# etc... it's an absolute luxury. I mean, 800x600 will be a fairly low and rare standard already, what about the tablets that display 2560x2048... or 640x400... it's also a problem of aspect ratio. Really, just be glad that it's so easy to support these different devices

I am the one who knocks...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 10th Feb 2014 17:23
Also, if you don't explicitly use the SetVirtualResolution command, the app defaults to the percentage system for placement and sizes.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 10th Feb 2014 19:37
I think Bob is asking, why doesn't ASK automatically set the virtual resolution when running in a window of known size?

They've got a fair point. Setting the virtual resolution is logical for full screen apps, but for windowed apps it doesn't.

BobH0905
19
Years of Service
User Offline
Joined: 3rd Feb 2005
Location: Portsmouth
Posted: 10th Feb 2014 21:34
Thanks for all the responses. For info, I wasn't asking why TGC doesn't automatically set virtual resolution, my question wasn't that sophisticated. I was asking why any resolution or scaling is necessary at all, when the window and the image are the same size. I understand that should I try to run it on any other device, it wouldn't work. I simply wanted to know why a bitmap of exactly the same proportions an a window doesn't just display correctly.
Thanks also to AppGameKit Backer for the idea of trying a 100 x 100 bitmap (I also tried a 50 x 50 bitmap). The 100 x 100 bitmap fills the window across, and lops a bit off the bottom. The 50 x 50 bitmap fills half the window across, and a bit more down.
I think that's pointed me back to reading about the percentage system and SetVirtualResolution again, but with a bit more understanding.
In case anybody's interested , I discovered that when I simply use

background = CreateSprite ( LoadImage ( "map10.bmp" ) )
SetSpritePosition ( background, 0, 0 )
sync()
do
loop

with an 800 x 600 image, it displays the top left hand corner of the bitmap, 100 pixels across x 75 pixels down. Exact proportions of 800 x 600. It looks like I need SetSpriteSize, and I'm very near to understanding why it works like it does. AppGameKit doesn't know that I'm simply testing and that I'm ONLY going to be using a Windows window of a particular size. It HAS to assume that I might be broadcasting to other devices.
(I did intimate that my query was so basic that experienced users might not understand just how basic it was)
I might nearly be there guys, back to the documentation for me. Thank you for your help.
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th Feb 2014 21:39
Quote: "I think Bob is asking, why doesn't ASK automatically set the virtual resolution when running in a window of known size?"

The most likely reason is for portability.

The app is sandboxed, it should behave exactly the same way whether it is full screen or windowed and shouldn't make assumptions about it's platform or environment.

You can get the app to work to the native resolution of the device with;

But imagine it did this automatically as suggested, if you are writing an app for multiple platforms - the purpose of AppGameKit after all - you are going to have to get the resolution from AppGameKit anyway to ensure everything fits.

Defaulting to the percentage system means people can jump in and code without needing to worry what size the screen is. They just have to use floats for coordinates and sort out the aspect of the source files.

It also makes the examples and demos work on all platforms without all the complications of precision or quality

Incidentally, I don't happen to like the percent system or agree with the decision to default to it, but I can understand why it is the way it is.
David Gervais
Retired Moderator
19
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 10th Feb 2014 22:48
Hi Bob, I approved your post and deleted the duplicate post.. welcome to AppGameKit Dev.

Note: SetVirtualResolution(800,600) not only is needed to get out of the % scale system, it'll give you pixel perfect control of sprites and images.

Cheers!

Login to post a reply

Server time is: 2024-11-25 01:57:31
Your offset time is: 2024-11-25 01:57:31