How to find device type and screen resolution

Previous topic - Next topic

marovada

Hi everyone.

I've searched the forum to find out how at runtime to determine:

- which device the game is running on (eg iPhone, iPad, Pandora, Android etc); and
- the screen resolution of the device.

There are hints scattered in various posts and also in the changelog (on GETSCREENSIZE) but I can't find an example setting this out for simple minds like mine :S

Presumably, you set the highest resolution in the project options and then, if you know what device you're on, you can SETSCREEN for the resolution of the device with ?IFDEF. You can then use scaling systems such as Z Project.

The main example I have is to program one universal binary for iPhone, iPhone retina, iPad and iPad retina. The other example is one binary for all Android devices (even if they have different screen resolutions).

Is there any tutorial on this?

Thanks

Quentin

did you try GETDESKTOPSIZE ?
not really sure, but I guess, it is working on every device.

Ian Price

GETDESKTOPSIZE won't tell you anything other than the resolution size (Width and Height) of the visible screen really. ie a Palm Pre and iPhone 3 use 480x320. Wiz, GP2X and Caanoo all use 320x240 (IIRC). How can you tell the difference between the machines with just the screensize? - you can't. It's useful to allow you to see if there are better/other resolutions available to you or if you need to scale your app.

PLATFORMINFO$("device") gives you the device type - iPhone/Pre/pc/GP2X etc. However Pandora is/was listed as DESKTOP when using this command.
I came. I saw. I played.

marovada

#3
GETDESKTOPSIZE is a good start, assuming it can distinguish retina and non-retina on the iPhone and iPad and the various resolutions of Android devices.

The difficulty in not knowing the device is deciding what controls to use.  For a phone/tablet there would be on-screen touch controls but for PC, Mac, console etc it may be preferable to hide on-screen controls.

Edit: Maybe GETDESKTOPSIZE doesn't solve the issue: http://www.glbasic.com/forum/index.php?topic=6226.0