A5 question about display adapters
William Labbett

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

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.

William Labbett

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

Does the example program not work?

Thomas Fjellstrom

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

I see so you want the desktop resolution. Do this through al_get_monitor_info

Matthew Leverton

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

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
i 1 width 640, height 480. format 2686584, refresh rate 60
i 2 width 640, height 480. format 2686584, refresh rate 66
i 3 width 640, height 480. format 2686584, refresh rate 73
i 4 width 640, height 480. format 2686584, refresh rate 75
i 5 width 640, height 480. format 2686584, refresh rate 59
i 6 width 640, height 480. format 2686584, refresh rate 60
i 7 width 640, height 480. format 2686584, refresh rate 66
i 8 width 640, height 480. format 2686584, refresh rate 73
i 9 width 640, height 480. format 2686584, refresh rate 75
i 10 width 640, height 480. format 2686584, refresh rate 59
i 11 width 640, height 480. format 2686584, refresh rate 60
i 12 width 640, height 480. format 2686584, refresh rate 66
i 13 width 640, height 480. format 2686584, refresh rate 73
i 14 width 640, height 480. format 2686584, refresh rate 75
i 15 width 800, height 600. format 2686584, refresh rate 56
i 16 width 800, height 600. format 2686584, refresh rate 60
i 17 width 800, height 600. format 2686584, refresh rate 70
i 18 width 800, height 600. format 2686584, refresh rate 72
i 19 width 800, height 600. format 2686584, refresh rate 75
i 20 width 800, height 600. format 2686584, refresh rate 56
i 21 width 800, height 600. format 2686584, refresh rate 60
i 22 width 800, height 600. format 2686584, refresh rate 70
i 23 width 800, height 600. format 2686584, refresh rate 72
i 24 width 800, height 600. format 2686584, refresh rate 75
i 25 width 800, height 600. format 2686584, refresh rate 56
i 26 width 800, height 600. format 2686584, refresh rate 60
i 27 width 800, height 600. format 2686584, refresh rate 70
i 28 width 800, height 600. format 2686584, refresh rate 72
i 29 width 800, height 600. format 2686584, refresh rate 75
i 30 width 1024, height 768. format 2686584, refresh rate 60
i 31 width 1024, height 768. format 2686584, refresh rate 66
i 32 width 1024, height 768. format 2686584, refresh rate 70
i 33 width 1024, height 768. format 2686584, refresh rate 72
i 34 width 1024, height 768. format 2686584, refresh rate 75
i 35 width 1024, height 768. format 2686584, refresh rate 60
i 36 width 1024, height 768. format 2686584, refresh rate 66
i 37 width 1024, height 768. format 2686584, refresh rate 70
i 38 width 1024, height 768. format 2686584, refresh rate 72
i 39 width 1024, height 768. format 2686584, refresh rate 75
i 40 width 1024, height 768. format 2686584, refresh rate 60
i 41 width 1024, height 768. format 2686584, refresh rate 66
i 42 width 1024, height 768. format 2686584, refresh rate 70
i 43 width 1024, height 768. format 2686584, refresh rate 72
i 44 width 1024, height 768. format 2686584, refresh rate 75
i 45 width 1152, height 864. format 2686584, refresh rate 60
i 46 width 1152, height 864. format 2686584, refresh rate 70
i 47 width 1152, height 864. format 2686584, refresh rate 75
i 48 width 1152, height 864. format 2686584, refresh rate 60
i 49 width 1152, height 864. format 2686584, refresh rate 70
i 50 width 1152, height 864. format 2686584, refresh rate 75
i 51 width 1152, height 864. format 2686584, refresh rate 60
i 52 width 1152, height 864. format 2686584, refresh rate 70
i 53 width 1152, height 864. format 2686584, refresh rate 75
i 54 width 1280, height 768. format 2686584, refresh rate 75
i 55 width 1280, height 768. format 2686584, refresh rate 75
i 56 width 1280, height 768. format 2686584, refresh rate 75
i 57 width 1280, height 960. format 2686584, refresh rate 60
i 58 width 1280, height 960. format 2686584, refresh rate 70
i 59 width 1280, height 960. format 2686584, refresh rate 72
i 60 width 1280, height 960. format 2686584, refresh rate 75
i 61 width 1280, height 960. format 2686584, refresh rate 60
i 62 width 1280, height 960. format 2686584, refresh rate 70
i 63 width 1280, height 960. format 2686584, refresh rate 72
i 64 width 1280, height 960. format 2686584, refresh rate 75
i 65 width 1280, height 960. format 2686584, refresh rate 60
i 66 width 1280, height 960. format 2686584, refresh rate 70
i 67 width 1280, height 960. format 2686584, refresh rate 72
i 68 width 1280, height 960. format 2686584, refresh rate 75
i 69 width 1280, height 1024. format 2686584, refresh rate 60
i 70 width 1280, height 1024. format 2686584, refresh rate 70
i 71 width 1280, height 1024. format 2686584, refresh rate 75
i 72 width 1280, height 1024. format 2686584, refresh rate 60
i 73 width 1280, height 1024. format 2686584, refresh rate 70
i 74 width 1280, height 1024. format 2686584, refresh rate 75
i 75 width 1280, height 1024. format 2686584, refresh rate 60
i 76 width 1280, height 1024. format 2686584, refresh rate 70
i 77 width 1280, height 1024. format 2686584, refresh rate 75
i 78 width 1440, height 900. format 2686584, refresh rate 60
i 79 width 1440, height 900. format 2686584, refresh rate 75
i 80 width 1440, height 900. format 2686584, refresh rate 60
i 81 width 1440, height 900. format 2686584, refresh rate 75
i 82 width 1440, height 900. format 2686584, refresh rate 60
i 83 width 1440, height 900. format 2686584, refresh rate 75

Now from this information can the screen resolution be worked out ?

Can anyone guess what my screen resolution is ?

Arthur Kalliokoski

In each line, "width" and "height" refer to the resolution of that particular screen mode, not how many pixels your monitor is capable of.

William Labbett

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

So what you want is the monitor's native resolution, not the one that is necessarily currently set?

Arthur Kalliokoski

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.

jmasterx

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?

Matthew Leverton

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

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

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.

William Labbett

Right.

Thanks j

jmasterx

Glad to help :)

Trent Gamblin

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

Thanks Trent.

just need to work out what 2686584 means for the pixel format.

Trent Gamblin

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

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 :

#SelectExpand
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

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

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
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.

Don Freeman
bool al_get_display_resolution( int &w, int &h )
{
   ALLEGRO_DISPLAY *display = al_get_current_display();
   if ( !display )
      return false;
   w = al_get_display_width(display);
   h = al_get_display_height(display);
   return true;
}

Matthew Leverton

He doesn't want the current resolution. He wants the resolution before setting the display.

Evert

Shouldn't the native resolution typically be the maximum resolution supported by the display?

jmasterx
Evert said:

Shouldn't the native resolution typically be the maximum resolution supported by the display?

Not always with CRTs, but for LCDs && LEDs I'd say so. But theres always that small bunch that still use CRTs ;)

Because with CRTs sometimes higher resolutions were supported at a cost of a headache-causing 60 Hz refresh rate.

Thomas Fjellstrom
jmasterx said:

Because with CRTs sometimes higher resolutions were supported at a cost of a headache-causing 60 Hz refresh rate.

Indeed, if you were trying to set a decent mode on a CRT, you'd want to skip any of the modes that only show up as 60hz, unless ALL of the modes are only 60hz... That'd be one crappy CRT.

Arthur Kalliokoski

I thought the limit on refresh rate was to keep down the clock rates for pixel sets? If the low res refresh rates were the same as the high res rates, the clocks per pixel would be much lower, so you could boost the refresh rate without making it impossible for the transistorized circuits to change color from one pixel to the next.

Thomas Fjellstrom

I thought the limit on refresh rate was to keep down the clock rates for pixel sets?

I don't know about you, but if I set a CRT to 60hz, it gives me awful headaches. The flickering is just too much.

Arthur Kalliokoski

Back in the day, 60hz was fine, because that's all you had! Never had an EGA monitor? n00bs!

Evert

Back in the day, 60hz was fine, because that's all you had!

For lower resolution modes, it was ok. For higher resolutions, not so much.

Thomas Fjellstrom
Evert said:

For lower resolution modes, it was ok. For higher resolutions, not so much.

I guess it depends on what you mean by "lower resolutions". My old 15" CRT back in the day gave me insane headaches at 1024x768.

My newer 20"+ CRTs all do modes higher than 1600x1200, but I dare not set them, for there madness lies.

Evert

I guess it depends on what you mean by "lower resolutions". My old 15" CRT back in the day gave me insane headaches at 1024x768.

640x480 or 800x600 is what I was thinking of when I said that, which is what my CRT could do at >60Hz in the mid to late 90s. My last one did 1024x768 at 85Hz or something like that, which was also fine.

Thread #605811. Printed from Allegro.cc