<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[C#] I&#39;m working on an Allegro C# binding, any requests?</title>
		<link>http://www.allegro.cc/forums/view/597224</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 29 Aug 2008 00:47:16 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Prompted by <a href="http://www.allegro.cc/forums/thread/597017/761833#target">BAF&#39;s complaints against current C# bindings</a>, I&#39;ve taken it upon myself to write up a relatively simple C# binding for Allegro.</p><p><b>Objective:</b></p><p>To create a C# binding for Allegro with an API familiar to users of both Allegro and .NET, and have the whole project done in time for TINS.</p><p><b>Current Status:</b></p><p>About 25%.</p><p>It currently consists of two parts: a tiny C library that translates some of the Allegro API to be .NET-friendly, and the actual C# library.</p><p>I&#39;ve been sticking fairly close to the API, but changing the wording where appropriate to match familiar .NET syntax, and adding scope where appropriate. (ie. Allegro.Init(), Keyboard.Install())</p><p><b>Feature Requests/Comments/Concerns/Gripes against other bindings</b><br />(aka the point of this thread)</p><p>Post em here. I want to make something everyone can use.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 31 Jul 2008 15:14:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t use C# but I think you should use an &quot;Allegro scope&quot; for everything. So use &quot;Allegro.Keyboard.Install ()&quot; instead your example. It will avoid collisions better.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Niunio)</author>
		<pubDate>Thu, 31 Jul 2008 15:51:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>C# puts everything in your project in a namespace by default. (I&#39;m not sure if you can even have code outside a namespace...) The namespace for the project is <tt>AllegroSharp</tt>, so if you don&#39;t resolve it with a <tt>using</tt> directive, it is <tt>AllegroSharp.Keyboard.Install()</tt>.</p><p>Question: What is the most desirable syntax for Datafiles?</p><div class="source-code snippet"><div class="inner"><pre><span class="c">// Most verbose...</span>
Bitmap bmp <span class="k3">=</span> myDatafile.FindObject<span class="k2">(</span><span class="s">"FILE"</span><span class="k2">)</span>.FindObject<span class="k2">(</span><span class="s">"BMP"</span><span class="k2">)</span>.Cast<span class="k3">&lt;</span>Bitmap&gt;<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>

<span class="c">// Most sugary...</span>
Bitmap bmp <span class="k3">=</span> myDatafile<span class="k2">[</span><span class="s">"FILE"</span><span class="k2">]</span><span class="k2">[</span><span class="s">"BMP"</span><span class="k2">]</span><span class="k2">;</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sat, 02 Aug 2008 16:44:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there some particular reason for it being AllegroSharp rather than Allegro? The name is quite long enough as it is.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Sat, 02 Aug 2008 17:31:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hah! Thats the same thing I wanted to say 3 hours earlier. But, my comment was more like:</p><p>Why must it be named AllegroSharp. I mean, you are already programming it in C <i>Sharp</i>, why does that need to be in the name of the binding too?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vanneto)</author>
		<pubDate>Sat, 02 Aug 2008 17:52:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, you don&#39;t normally specify a namespace in C# unless there&#39;s a conflict, which has never happened to me.</p><p>Besides, it can&#39;t be Allegro because I have a static class called Allegro.</p><p>For illustration purposes:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">using</span> System<span class="k2">;</span>
<span class="k1">using</span> AllegroSharp<span class="k2">;</span>

<span class="k1">class</span> Program
<span class="k2">{</span>
    <span class="k1">static</span> <span class="k1">void</span> Main<span class="k2">(</span>string<span class="k2">[</span><span class="k2">]</span> args<span class="k2">)</span>
    <span class="k2">{</span>
        Allegro.Init<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
        <span class="c">// Supposing I've defined a class called Keyboard somewhere,</span>
        <span class="c">// I have to resolve this.</span>
        AllegroSharp.Keyboard.Install<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
        <span class="c">// etc...</span>
        Allegro.Exit<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
    <span class="k2">}</span>
<span class="k2">}</span>
</pre></div></div><p>

But if you think AllegroSharp is a long namespace, try Microsoft.Xna.Framework!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Sun, 03 Aug 2008 08:30:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Perhaps you should reconsider naming that class Allegro, then. From the looks of it, most operations will be on the namespace, not that class.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Sun, 03 Aug 2008 12:02:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, progress update.</p><p>Mostly everything is fully implemented, and about 65% of what&#39;s implemented is documented.</p><p>The things it still needs are:
</p><ul><li><p>Joystick needs to be redesigned because it&#39;s not playing nicely with the interop.</p></li><li><p>GUI needs to be implemented.</p></li><li><p>Fixed point and 3D math are being left out because there&#39;s no use for them.</p></li><li><p>Lots of documentation still, went on a coding binge without documenting.</p></li><li><p>Translate the rest of the examples. (Currently translated 5 of them)</p></li></ul><p>&lt;/li&gt;</p><p>Here&#39;s ExData, the shortest example I&#39;ve translated.</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">using</span> System<span class="k2">;</span></td></tr><tr><td class="number">2</td><td><span class="k1">using</span> AllegroSharp<span class="k2">;</span></td></tr><tr><td class="number">3</td><td>&#160;</td></tr><tr><td class="number">4</td><td><span class="k1">namespace</span> ExData</td></tr><tr><td class="number">5</td><td><span class="k2">{</span></td></tr><tr><td class="number">6</td><td>    <span class="k1">class</span> Program</td></tr><tr><td class="number">7</td><td>    <span class="k2">{</span></td></tr><tr><td class="number">8</td><td>        <span class="k1">static</span> <span class="k1">void</span> Main<span class="k2">(</span>string<span class="k2">[</span><span class="k2">]</span> args<span class="k2">)</span></td></tr><tr><td class="number">9</td><td>        <span class="k2">{</span></td></tr><tr><td class="number">10</td><td>            Datafile datafile <span class="k3">=</span> <span class="k1">new</span> Datafile<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>            Allegro.Init<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>            Keyboard.Install<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>            Graphics.SetMode<span class="k2">(</span>GraphicsDriver.AutoDetectWindowed, <span class="n">320</span>, <span class="n">200</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>            Graphics.ColorConversion <span class="k3">=</span> ColorConversion.None<span class="k2">;</span></td></tr><tr><td class="number">15</td><td>            datafile.Load<span class="k2">(</span><span class="s">"example.dat"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>            Palette.Set<span class="k2">(</span>datafile.FindObject<span class="k2">(</span><span class="s">"THE_PALETTE"</span><span class="k2">)</span>.Cast<span class="k3">&lt;</span>Palette&gt;<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>            Graphics.ColorConversion <span class="k3">=</span> ColorConversion.PresetTotal<span class="k2">;</span></td></tr><tr><td class="number">18</td><td>            Text.Out<span class="k2">(</span>Graphics.Screen, <span class="k1">new</span> Point<span class="k2">(</span><span class="n">32</span>, <span class="n">16</span><span class="k2">)</span>, Color.White, <span class="s">"This is the bitmap:"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>            datafile.FindObject<span class="k2">(</span><span class="s">"SILLY_BITMAP"</span><span class="k2">)</span>.Cast<span class="k3">&lt;</span>Bitmap&gt;<span class="k2">(</span><span class="k2">)</span>.Blit<span class="k2">(</span></td></tr><tr><td class="number">20</td><td>                Graphics.Screen, <span class="k1">new</span> Rectangle<span class="k2">(</span><span class="n">0</span>, <span class="n">0</span>, <span class="n">64</span>, <span class="n">64</span><span class="k2">)</span>, <span class="k1">new</span> Point<span class="k2">(</span><span class="n">64</span>, <span class="n">32</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">21</td><td>            Text.Out<span class="k2">(</span>Graphics.Screen, datafile.FindObject<span class="k2">(</span><span class="s">"BIG_FONT"</span><span class="k2">)</span>.Cast<span class="k3">&lt;</span>Font&gt;<span class="k2">(</span><span class="k2">)</span>, <span class="k1">new</span> Point<span class="k2">(</span><span class="n">32</span>, <span class="n">128</span><span class="k2">)</span>,</td></tr><tr><td class="number">22</td><td>                Color.PureGreen, <span class="s">"And this is a big font!"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">23</td><td>            Keyboard.ReadKey<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>            datafile.Unload<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>        <span class="k2">}</span></td></tr><tr><td class="number">26</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">27</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

Feel free to mock the hell out of the API. <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Tue, 05 Aug 2008 13:36:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
</p><ol><li><p>Testing on Mono
</p></li></ol></div></div><p>

You&#39;re going to make it work in Monodevelop?</p><p>I just checked out and tried to build. It fails.<br />First error at this line in Bitmap.cs<br />protected virtual IntPtr ptr { get ; set ; }</p><p>get must have a body because it is not marked abstract, extern, or partial
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Mon, 18 Aug 2008 01:05:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
I just checked out and tried to build. It fails.<br />First error at this line in Bitmap.cs<br />protected virtual IntPtr ptr { get ; set ; }
</p></div></div><p>
You are using an old Mono version - update to 1.2.6 or higher and use the gmcs compiler with the switch that enables the new C# 3.0 features.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fiddler)</author>
		<pubDate>Tue, 19 Aug 2008 19:23:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>And what switch is that?<br />I googled a bit and can&#39;t find it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Wed, 20 Aug 2008 01:02:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>IIRC it&#39;s -langversion:linq, which should be enabled by default on Mono 1.9+.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fiddler)</author>
		<pubDate>Wed, 20 Aug 2008 01:54:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Perhaps you should reconsider naming that class Allegro, then. From the looks of it, most operations will be on the namespace, not that class.
</p></div></div><p>
You can&#39;t have methods at namespace level in C#. Even static methods should be in class scope.</p><p>I like the name AllegroSharp. Though if you consider it might work as well on VB.Net, maybe it <b>should</b> be called AllegroNet or something like that.</p><p>I&#39;m trying it right now on some MSVC# Express edition! It for sure will delay my tests on XNA but I bet it worth! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Biznaga)</author>
		<pubDate>Wed, 20 Aug 2008 03:40:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is the 1.9+ stable enough for usage?</p><p>Anyway, just for the heck of it I fixed those errors to see what comes next. And found out it builds with just 28 warnings. But running an example is a different matter. It doesn&#39;t find AllegroBridge.dll so I guess one needs to do something about that. I don&#39;t know how this stuff works though so someone could maybe explain? I&#39;m guessing I need to have a AllegroBridge.so, but how exactly should it be built, and then referenced in monodevelop?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trezker)</author>
		<pubDate>Wed, 20 Aug 2008 11:47:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p> 
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Is the 1.9+ stable enough for usage?
</p></div></div><p>
For most uses, yes. Some Windows.Forms parts have a few kinks, as does the ASP .Net module, but otherwise its quite solid. I develop an opengl simulation for my diploma thesis and I have no problems running the same executable on Mono/.Net. Mono 2.0 should arrive on September and should be a stable implementation of .Net 2.0 (plus some newer parts, e.g. linq). </p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Anyway, just for the heck of it I fixed those errors to see what comes next. And found out it builds with just 28 warnings. But running an example is a different matter. It doesn&#39;t find AllegroBridge.dll so I guess one needs to do something about that. I don&#39;t know how this stuff works though so someone could maybe explain? I&#39;m guessing I need to have a AllegroBridge.so, but how exactly should it be built, and then referenced in monodevelop?
</p></div></div><p>
This is an unmanaged library that smooths out Allegro&#39;s API, to make wrapping simpler (without having looked at the source, I&#39;m pretty sure it provides getters/setters for global variables and things like that). This will have to be compiled for each platform (while the C# wrapper needs only to be compiled once).</p><p>Once you have an .so, you simply instruct Mono to use this .so instead of the windows dll. Check here for details: <a href="http://www.mono-project.com/Config_DllMap">http://www.mono-project.com/Config_DllMap</a></p><p>Edit: Btw, the A5 API should be much more wrapper-friendly (no need for intermediate dlls etc).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Fiddler)</author>
		<pubDate>Wed, 20 Aug 2008 13:24:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry guys, I&#39;d love to address the concerns raised here in-depth, but I&#39;ve got some eye problems and I won&#39;t be able to use the computer much for the next couple weeks. Not sure how that&#39;s gonna work out with TINS yet, I might get the a-ok by then.</p><p>You&#39;re correct about AllegroBridge. It&#39;s included in the source distribution and a .dll is included in the binary distro, but no .so yet.</p><p>Yes, AllegroNet might&#39;ve been a better namespace, but I didn&#39;t want to step on the toes of the Allegro.NET project.</p><p>Don&#39;t rely too explicitly on the API yet*, I&#39;m looking to change the memory management after TINS to leave unmanaged memory at the threshold of interop instead of carrying it over. I&#39;d tried this before and encountered problems, so I took the &quot;First make it work, then make it work better.&quot; approach.</p><p>*Just a warning. I don&#39;t plan to change the API, but I can&#39;t guarantee it won&#39;t as a result of this goal.</p><p>~~~</p><p><a href="http://allegrosharp.lessthanthree.vg/">I&#39;ve added solutions and projects specifically for SharpDevelop/Mono.</a></p><p>They <b>should</b> work for Linux, but I don&#39;t have a distro at hand so I can&#39;t test it at the moment. You will need to compile AllegroBridge yourself, on Linux, which should be easy as pie: Insert source files, receive library.</p><p>If you would rather not use dll mapping, you can change ALLEG_DLL and BRIDGE_DLL (in src/Bridge/Bridge.cs) to be *.so instead of *.dll.</p><p>It seems there should be a preprocessor directive for determining the platform, but I can&#39;t find one.</p><p>Happy coding! <img src="http://www.allegro.cc/forums/smileys/cheesy.gif" alt=":D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Tue, 26 Aug 2008 05:20:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Have you considered naming the namespace <i>Al4</i> (then <i>Al5</i>) or similar to distinguish the Allegro versions? Plus it&#39;s shorter.</p><p>Just a suggestion.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Archon)</author>
		<pubDate>Tue, 26 Aug 2008 06:17:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Besides, it can&#39;t be Allegro because I have a static class called Allegro.
</p></div></div><p>
It too can. C# is smart enough to figure out the difference between class Allegro, namespace Allegro, and class instance Allegro. Therefor, you can have a class, a namespace and a variable all by the same name, sharing scope.<br />Long namespace names are not much of a concern though, assuming you&#39;re using Visual Studio&#39;s Intellisense (which works better with C# than with most other languages). How else would people not get offended by stuff like this: <span class="source-code">System.Data.SqlClient.SqlParameter param <span class="k3">=</span> <span class="k1">new</span> System.Data.SqlClient.SqlParameter<span class="k2">(</span><span class="s">"@foo"</span>, foo<span class="k2">)</span><span class="k2">;</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Tue, 26 Aug 2008 18:38:44 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think the namespace concerns are a bit of a bike shed, to be honest. It&#39;s fine being the name of the library, and it impacts precisely one line of code per source file, in a place most people choose to hide with regions.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
How else would people not get offended by stuff like this:
</p></div></div><p>

That is not representative of real code. By default, you have <tt>using System.Data;</tt> in your source files, so even if you&#39;re a complete idiot and don&#39;t add <tt>using System.Data.SqlClient;</tt> since you&#39;re using SQL, you&#39;d only have to type SqlClient.SqlParameter.</p><p>Or just type SqlParameter and right click it and choose &quot;Resolve using System.Data.SqlClient&quot; to have VS do it for you.</p><p>~~~</p><p><a href="http://allegrosharp.lessthanthree.vg/index.php?/archives/6-Allegro-0.81-Released.html">Version 0.81</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Tue, 26 Aug 2008 21:13:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I know. It&#39;s just that long identifier names don&#39;t bother me anymore now I have intellisense and all that. What I&#39;m trying to get at is that Visual Studio makes the length of identifier names pretty irrelevant, so people shouldn&#39;t be complaining.<br />In real life, I put &quot;using System.Data.SqlClient&quot; at the top and just type &quot;SqlP&quot;, then Enter (or open bracket, or whatever comes next).<br />What is more irritating is identifier names that share a lot of letters, like &quot;ConfigurationSettings&quot;, &quot;ConfigurationManager&quot;, etc. etc. - when I want &quot;ConfigurationManager&quot;, I need to either type &quot;ConfigurationM&quot; plus hit Enter, or type &quot;Con&quot; and then scroll down the list to find what I want.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Fri, 29 Aug 2008 00:47:16 +0000</pubDate>
	</item>
</rss>
