Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Tester for set_gfx_mode complete

This thread is locked; no one can reply to it. rss feed Print
Tester for set_gfx_mode complete
Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I've completed a testing and logging program for the allegro function set_gfx_mode.
Since I've been having problems setting more than one resolution in a row I figured I would write out a program that allows me to easily log how well it is working. If anyone else is having problems with set_gfx_mode then they should be able to use this to report their problems as well.

Feel free to use any of my source code in your programs if you like , as long as you give me credit for it somewhere and don't pass it off as your own.
Source code zip file plus two batch files for compiling and linking with MinGW in a Windows cmd interpreter.
Windows Binary (dynamic debug version , Allegro 4.2.2)
All example pictures and logs (jpegs and text files)

What it does :
1. Sets up Allegro and an initial resolution for the program.
2. Draws and displays a pair of checkered bitmaps that alternate. The checkers are 100X100 for easy screen size reference.
3. (Enter key) Lets the user change into a different resolution , color depth and mode using gfx_mode_select_filter (nothing less than 320 X 240 , nothing bigger than the desktop resolution , and only 4:3,16:9,or 16:10 resolutions)
4. If the resolution or color depth changes , go back to step 2.
5. (L key) Lets the user log whether this was a success or not and enter any notes into the text log file through an Allegro gui interface.
6. (P key) Pause.
7. (ESC key) Quit.

Any time the resolution is changed a function called change_res is called. This is a wrapper for Allegro's set_gfx_mode function. Change_res is called with a mode argument that is either 1 , 2 , or 3. This is also the argument used to start the program with.
SetGfxModeTest must be run from the command line with the argument of 1 , 2 , or 3.

Change_res modes :
Mode 1 : When changing resolutions , directly call set_gfx_mode for the requested resolution and mode.
Mode 2 : When changing resolutions , first change into GFX_TEXT mode , and then use set_gfx_mode to change into the requested resolution and mode.
Mode 3 : When changing resolutions , first change into GFX_TEXT mode , next use allegro_message to output a popup message to the screen , and then use set_gfx_mode to change into the requested resolution and mode.
Mode 1 : No GFX_TEXT , No allegro_message , Set gfx mode
Mode 2 : Set GFX_TEXT , No allegro_message , Set gfx mode
Mode 3 : Set GFX_TEXT , Use allegro_message , Set gfx mode

Mode 3 is what I've been using in my programs for some time when I need to change to another mode and resolution. It's not perfect , but it's a far cry better than the results I had been having in mode 1 or 2. (Note : Mode 3 always works to change properly to the new graphics mode , even if the window looks a little funny during the allegro_message transition.

Here are some examples of what happens in each mode. Hopefully this can help the Allegro developers figure out what is going on. ( Please look at the associated logs as they have detailed descriptions of what happened to create the examples seen below )

Example 1 , Mode 1
Program Log for examples 1 and 2
Allegro Log for examples 1 and 2
{"name":"593509","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/8\/e80ff040f9bd3f1d866c1d175ad8eda3.jpg","w":1024,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/8\/e80ff040f9bd3f1d866c1d175ad8eda3"}593509

Example 2 , Mode 1
Program Log for examples 1 and 2
Allegro Log for examples 1 and 2
{"name":"593510","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/7\/871a7b68578c6b25dcb62dedc11d807a.jpg","w":1024,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/7\/871a7b68578c6b25dcb62dedc11d807a"}593510

Example 3 , Mode 1
Program Log for example 3
Allegro Log for example 3
{"name":"593511","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/3\/d32cc69a4f2c2adca0c75cb10e296cdd.jpg","w":1024,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/3\/d32cc69a4f2c2adca0c75cb10e296cdd"}593511

Example 4 , Mode 1
Program Log for example 4
Allegro Log for example 4
http://www.allegro.cc/files/attachment/593512

Example 5 , Mode 2
Program Log for example 5
Allegro Log for example 5
http://www.allegro.cc/files/attachment/593513

Example 6 , Mode 3
Program Log for examples 6 and 7
Allegro Log for examples 6 and 7
{"name":"593545","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/8\/a866f9277e43e311db43c747bdf8b0e8.jpg","w":1024,"h":768,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/8\/a866f9277e43e311db43c747bdf8b0e8"}593545

Example 7 , Mode 3
Program Log for examples 6 and 7
Allegro Log for examples 6 and 7
http://www.allegro.cc/files/attachment/593546

To sum everything up , most of the problems encountered changing to a new graphics mode happen when changing from a non-desktop sized fullscreen resolution to any windowed mode. The monitor is forced to change its working resolution (I hear the monitor click inside) and then allegro sets a window the size of the desktop. The only portion of that window that is being drawn to is the requested size area in the upper left corner of the window.

Hope all this helps.:) Any questions?

Go to: