List of supported resolutions

For questions about using Classic.

Post » Sun Sep 11, 2011 3:14 am

Hey, just wondering how I can get what resolutions a users computer can do. I know you can get their desktop resolution, but I'd like to know of lower resolutions too.

For instance, in many (most) games when you go to the video options they'll have a drop down list of the resolutions your computer can support. And I'd like to make a similar thing.

Or do they just list any resolution thats not larger than your desktop resolution?

alspal2011-09-11 03:19:03
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Sun Sep 11, 2011 1:15 pm

No they don't list just any. They query the system, which reports any resolutions, that the attached monitor reports.

There is no built-in support for that query, or I haven't found it. I'm sure, ROJO knows how to access these informations directly from the system using Python ;)
However, using Python you can also get such a list if you install PyGame. The function "pygame.display.list_modes" does exactly what you want.
It would be used like so:
import pygame.display
pygame.display.init()
modelist = pygame.display.list_modes(32)

32 indicates that you are looking for resolutions with 32bit color. The result is a list with tuples:
[(640, 480), (1024, 768), (1440, 900), etc...]

[EDIT] Link to the pygame function description: http://www.pygame.org/docs/ref/display.html#pygame.display.list_modestulamide2011-09-11 13:17:12
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sun Sep 11, 2011 2:27 pm

Thanks a lot tulamide! I really don't understand python much (only using it to change cursor in my game so far). Not sure how to get that pygame thing. Do I make a directory for it like I have with ctypes and do the "sys.path.append(System.AppPath + 'data')" at the start of the script? How would I access the list its made ("modelist = pygame.display.list_modes(32)") with events?alspal2011-09-11 14:29:42
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Mon Sep 12, 2011 5:47 am

Well, contrary to what tulamide says, I don't know how how to do it, but I just learned from a few internet serches and about an hour of tinkering.

Here is the example with the required pywin32 files.
I also included the cursor example edited to use pywin32 instead of ctypes to reduce the amount of files needed.
http://dl.dropbox.com/u/5426011/examples6/resolutions.zip

In my example I used the name "resolutions" instead of "modelist" but they will act the same.

To access the first mode:
modelist[0]
the second mode, and so on.
modelist[1]
modelist[2]

To access the width of say the first mode do this:
modelist[0][0]
and the height:
modelist[0][1]R0J0hound2011-09-12 05:48:26
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233

Post » Mon Sep 12, 2011 6:11 am

Wow, that's fantastic! Thanks for your time R0J0.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Mon Sep 12, 2011 7:48 am

Do you ever get the feeling that R0J0hound's real name may be Zod, and we should all 'bow down before' him :)

Joke aside (if that's what you'd call it), very useful .cap, much obliged.

zen
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,843
Reputation: 48,287

Post » Mon Sep 12, 2011 11:47 am

Thanks, very helpful.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Mon Sep 12, 2011 11:55 am

Just in case anyone else uses this: it's best to change the range(200) to a higher value so that it shows more high resolutions, my 1600x1200 didn't show up in that range.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Mon Sep 12, 2011 7:03 pm

range(200) was purely arbitrary, my system had about 95 modes.
I fixed the cap so that it will read all the modes.

http://dl.dropbox.com/u/5426011/examples6/resolutions.cap
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233

Post » Mon Sep 12, 2011 7:17 pm

How does it work exactly? What are all these modes? On one comp I have 3 modes for each resolution on another about 6. I thought, there'd be just one mode(32bit) for each resolution.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests