|
A4 Validating accepted program window sizes |
raynebc
Member #11,908
May 2010
|
In a program I work on, I am recently adding the ability for the user to define the window width and height instead of pick some known-good presets, but the problem is I can't tell whether the user supplied window size will work until I call set_gfx_mode() and see if it returned success. Is there a reasonably simple way to tell in advance what windows sizes will be able to be applied? |
Frank Drebin
Member #2,987
December 2002
|
I think some example that comes with Allegro 4 gives you a list of available graphic modes to select from at startup ... maybe it was the Allegro 4 demo itself... You could take a look at that source code. If this doesn't work what I would do is to open a window with a width and height that is likely/alomst guaranteed to be supported (classical resolutions like 320x240, 640x480, 800x600, ...) and then you could try to set the first user-defined width and height (e.g. 975x625) out of this with a call to set_gfx_mode. Then check the return value of set_gfx_mode and return to the previous width and height if this fails. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
There's probably some minimum size, but 320x240 should always always be safe and available for a window size. And you can increase that up until it reaches the size of the screen, minus title bar and window frame. It should only fail if it is too large for the screen. EDIT GFX_DIRECTX_WIN said:
GFX_DIRECTX_WIN if (desktop_color_depth() == 16) { set_color_depth(16); if (set_gfx_mode(GFX_DIRECTX_WIN, 640, 480, 0, 0) != 0) { set_color_depth(15); if (set_gfx_mode(GFX_DIRECTX_WIN, 640, 480, 0, 0) != 0) { /* 640x480 direct drawing mode not supported */ goto Error; } } /* ok, we are in direct drawing mode */ } Note that, mainly for performance reasons, this driver requires the width of the screen to be a multiple of 4. This driver is capable of displaying a hardware cursor, but there are size restrictions. Typically, the cursor image cannot be more than 32x32 pixels.
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 |
raynebc
Member #11,908
May 2010
|
Frank That's pretty much the workaround I've been doing, is try to set it and revert to the previous window size if the new one fails. Edgar A requirement for the width to be a multiple of 4 is probably the information I was missing. Thanks to both of you for your replies. |
|