|
This thread is locked; no one can reply to it. |
1
2
|
A5 question about display adapters |
William Labbett
Member #4,486
March 2004
|
hi, I get 84 different display adapters with ALLEGRO_OPENGL as the display flags. On all of them the format is 2686584. Is this expected ? What does it mean ? EDIT : also : is there any way to get the dimensions of the screen ?
|
jmasterx
Member #11,410
October 2009
|
to get the display size I do: AguiSize AguiAllegro5GraphicsManager::getDisplaySize() { if(al_get_current_display()) return AguiSize(al_get_display_width( al_get_current_display()), al_get_display_height(al_get_current_display())); else return AguiSize(0,0); } Not sure about the formats though. Agui GUI API -> https://github.com/jmasterx/Agui |
William Labbett
Member #4,486
March 2004
|
thanks. The thing is an actual monitor has a certain size : aspect ratio. So you could have a widescreen monitor or something else other than 3 : 4 and still set a 3 : 4 fullscreen display eg 640 : 480 etc.. The code you show wouldn't actually give the size of the physical screen. The reason I'm bothered about this is because I've written my game at 640 by 480 but on a screen which isn't in these proportions, the graphics will all get stretched. This could be avoided by drawing black rectangles on the left and right of the screen and resizing the 640 480 bitmap to fit in the middle but I need to know what the proportions of the screen are to do this.
|
Arthur Kalliokoski
Second in Command
February 2005
|
Does the example program not work? They all watch too much MSNBC... they get ideas. |
Thomas Fjellstrom
Member #476
June 2000
|
William Labbett said: This could be avoided by drawing black rectangles on the left and right of the screen and resizing the 640 480 bitmap to fit in the middle but I need to know what the proportions of the screen are to do this. width / height -- |
jmasterx
Member #11,410
October 2009
|
I see so you want the desktop resolution. Do this through al_get_monitor_info Agui GUI API -> https://github.com/jmasterx/Agui |
Matthew Leverton
Supreme Loser
January 1999
|
I think he's looking for the equivalent of A4's get desktop resolution, where you could then (sort of) know what the native resolution is. |
William Labbett
Member #4,486
March 2004
|
What I really want is the screen resolution. As an example of the problem. here's what I get for the monitor info's on my card : i 0 width 640, height 480. format 2686584, refresh rate 59 Now from this information can the screen resolution be worked out ? Can anyone guess what my screen resolution is ?
|
Arthur Kalliokoski
Second in Command
February 2005
|
In each line, "width" and "height" refer to the resolution of that particular screen mode, not how many pixels your monitor is capable of. They all watch too much MSNBC... they get ideas. |
William Labbett
Member #4,486
March 2004
|
Arthur Kalliokoski said: not how many pixels your monitor is capable of. but that's what I want to know, because for all those options which are fullscreen any that aren't the same ratio as my screen res will mean my buffer will get stretched. Sorry to be a bore but it really matters to me.
|
jmasterx
Member #11,410
October 2009
|
So what you want is the monitor's native resolution, not the one that is necessarily currently set? Agui GUI API -> https://github.com/jmasterx/Agui |
Arthur Kalliokoski
Second in Command
February 2005
|
I'd suppose that everybody runs their desktop at the native resolution, so I'd guess passing ALLEGRO_FULLSCREEN_WINDOW to a screen mode set, then using al_get_display_height() and al_get_display_width(), then setting the actual open gl mode you want would work. They all watch too much MSNBC... they get ideas. |
jmasterx
Member #11,410
October 2009
|
Then why doesn't monitor info work? If x1 || y1 != 0, then just subtract x1 from x2 and subtract y2 from y1 to get the desktop res right? Agui GUI API -> https://github.com/jmasterx/Agui |
Matthew Leverton
Supreme Loser
January 1999
|
I don't think he understands that you are suggesting this: ALLEGRO_MONITOR_INFO monitor; al_get_monitor_info(0, &monitor); int w = monitor.x2 - monitor.x1; int h = monitor.y2 - monitor.y1; This is the same thing as get_desktop_resolution() on A4. It's not guaranteed to be the monitor's native resolution, but it's what the user has set. So that's probably just as good. |
William Labbett
Member #4,486
March 2004
|
Alrighty. So that's what I should I do and say in the readme to make sure your desktop res is set the native one for the display/monitor. But just out of interest : would it be possible to hold a database of display's and all the makes and relevant data and then somehow find out which one it is by poking around the OS ?
|
jmasterx
Member #11,410
October 2009
|
Yea I imagine it is possible. You can get the vendor id and device id from the OS and then compare that to a database to know which one it is. However making this cross platform might require some work. Agui GUI API -> https://github.com/jmasterx/Agui |
William Labbett
Member #4,486
March 2004
|
Right. Thanks j
|
jmasterx
Member #11,410
October 2009
|
Glad to help Agui GUI API -> https://github.com/jmasterx/Agui |
Trent Gamblin
Member #261
April 2000
|
That's certainly not in the scope of something Allegro would do... and I suspect there are probably ways to find an lcds native resolution without a giant database. Seems probably, but I don't know. I think a database is extreme overkill in any case, and you'd never get every monitor into it so it wouldn't be any better than the guesses you can make already, IMO.
|
William Labbett
Member #4,486
March 2004
|
Thanks Trent. just need to work out what 2686584 means for the pixel format.
|
Trent Gamblin
Member #261
April 2000
|
Yes. Are you using an example included with Allegro to get that output, and if so which one? If not, can you upload your code? I'll try it out on Windows/OpenGL.
|
William Labbett
Member #4,486
March 2004
|
I isolated the code down to a simple program and now all the values are 21 which makes sense. Not sure why I'm getting that value in my game code. I'll keep fiddling and see if I can reproduce it without posting my entire project. Okay. This code reproduces the problem : 1#include <stdio.h>
2#include <allegro5/allegro.h>
3#include <allegro5/allegro_image.h>
4#include <allegro5/allegro_font.h>
5
6
7
8
9static void initialise_game(void);
10
11
12
13int main()
14{
15
16
17 printf("calling initialise game.\n");
18
19 initialise_game();
20
21 return 0;
22}
23
24
25
26
27
28static void initialise_game(void)
29{
30 int x, y;
31
32
33 int num_display_modes;
34
35 ALLEGRO_DISPLAY_MODE mode;
36
37 int i;
38
39
40 if ( !al_init() )
41 {
42 printf("Could not init Allegro.\n");
43 exit(1);
44 }
45
46
47 if(!al_init_image_addon())
48 {
49 printf("Couldn't initialise image addon.\n");
50 exit(1);
51 }
52
53 if(!al_init_primitives_addon())
54 {
55 printf("couldn't init primitives addon.\n");
56 }
57
58
59
60 al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA);
61
62 al_init_font_addon();
63
64
65 if(!al_init_ttf_addon())
66 {
67 printf(" couldn't init ttf_addon.\n");
68 exit(1);
69 }
70
71 al_inhibit_screensaver(1);
72
73
74 al_install_keyboard();
75
76
77
78 srand(time(0));
79
80 al_set_new_display_flags(ALLEGRO_OPENGL);
81
82
83
84 FILE *modes = fopen("modes.txt", "w");
85
86 num_display_modes = al_get_num_display_modes();
87
88
89 for(i = 0; i < num_display_modes; ++i)
90 {
91
92 al_get_display_mode(i, &mode);
93
94 fprintf(modes, " i %d width %d, height %d. format %d, refresh rate %d\n", i, mode.width, mode.height, mode.format, mode.refresh_rate);
95 }
96
97 fclose(modes);
98
99
100 printf("num display modes = %d.\n", num_display_modes);
101
102}
|
Trent Gamblin
Member #261
April 2000
|
hmm this sort of reminded me that with OpenGL you can't actually set or get a specific pixel format, which means the "format" field is meaningless. If that's the case then it should just be removed. When I run that program I get "0" for each of them. Could just be uninitialized memory, which happens to be some strange value for you but 0 is pretty likely...
|
Elias
Member #358
May 2000
|
Arthur Kalliokoski said: I'd suppose that everybody runs their desktop at the native resolution, so I'd guess passing ALLEGRO_FULLSCREEN_WINDOW to a screen mode set, then using al_get_display_height() and al_get_display_width(), then setting the actual open gl mode you want would work. I'd suggest that solution as well. The desktop usually will be set to the native size so there's little reason not to use it. Best is probably to make it a user option though so someone with a very low-end system could configure the game to use a lower resolution. [edit: in code] al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_FULLSCREEN_WINDOW); al_create_display(640, 480); /* size given here is ignored */
-- |
Matthew Leverton
Supreme Loser
January 1999
|
Elias said: I'd suggest that solution as well I don't think William wants to set the exact desktop mode, but just one that matches the aspect ratio. So you might have two main resolutions, one for 4:3 and another for widescreen. This is more convenient for tile/sprite based games than trying to support any resolution. |
|
1
2
|