Re: [AD] split_modex_screen

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Friday 21 January 2005 14:56, Peter Wang wrote:
> Following the change to make GFX_* constants always defined, there is 
> now incorrect code in the test programs and examples which looks like 
this:
> 
>     #ifdef GFX_MODEX
>        if (gfx_driver->id == GFX_MODEX)
>           split_modex_screen(...);
>     #endif
> 
> which doesn't compile if Mode-X is not available on the system, yet 
> GFX_MODEX is defined.  What do we do about this?

Well, as faras I'm concerned, always defining the symbols for drivers that 
aren't there is a misfeature to begin with, so if you want to revert that 
change that's fine by me.
As for why I concider this to be a misfeature, let's consider two ways in 
which the driver defines can be interpreted.
The first is that for a given system, there can be a number of specific 
graphics drivers, which are given by the driver name #defines. Wether the 
driver actually works or not will become clear when one tries to 
initialize it.
The second is that there are a number of possible drivers, and at compile 
time Allegro is build/configured with a number of them. These are the ones 
that are in principle available on the system, and defines are provided 
for these but not for those that are not available.
Clearly, 1 is how it is now and 2 is how it was originally and how Allegro 
itself assumes it works.

The reason I think the second alternative is better and more logical is... 
well, basically that it makes sense. There is no GFX_DIRECTX on UNIX, 
because it's a Windows driver. This surprises noone. But not all UNICES 
are the same, so why should there always be a define for a GFX_DGA driver? 
I would expect that not to be there if I were running Solaris, or had 
disabled it at configure time.

As I recall, this was changed when the DGA1 driver was removed because user 
code might depend on the symbol being defined. Personally, I think such 
code was broken to begin with as even prior to the removal of the driver 
it wasn't guarenteed to always be there. Leaving the DGA1 define be 
defined although the driver itself was no more may have been a good idea 
(but I think that's debatable as well, not to mention confusing) for 
backward compatibility, but defining all of them always was a mistake, I 
think. Not to mention that now programs that relied on the old behavior 
are now broken, as is clear with Allegro's own #ifdef GFX_MODEX problems.

So I really think this has, in the end, caused more problems than it was 
intended to solve and we should consider reverting the change. The 
alternative would be to seperate the driver identifiers from the defines 
that say if a driver is available, although that seems somewhat redundant.
For mode-x specifically, I think there already is a GFX_HAS_VGA 
preprocessor symbol.

So, yeah... sorry for the long rant ;)

Evert





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/