![]() |
|
Does al_set_new_display_adapter affect al_get_display_mode? |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Like the title says, does al_set_new_display_adapter affect the results of al_get_display_mode? I want to know the available modes for each adapter there is. That way I can detect my HDTV resolution programmatically through the HDMI cable, as well as other monitors. Cookies are on standby. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Elias
Member #358
May 2000
|
Yes, look here: https://github.com/liballeg/allegro5/blob/master/src/win/d3d_disp.cpp#L2895 int adapter = al_get_new_display_adapter(); if (adapter < 0) adapter = 0; if (!_al_pixel_format_is_real(allegro_formats[j]) || _al_pixel_format_has_alpha(allegro_formats[j])) continue; num_modes = _al_d3d->GetAdapterModeCount(adapter, (D3DFORMAT)d3d_formats[j]); So it does uses the current adapter when listing the available modes. -- |
Kris Asick
Member #1,424
July 2001
|
I'm going to say "yes", but that's just a guess. The simplest way to test would be to quickly write in some debug code which outputs the results of al_get_num_video_adapters() so you know how many adapters you can set to (in case the entirety of the desktop space counts as one), then simply set one of those adapters and report the result of al_get_num_display_modes() for each one. If the results differ for each video adapter, the answer to your question is yes. If not, the answer is no. EDIT: Nevermind. Better answer posted above while I was writing this post. --- Kris Asick (Gemini) |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Looks like _al_wgl_get_display_mode enumerates them every time, but it totally ignores the adapter entirely. So you can't rely on it with OpenGL. I'm not sure where the comment in _al_wgl_get_num_display_modes is coming from, but you can get a list of the display devices on Windows by using EnumDisplayDevices. You don't have to create a window to do it either. So this function could easily be altered to use a specific adapter. EnumDisplayDevices returns a DEVMODE object with the number of bits per pixel, but it doesn't tell you the layout of the rgb structure. OpenGL will use the adapter you set with al_set_new_display_adapter when you create a display, but right now there is now way to enumerate display modes on anything but the default display. Unless I'm missing something, which I very well could be. :/ 285/* Function: al_set_new_display_adapter
286 */
287void al_set_new_display_adapter(int adapter)
288{
289 thread_local_state *tls;
290
291 if ((tls = tls_get()) == NULL)
292 return;
293
294 if (adapter < 0) {
295 tls->new_display_adapter = ALLEGRO_DEFAULT_DISPLAY_ADAPTER;
296 }
297 tls->new_display_adapter = adapter;
298}
1585
1586int _al_wgl_get_num_display_modes(int format, int refresh_rate, int flags)
1587{
1588 DEVMODE dm;
1589 int count = 0;
1590
1591 /* FIXME: Ignoring format.
1592 * To get a list of pixel formats we have to create a window with a valid DC, which
1593 * would even require to change the video mode in fullscreen cases and we really
1594 * don't want to do that.
1595 */
1596 (void)format;
1597 (void)refresh_rate;
1598 (void)flags;
1599
1600 memset(&dm, 0, sizeof(dm));
1601 dm.dmSize = sizeof(dm);
1602
1603 while (EnumDisplaySettings(NULL, count, &dm) != false) {
1604 count++;
1605 }
1606
1607 return count;
1608}
1609
1610
1611ALLEGRO_DISPLAY_MODE *_al_wgl_get_display_mode(int index, int format,
1612 int refresh_rate, int flags,
1613 ALLEGRO_DISPLAY_MODE *mode)
1614{
1615 DEVMODE dm;
1616
1617 /*
1618 * FIXME: see the comment in _al_wgl_get_num_display_modes
1619 */
1620 (void)format;
1621 (void)refresh_rate;
1622 (void)flags;
1623
1624 memset(&dm, 0, sizeof(dm));
1625 dm.dmSize = sizeof(dm);
1626
1627 if (!EnumDisplaySettings(NULL, index, &dm))
1628 return NULL;
1629
1630 mode->width = dm.dmPelsWidth;
1631 mode->height = dm.dmPelsHeight;
1632 mode->refresh_rate = dm.dmDisplayFrequency;
1633 mode->format = format;
1634 switch (dm.dmBitsPerPel) {
1635 case 32:
1636 if (format == ALLEGRO_PIXEL_FORMAT_ANY)
1637 mode->format = ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA;
1638 else if (format == ALLEGRO_PIXEL_FORMAT_ANY_NO_ALPHA)
1639 mode->format = ALLEGRO_PIXEL_FORMAT_ANY_32_NO_ALPHA;
1640 break;
1641 case 24:
1642 mode->format = ALLEGRO_PIXEL_FORMAT_ANY_24_NO_ALPHA;
1643 break;
1644 case 16:
1645 if (format == ALLEGRO_PIXEL_FORMAT_ANY)
1646 mode->format = ALLEGRO_PIXEL_FORMAT_ANY_16_WITH_ALPHA;
1647 else if(format == ALLEGRO_PIXEL_FORMAT_ANY_NO_ALPHA)
1648 mode->format = ALLEGRO_PIXEL_FORMAT_ANY_16_NO_ALPHA;
1649 break;
1650 default:
1651 break;
1652 }
1653
1654 return mode;
1655}
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|