![]() |
|
Can't enumerate fullscreen modes before a display is created |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
I am doing a little testing of some stuff, and I can't enumerate the fullscreen display modes on my laptop before creating a display. If I call this code after I create a display it runs fine no problem. printf("Fullscreen modes :\n"); for (int i = 0 ; i < al_get_num_display_modes() ; ++i) { ALLEGRO_DISPLAY_MODE mode; if (al_get_display_mode(i , &mode) == &mode) { printf("Mode #%i w,h = %d , %d , format = %d , refresh_rate = %d\n" , i , mode.width , mode.height , mode.format , mode.refresh_rate); } } Debugging session : c:\ctwoplus\progcode\allegro5\test\Multisampling>gdb minfo.exe Program received signal SIGSEGV, Segmentation fault. 0x6f128abe in _al_d3d_get_num_display_modes (format=format@entry=0, refresh_rate=refresh_rate@entry=0, flags=0) at C:\mingw\LIBS\A5GIT\allegro\src\win\d3d_disp.cpp:2896 2896 num_modes = _al_d3d->GetAdapterModeCount(adapter, (D3DFORMAT)d3d_formats[j]); (gdb) p _al_d3d $1 = (LPDIRECT3D9) 0x0 (gdb) bt #0 0x6f128abe in _al_d3d_get_num_display_modes (format=format@entry=0, refresh_rate=refresh_rate@entry=0, flags=0) at C:\mingw\LIBS\A5GIT\allegro\src\win\d3d_disp.cpp:2896 #1 0x6f11de54 in win_get_num_display_modes () at C:\mingw\LIBS\A5GIT\allegro\src\win\wsystem.c:394 #2 0x0040392e in main () (gdb) A display hasn't been created, so the d3d or opengl driver hasn't been setup yet, but it calls the _al_d3d driver while it is still null and crashes. 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 |
SiegeLord
Member #7,827
October 2006
![]() |
Ooohh... that's a nasty regression. Sorry about that... 5.1.11 might come sooner than usual "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Hasn't this sort of been a lingering design issue? If the driver isn't set up before creating the display then any functions that rely on it will fail. Which driver to set up though? DX or OGL? That isn't determined until the display is created, currently. 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 |
SiegeLord
Member #7,827
October 2006
![]() |
I think what used to happen is that D3D code would get initialized no matter what, so that function worked for D3D. For OpenGL, no initialization is necessary as far as I can tell. The fix for this is to just add a call to the necessary initialization function (or encapsulate it in a singleton-like function call). EDIT: Should be fixed as of http://sourceforge.net/p/alleg/allegro/ci/e0e4c27. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Is D3D required then on Windows? Here's another issue - take a look at what happens if I then create an OpenGL window : c:\ctwoplus\progcode\allegro5\test\Multisampling>ms.exe Monitor info : Adapter #0 : x1 y1 x2 y2 = 0 0 1280 800 Fullscreen modes : Mode #0 w,h = 640 , 480 , format = 23 , refresh_rate = 60 Mode #1 w,h = 800 , 600 , format = 23 , refresh_rate = 60 Mode #2 w,h = 1024 , 768 , format = 23 , refresh_rate = 60 Mode #3 w,h = 1280 , 800 , format = 23 , refresh_rate = 60 Mode #4 w,h = 640 , 480 , format = 13 , refresh_rate = 60 Mode #5 w,h = 800 , 600 , format = 13 , refresh_rate = 60 Mode #6 w,h = 1024 , 768 , format = 13 , refresh_rate = 60 Mode #7 w,h = 1280 , 800 , format = 13 , refresh_rate = 60 New window x,y = 2147483647,2147483647 INT_MAX = 2147483647 Fullscreen modes after setting OpenGL display : Mode #0 w,h = 640 , 480 , format = 0 , refresh_rate = 60 Mode #1 w,h = 640 , 480 , format = 0 , refresh_rate = 60 Mode #2 w,h = 640 , 480 , format = 5 , refresh_rate = 60 Mode #3 w,h = 640 , 480 , format = 5 , refresh_rate = 60 Mode #4 w,h = 640 , 480 , format = 8 , refresh_rate = 60 Mode #5 w,h = 640 , 480 , format = 8 , refresh_rate = 60 Mode #6 w,h = 800 , 600 , format = 0 , refresh_rate = 60 Mode #7 w,h = 800 , 600 , format = 0 , refresh_rate = 60 Mode #8 w,h = 800 , 600 , format = 5 , refresh_rate = 60 Mode #9 w,h = 800 , 600 , format = 5 , refresh_rate = 60 Mode #10 w,h = 800 , 600 , format = 8 , refresh_rate = 60 Mode #11 w,h = 800 , 600 , format = 8 , refresh_rate = 60 Mode #12 w,h = 1024 , 768 , format = 0 , refresh_rate = 60 Mode #13 w,h = 1024 , 768 , format = 0 , refresh_rate = 60 Mode #14 w,h = 1024 , 768 , format = 5 , refresh_rate = 60 Mode #15 w,h = 1024 , 768 , format = 5 , refresh_rate = 60 Mode #16 w,h = 1024 , 768 , format = 8 , refresh_rate = 60 Mode #17 w,h = 1024 , 768 , format = 8 , refresh_rate = 60 Mode #18 w,h = 1280 , 800 , format = 0 , refresh_rate = 60 Mode #19 w,h = 1280 , 800 , format = 5 , refresh_rate = 60 Mode #20 w,h = 1280 , 800 , format = 8 , refresh_rate = 60 c:\ctwoplus\progcode\allegro5\test\Multisampling> The modes returned by the driver change. Edit 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 |
SiegeLord
Member #7,827
October 2006
![]() |
Edgar Reynaldo said: Is D3D required then on Windows? You can call al_get_display_mode without D3D. If your Allegro comes with both you can force OpenGL via al_set_new_display_flags. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Oh, okay. Wasn't thinking that al_set_new_display_flags could be used to alter the results of al_get_display_mode. Edit How could I compile allegro without DX? Ie, say I wanted to trim down my libs and programs by removing it, how do I do that? 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 |
SiegeLord
Member #7,827
October 2006
![]() |
-DWANT_D3D=off should do the trick. Also, just to be clear... what's wrong with the display modes you're finding (it's a bit early here so I'm not quite seeing it)? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Sorry, miscommunication. All I meant to say is that the number and format of modes differs whether you use D3D or OpenGL to enumerate it. So that makes a difference as to which driver should be in use before a display is created. But as you said, enumerating modes for a specific backend is as simple as calling al_set_new_display_flags. That is not intuitive to me. It seems like more global mystery state. 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 |
SiegeLord
Member #7,827
October 2006
![]() |
Edgar Reynaldo said: It seems like more global mystery state. In many ways, it is "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
|