Re: [AD] Magic main in Windows

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


On Monday 02 August 2004 20:48, Stepan Roh wrote:
> I think get_executable_name() should be dropped w/o replacement or with 
> something like your find_file() (which I removed from this post :-) ) as 
a 
> replacement.

It can't really be dropped because of API compatibility. However, a 
function that locates a file might be useful.

> Could be (in the spirit of find_allegro_resource(), but smaller):
> 
> int find_user_resource(char *dest, const char *resource, int type, int 
> size);
> 
> where type is either DATA or STATE or whatever you like
> 
> Places where such resource is located in are configured with:
> 
> add_user_resource_dir(const char *dir, int type);
> 
> Default resource dirs (last ones to be searched) are program dir for 
> Windows and current dir for *nix.

I think something like this could work (in fact, I use something comparable 
in my own programs), but I'm not sure if it is something that should be 
build into Allegro.

> In main() programmers write:
> 
> #ifdef DATA_DIR
> add_user_resource_dir(DATA_DIR, DATA);
> #endif
> #ifdef STATE_DIR
> add_user_resource_dir(STATE_DIR, STATE);
> #endif
> 
> Values of *_DIR are supplied by some config.h created during build 
> process on *nix and undefined on Windows.

If they're undefined on Windows, then most users aren't going to bother 
using them. If we want people to write platform independent code, then we 
need them to be able to do so without too much trouble.
I personally probably wouldn't bother with similar typedefs in my code if 
they were needed to make my program do something particular in Windows. ;)

As an analogy, consider the ALLEGRO_VRAM_SINGLE_SURFACE define: this has to 
be used to make things like double buffering or tripple buffering work in 
Windows as well as X. Up to recently, not even Allegro's examples and demo 
game used to check for this.

Evert





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