[no subject]

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


PLUGIN *allegro_gl_plugin; /* Just a random name, really :) */
allegro_gl_plugin=find_plugin("AGL", 0x2400); /* need 0.24 or higher */
if (allegro_gl_plugin) {
  agl_dostuff();
}
else {
  /* either complain or use an alternate plugin, etc */
  /* could even try finding it again with a lower version number */
  /* if we have some fallback code to do stuff with the old API */
}

Of course, this probably means that plugin authors must follow some
guidelines (eg generating PIC code). I'm not knowledgeable at all in
this area, so I'll let other people point out any problems with this
approach, as the constraints placed on writers might be too high ?

Please comment

-- 
Vincent Penquerc'h 

------_=_NextPart_001_01C184A5.CA54A5A0
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2448.0">
<TITLE>Rambings about plugins</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Here is a suggestion on how official plugins could be implemented,</FONT>
<BR><FONT SIZE=2>quickly written during lunch. It would allow a program to query</FONT>
<BR><FONT SIZE=2>wether a plugin is available or nor in an unified way, which</FONT>
<BR><FONT SIZE=2>would be followed by the writers of the 'official' plugins.</FONT>
</P>

<P><FONT SIZE=2>Plugins would be described by a PLUGIN structure, and would be loaded</FONT>
<BR><FONT SIZE=2>as a shared library or be statically linked (in which case, the</FONT>
<BR><FONT SIZE=2>find_plugin and release_plugin functions would be trivial).</FONT>
</P>

<P><FONT SIZE=2>typedef struct {</FONT>
<BR><FONT SIZE=2>&nbsp; const char *name;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* ASCII, eg &quot;AGL&quot; */</FONT>
<BR><FONT SIZE=2>&nbsp; const char *display_name; /* UTF-8, eg &quot;AllegroGL v0.24&quot; */</FONT>
<BR><FONT SIZE=2>&nbsp; unsigned int version;&nbsp;&nbsp;&nbsp;&nbsp; /* 0x00MMmmrr (M)ajor (m)inor (r)evision */</FONT>
</P>

<P><FONT SIZE=2>/* private: */</FONT>
<BR><FONT SIZE=2>&nbsp; int refs;</FONT>
<BR><FONT SIZE=2>} PLUGIN;</FONT>
</P>

<P><FONT SIZE=2>These plugins could be stored internally in the list of MODULEs that</FONT>
<BR><FONT SIZE=2>now exist for Unix drivers, which could be exposed to other platforms.</FONT>
<BR><FONT SIZE=2>The void *handle can be coerced to point to whatever data structure</FONT>
<BR><FONT SIZE=2>a platform needs to keep track of shared libraries/objects. For DOS,</FONT>
<BR><FONT SIZE=2>such a list can be built at compile time (probably :))</FONT>
</P>

<P><FONT SIZE=2>/* the following functions would find and load a plugin */</FONT>
<BR><FONT SIZE=2>/* such a plugin could be in canonical places (eg /usr/local/lib/allegro) */</FONT>
<BR><FONT SIZE=2>/* or in other places in future versions of Allegro (in a DATAFILE :)) */</FONT>
<BR><FONT SIZE=2>PLUGIN *find_plugin(const char*, unsigned int min_version); /* incs refs */</FONT>
<BR><FONT SIZE=2>void release_plugin(PLUGIN*); /* decs refs and unloads if not used anymore */</FONT>
</P>

<P><FONT SIZE=2>From there, if the plugin was found, functions can be called on it.</FONT>
<BR><FONT SIZE=2>An example code snippet would be:</FONT>
</P>

<P><FONT SIZE=2>PLUGIN *allegro_gl_plugin; /* Just a random name, really :) */</FONT>
<BR><FONT SIZE=2>allegro_gl_plugin=find_plugin(&quot;AGL&quot;, 0x2400); /* need 0.24 or higher */</FONT>
<BR><FONT SIZE=2>if (allegro_gl_plugin) {</FONT>
<BR><FONT SIZE=2>&nbsp; agl_dostuff();</FONT>
<BR><FONT SIZE=2>}</FONT>
<BR><FONT SIZE=2>else {</FONT>
<BR><FONT SIZE=2>&nbsp; /* either complain or use an alternate plugin, etc */</FONT>
<BR><FONT SIZE=2>&nbsp; /* could even try finding it again with a lower version number */</FONT>
<BR><FONT SIZE=2>&nbsp; /* if we have some fallback code to do stuff with the old API */</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>

<P><FONT SIZE=2>Of course, this probably means that plugin authors must follow some</FONT>
<BR><FONT SIZE=2>guidelines (eg generating PIC code). I'm not knowledgeable at all in</FONT>
<BR><FONT SIZE=2>this area, so I'll let other people point out any problems with this</FONT>
<BR><FONT SIZE=2>approach, as the constraints placed on writers might be too high ?</FONT>
</P>

<P><FONT SIZE=2>Please comment</FONT>
</P>

<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Vincent Penquerc'h </FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C184A5.CA54A5A0--



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