tag:blogger.com,1999:blog-76736065409418003762024-03-05T16:24:10.925+01:00A Rain Songit's just a programming blog.Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-7673606540941800376.post-73236824824791718082010-03-18T11:01:00.001+01:002010-03-18T11:02:28.710+01:00Took me a while<span style="font-family: "Trebuchet MS", sans-serif;">In order to keep up the good tradition of this blog, famous for its quality content, I had to meditate for months.</span><br />
<br />
<span style="font-family: Trebuchet MS;">Work, as usual, has not been forgiving with my spare time. Many things also happen outside the event horizon of a computer screen, and it eventually becomes increasingly hard to clear up thoughts and write down stuff.</span><br />
<br />
<span style="font-family: Trebuchet MS;">Blabbering aside, I've managed to finally write a working prototype of the famous Entity System. Not only that, though. The Rainweaver Framework (guess I'll stick to this name for the time being) has been given lots of love as well, and despite my constant refactoring, I can say I'm 80% satisfied with the result. I made a <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=563744">post</a> at <a href="http://www.gamedev.net/">Gamedev.net</a> but stirred no interest. Ah well. For fun and not for fame, right?</span><br />
<br />
<span style="font-family: Trebuchet MS;">This Framework of mine is a hobby project. I'm giving myself the chance to learn new technologies such as WPF as well. It has a steep learning curve. It's true. If you want to learn WPF, you gotta have the time to. Time to sit down, open two Visual Studio instances, download <a href="http://familyshow.codeplex.com/">Family.Show</a> and get dissecting. Time to wade through thousands of tutorials looking for best practices with a dim light.</span><br />
<br />
<span style="font-family: Trebuchet MS;">With this spirit, I decided to take up a WPF project related to the Entity System. It's called Prototyper. You can still see in the changelogs that the project was named ArchProto, then ProtoArch, it turned WPF from WinForms (just like growing adult), and got its final name.</span><br />
<br />
<span style="font-family: Trebuchet MS;">Project conception aside, I'll explain briefly what it's supposed to do.</span><br />
<br />
<span style="font-family: Trebuchet MS;">Every Entity System has a Schema and a Runtime. The first says how things work, the second makes them happen. Between them, there are Runtime Globals and Scripts. Runtime Globals are implementation-specific methods or properties exposed by the runtime to the schema. Scripts can be modified at runtime (atomically, i.e. no undefined state across modifications) and are generally kept in some kind of storage (files, db).</span><br />
<br />
<span style="font-family: Trebuchet MS;">Prototyper is being written to allow designers to define components, messages and prototypes in a visual fashion; associate a Runtime Globals type for scripts; associate scripts from a typed script storage object to message handlers; compile a schema to CLR Objects.</span><br />
<br />
<span style="font-family: Trebuchet MS;">The Entity System was a challenge and still is, as it's not 100% done. But a bigger challenge lies ahead with this Prototyper thing.</span><br />
<br />
<span style="font-family: Trebuchet MS;">If you feel brave, head over at <a href="http://rainweaver.codeplex.com/">http://rainweaver.codeplex.com/</a> and download the latest code drop, play with it, examine the code.</span><br />
<br />
<span style="font-family: Trebuchet MS;">Thanks for reading.</span><br />
<br />
<span style="font-family: Trebuchet MS;">Bye-bye!</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-31479752295285146052009-09-17T10:01:00.004+02:002009-09-18T11:31:56.093+02:00"The Moon Won't Shine"<span style="font-family:trebuchet ms;">"...It's broken down" to use Eric Clapton's words.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">Lua. Enemy of mine. I love the language, don't get me wrong. But I spent oh so many nights on my Lua VM that now I burst into tears every time I glance at the project file in Windows Explorer.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">First and foremost, while I believe Lua source code is highly optimized C, it kinda looks obfuscated. It gets quite hard to understand what's going on, so hard that I haven't managed to understand how function calls work. And this makes me very sad, angry, people hate me, and I hate the world. There's a lot of pointer mumbo-jumbo to maximize speed. </span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">Calls are pushed on a "call stack". They seem to contain stack top and stack base information. However, a lua thread has a notion of stack top too. You'd think the current call info on the call stack has all the info you need in order to push values at the right index; but no, there are about two stack tops, and the macro hell makes everything even more difficult to understand.</span><br /><span style="font-family:Trebuchet MS;">This is more a practical problem, rather than an issue with the language itself.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">Something more interesting would be discussing about the possibility of porting Lua on the CLI. I bet as soon as .NET 4.0 will be out, there will be a plethora of language implementations on the <a href="http://www.google.it/search?hl=it&q=dynamic+language+runtime&meta=">DLR</a>. </span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">Anyway. Lua is a strange beast, strange in the sense that Lua values just can't map to POC objects. This means that you have to implement proxy objects that wrap the same semantics of a Lua value. Not good. Quite bothersome. Prone to run slow - slower than the original C implementation, and especially so in a VM that would decode bytecode on the fly. I have faith in IDynamicObject of the 4.0 FCL.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">Practical doubt: what if the Compact Framework got runtime code generation as well? All my efforts in creating a Lua VM would become useless. And right now, seeing as I can't <em>unravel the mysteries</em> of the Lua implementation, I'm not even enjoying the effort in making one. Yes, I have a better picture of how Lua works, but no, I don't have a full, clear picture. </span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">Annoying. </span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">As usual, if you don't know what you're going to code in advance, things are bound to become a mess. I thought I nailed function calls, as the output of a few test scripts would yield exactly the same results of the original Lua VM - however, things got crazy when I had to implement protected calls and coroutines. And vararg parameters. Not enough analysis, and that's the result.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">For the record, it is just wrong in my opinion to use <a href="http://en.wikipedia.org/wiki/Virtual_Execution_System">VES</a> exceptions (oh, fancy details) to change the program flow of a Lua script (which in turn calls plain old CLI methods). The implementations I've seen just do that, seeing as the original C code uses <a href="http://en.wikipedia.org/wiki/Setjmp.h">setjmp</a>, longjmp facilities, or C++ exceptions if #DEFINEd to do so; and it becomes hard to model Lua errors in a different way. However, I think it is possible to avoid using Exceptions (costly) with a not-so-nice set of flags that should be checked in strategic places. This might produce code that is not as readable, but it's bound to perform better. In this case, I think it might be worth to sacrifice readability - yes, purists will cry and all.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">I've also discovered F#. I have too many things to do, and since work has highest priority (go live closer and closer), chances of getting any of my personal projects done gets slimmer and slimmer with time.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;"><a href="http://www.google.it/search?hl=it&safe=off&q=F%23&meta=lr%3Dlang_en">F#</a> is very cool. But damn it, functional programming seems to require some kind of CS education, which I do not have.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">Another challenge. Yeah. </span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:Trebuchet MS;">That's about it, thanks for reading.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:trebuchet ms;">Nerd joke I came up with while talking with a friend some time ago:</span><br /><span style="font-family:trebuchet ms;">"You don't have to kill me; just set me to null, the garbage collector will take care of the rest". I thought it was fun. :P</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com1tag:blogger.com,1999:blog-7673606540941800376.post-70873789334034013602009-07-22T10:17:00.004+02:002009-09-18T11:32:31.506+02:00Of Virtual Machines<span style="font-family:trebuchet ms;">Hello my dear readers, I have been away too long.<br /><br />I wanted to give a little visibility to my latest efforts: a Lua Virtual Machine. Yes, you got it right, a <span style="FONT-STYLE: italic">Lua Virtual Machine</span>! Bytecode in, execution out! This also means that as soon as the bytecode format changes (and it can happen anytime at discretion of the creators of Lua) everything breaks.<br /><br />Needless to say its based on the works of Fabio Mascarenhas (<a href="http://www.lua.inf.puc-rio.br/post/7">Lua2IL</a>) and Kein-Hong Man (<a href="http://www.google.it/url?sa=t&source=web&ct=res&cd=1&url=http%3A%2F%2Fluaforge.net%2Fdocman%2Fview.php%2F83%2F98%2FANoFrillsIntroToLua51VMInstructions.pdf&ei=C8xmSq7zNImj_AaD2rVk&usg=AFQjCNE1ViSmj2EBTbUI5OZhYCgMZQ6u1Q&sig2=ICN2ZbCuYrRaq5udnUOAZw">A No-Frills introduction to Lua 5.1 VM Instructions</a>).<br /><br />I really love Lua, I think it's a wonderful language. Not perfect, but it features metamethods and if it's something with "meta-" built-in, it must be cool (once they were called tag methods, as you can glimpse from the source). Jokes aside, metamethods seem to offer this nice extensibility and hooks to language events (indexing, new index creation, various operators, to name a few) that make every change a little microcosm of new features.<br /><br />Back on topic, this Lua VM is meant to run on non-DLR-ready frameworks, such as the .NET Compact Framework. You might argue that System.Reflection.Emit comes before the DLR, but the latter is the future (had too much of IL emit at once in the past) and I like to look ahead.<br /><br />I know there have been many wise guys at work on Lua implementations on the CLR, but I took up this challenge mainly for fun and <span style="FONT-STYLE: italic">not</span> for fame. If it turns out to be complete enough for regular usage, even better. There's a lot to learn from the learning itself.<br /><br />You can find the work-in-progress source at the <a href="http://rainweaver.codeplex.com/">Rainweaver Framework Codeplex page</a>. I make a lot of changes all the time, but the core library should be stable enough to use.<br /><br />I tried to use <a href="http://irony.codeplex.com/">Irony</a> to create a Lua AST generator but it looks I'm not smart enough, and I had to fall back to other solutions for the moment. It was cool to find out about monadic parser combinators (<a href="http://blogs.msdn.com/lukeh/archive/2007/08/19/monadic-parser-combinators-using-c-3-0.aspx">LukeH's weblog</a> and <a href="http://lorgonblog.spaces.live.com/blog/cns%21701679AD17B6D310%21123.entry">Brian's weblog</a>) - read them up because they will make you super smart and taint with functional sexyness your imperative ego. As soon as I manage to play with those concepts a bit, I'll be sure to post more.<br /><br />Waiting for feedback as usual,<br />Yours truly,<br />Rob<br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com2tag:blogger.com,1999:blog-7673606540941800376.post-13966706309852373042009-05-12T12:31:00.015+02:002009-05-12T16:44:49.557+02:00Parallelism, Scalability, Persistence - Linkage<div align="left"><span style="font-family:trebuchet ms;">Thanks to a bad neck, I finally have some free time. Why not spam the blog, I thought (and why not try Windows 7 on a VM, zomg it's amazing).<br /><br />While searching for cool programming stuff, I found some interesting links I <em>have</em> to share with you. Just two for the moment! Don't be greedy.<br /></span><a href="http://www.gamasutra.com/view/feature/3861/performance_scaling_with_cores_.php"><span style="font-family:trebuchet ms;">Smoke</span></a><span style="font-family:trebuchet ms;"> framework, for starters. The good thing is that what I had in mind is scarily similar to what Intel done, and this makes me a happy gummybear.<br /></span><a href="http://code.google.com/p/retlang/"><span style="font-family:trebuchet ms;">Retlang</span></a><span style="font-family:trebuchet ms;">, by Mike Rettig, which seems to be the answer to my concerns about thread-safe message passing.<br />(And "</span><a href="http://refractalize.blogspot.com/2009/02/stackless-c-trampolining-continuations.html"><span style="font-family:trebuchet ms;">Stackless C#</span></a><span style="font-family:trebuchet ms;">", by Tim Mcfarlane, which has led me to try and learn how </span><a href="http://irony.codeplex.com/"><span style="font-family:trebuchet ms;">Irony</span></a><span style="font-family:trebuchet ms;"> works in order to recreate a Lua CLR compiler that supports coroutines without fugly hacks - but that better be another story for another post).<br /><br />While those two links lead to resources that can only inspire the mere mortals, they also made me remove my Google Code page until I completely embrace their paradigms. That's to say I wasn't exactly happy with what I'd done and I wanted a fresh start. I think by now you noticed my big problem with finishing my own projects.<br /><br />Now, you might be wondering, what's this to do with the post subject? Very well. Good question.<br /><br />Smoke shows an important concept: that is to share the workload among <em>n</em> threads. However, as usual, it is easier said than done. Sharing the workload requires a careful design, so that nothing is left to compromise and everything falls nicely in place when all computations are done.<br /><br />However, one of the biggest challenges is to actually find good heuristics so that work is spread evenly across threads. You don't want to waste time counting those threaded sheeps jump past the fence. The other is to allow an immediate flow from producers to consumers.<br /><br />I have a good example of the mental maze you find yourself in once you try to make sense of the above; your rendering thread is told to render something you haven't yet loaded. An animated mesh, for instance, along with its textures and animations and whatnots.<br />If the rendering waited idly for that asset to be loaded, we'd be back to square one. It becomes difficult to remove dependencies from systems that'd naturally rely on them. What would the pragmatic developer do? Perhaps identify each resource with an ID, and check against that to verify if the asset has been loaded. However, spamming IDs all over the place lacks of elegance, and the initial problem leads to another sub-problem; how to organize data.<br /><br />There are two kinds of data I can see right now; in-memory data, and assets to be eventually loaded in some memory (they're initially stored on disk, any type of assets, from textures to <em>ai-behaviour-definition</em> files, the latter being just made up).<br /><br />Both have a stage in which they are not utilizable, as they're to be either created or loaded. And even when you've loaded data, there's another possible step, that is going back to storage. Persistence.<br /><br />All of this needs a common interface: find necessary data, load it, access it, save it again. Rinse and repeat. Add two tablespoons of sugar. Did I mention data has to be immutable? My head is hurting.<br /><br />Oh, damn. Lunch time. I was about to make a nice diagram. I'll continue later. >:)</span><br /><br /><span style="font-family:trebuchet ms;">Edit: nice diagram (click to enlarge):</span></div><span style="font-family:Trebuchet MS;"></span><span style="font-family:trebuchet ms;"><div align="center"><br /></span><span style="font-family:trebuchet ms;">A Rain Song: now with nice pictures!</span></div><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaAdjMXk9On1NwWZ9fztCJA986MEokx0FmEPj5mPsU_mo2JsL_7w-HFs7_5dECCgGQ-h20abC7hBJbUPAvLlClU5LerClf6flCXZ_S2L7Uxs9e7vQjdZBnZcgOo6nNAdDuElodD7Bx62Ci/s1600-h/Distributed+System.png"><img style="TEXT-ALIGN: center; MARGIN: 0px auto 10px; WIDTH: 263px; DISPLAY: block; HEIGHT: 400px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5334948218879180306" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaAdjMXk9On1NwWZ9fztCJA986MEokx0FmEPj5mPsU_mo2JsL_7w-HFs7_5dECCgGQ-h20abC7hBJbUPAvLlClU5LerClf6flCXZ_S2L7Uxs9e7vQjdZBnZcgOo6nNAdDuElodD7Bx62Ci/s400/Distributed+System.png" /></a><br /><span style="font-family:trebuchet ms;">Why two servers with the same processing units? Our ultimate goal is to plug one more server and see performance double instantly. More or less. The same goes for three servers, and so on.</span><br /><span style="font-family:Trebuchet MS;"></span><br /><span style="font-family:trebuchet ms;">More on this later, car's getting brake pads changed and I need to take it back.</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com4tag:blogger.com,1999:blog-7673606540941800376.post-21871391047315903182009-04-19T15:46:00.004+02:002009-04-19T16:05:36.631+02:00Parallelism, Scalability, Persistence<span style="font-family:trebuchet ms;">In order to not let the blog wither, I think I'll post some notes I took during my stay in Milan. </span><span style="font-family:trebuchet ms;">I won't bother you with the details of these past months, as I've been beyond busy... perhaps <em>super busy</em>. I've been working on a data relay system for an international company (first big project, yay!), and I don't feel like enumerating the crapload of snags I hit along the way. I've been using WCF, for the curious. Nice technology, if confusing at first like most MS frameworks.</span><br /><span style="font-family:Trebuchet MS;">Anyway, there we go. I'd love to see some feedback, if any.</span><br /><br />--<br /><br /><span style="font-family:trebuchet ms;">Parallelism means performing many operations with none waiting on another.</span><br /><span style="font-family:trebuchet ms;"><br />Scalability means opening up parallelism over separated but cooperating processing units.<br /><br />Persistence means the capability of a state to be saved and restored in its entirety<br />at any point in time.</span><br /></span><span style="font-family:trebuchet ms;"><br />In order to achieve parallelism, data must be immutable, there must be as little data contention as possible, and no locking, as a corollary of the previous statement. In order to achieve scalability, operations must be serializable, and so their results, so that they can be shared across different parallel processing units. The cost of sending data across a communication channel must be less than the sum of the processing costs on a processing unit; this implies fast communications and smart work-stealing heuristics.<br /><br />In order to achieve persistence, the selected storage must be able to create a perfect copy of the data being sent to it, save it in a lossless way and retrieve it later; this sequence must be able to happen at any point in time to prevent sudden data loss.<br /><br />--<br /><br />The data upon which operations are performed and the operation themselves must be local, that is they must be in the same processing unit. Whenever a state* happens to be partially shared across two different processing units, the one with less workload will receive a full copy of the necessary data and carry out the involved operations. This can be seen as an implementation of the concept of "ghosting".<br /><br /><span style="font-size:85%;">* A state is a collection of operations to be performed towards a specific result, along<br />with their determinant data.</span><br /><br />Data can also be proactively shared with processing units that don't yet need it. Sharing in this case means transfering a clone of the data until the data is either not needed anymore or completely trusted to another processing unit. Proactive sharing might happen when data gets close to the processing unit boundaries, which can be both abstract or physical (different machines linked by a connection). Data should be sent only when it changes.<br /></span><br /><span style="font-family:trebuchet ms;">I hope I'll be able to post more.<br /></span><br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-82217912538972523362009-03-04T16:27:00.003+01:002009-03-04T16:33:36.860+01:00Oooh.<span style="font-family:trebuchet ms;">My best virtual croatian friend Joe Basic and I have opened a Google Code page.<br /><br /><a href="http://code.google.com/p/rainweaver/">http://code.google.com/p/rainweaver/</a><br /><br />The Rainweaver Framework (it's a codename, whatever) is a set of libraries for game developers. You can read about our evil plans on the first page. There's something you can download, as well. Let us know what you think, of course!<br /><br />If you know C# and you're the reliable type, consider joining us. We're busy with work, university, and all the rest, so it's a long term project.<br /><br />Thanks for reading.<br /><br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-37849885165637740312009-01-19T23:54:00.009+01:002009-01-20T09:32:54.003+01:00Work, work, work<span style="font-family:trebuchet ms;">I know you've been missing me. I've been missing you too - blog of mine.<br /><br />Anyway, it's been a super busy period with super big things to get done. For instance, I wrote a Dynamics NAV text fob parser in order to create a versioning documentation against two databases. It's been both a pain and a pleasure. I had a few "eureka!" moments worth all the stress I went through in order to deliver the tool in a timely manner. I also managed to understand parsing / compiler theory a bit more. You never stop learning.<br /><br />I also took the opportunity to brush up my design patterns knowledge. I've been messing with <a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a> and today I've been reading up about <a href="http://blogs.infragistics.com/blogs/tsnyder/archive/2007/10/17/mvc-or-mvp-pattern-whats-the-difference.aspx">MVP</a> - the former being model-view-controller and the latter model-view-presenter. Curious? I'll post a pretty scheme I made tomorrow. It's pretty, I swear. Edit: and here it is:<br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJNDIZc2Vsn68mHg_K_8L_rsYMZxG3BbtAPJXlvHDJ-VbNqOazGU5bouWw6KhyinaH4VkbUi3VmTt2AFatBPdTljmuU_bK9Vsus4KYO6iAUFmphq0b5qkc8cdjb2uaifHcT91Xh8DzYhZ/s1600-h/MVP+Diagram.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 225px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJNDIZc2Vsn68mHg_K_8L_rsYMZxG3BbtAPJXlvHDJ-VbNqOazGU5bouWw6KhyinaH4VkbUi3VmTt2AFatBPdTljmuU_bK9Vsus4KYO6iAUFmphq0b5qkc8cdjb2uaifHcT91Xh8DzYhZ/s320/MVP+Diagram.png" alt="" id="BLOGGER_PHOTO_ID_5293290876192907922" border="0" /></a><span style="font-family:trebuchet ms;"><br />I learned some new tricks in these months, and I got to the point where you have to actually sit down and try to make everything snap in place.<br /><br /></span><ul><li><span style="font-family:trebuchet ms;">MVP? World editor. Absolutely.</span></li><li><span style="font-family:trebuchet ms;">Object persistence? Game server. Finally I realized the true form of the Entity System (more on this later).</span></li><li><span style="font-family:trebuchet ms;">System.Threading? Do more with less. Locality of data - as few shared states as possible, lockless when you can, otherwise don't bother.<br /></span></li><li><span style="font-family:trebuchet ms;">System.AddIn? Useless, use the MEF and do yourself a favour; however, you learned that proxies and abstractions are a good thing to decouple the contract from the implementation - and if you're smart (like the System.AddIn guys) you have a version tolerant framework without even breaking a sweat. And here comes a platform-independent engine API...!</span></li></ul><span style="font-family:trebuchet ms;"><br />Thanks for reading.<br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-48999211221535575072008-10-30T17:09:00.005+01:002008-10-30T17:24:03.685+01:00System.AddIn<span style="font-family:trebuchet ms;">I wish I had more time to write more often, but I've been quite busy lately. I have however something to share, and it's not much since it's publicly available, but it's still something worth having a look for those who, like me, didn't know about it until yesterday.<br /><br />I'm talking about the System.AddIn namespace (the 3.5 version, it's an assembly you must reference).<br /><br />While researching for plug-in frameworks, I've found that our beloved framework allows you to create extensible applications with very little effort. You don't have to code your own assembly attributes, your own interfaces, your own versioning gimmicks, and more importantly your own external assembly loading routines (which are most likely to revolve around the black magic-y world of AppDomains). This doesn't mean, however, that you don't have to design the way these addins interface with your host application - that's another story.<br /><br />Two CLR Inside Out columns (<a href="http://msdn.microsoft.com/en-gb/magazine/cc163476.aspx">this</a>, and <a href="http://msdn.microsoft.com/en-gb/magazine/cc163460.aspx">this</a> one) introduce the System.AddIn pipeline. I wish I'd found this stuff sooner.<br /><br />Two things I do not like: The first is the way the pipeline is layed out in terms of directory hierarchy; it's surely clean enough, but I don't like it when someone else decides where I should put my assemblies (.NET has a local assembly copy paradigm if you aren't going the GAC route), so, in this regard, it could be improved and allow for a little bit of customization. The second, you need to create different projects for the pipeline segments and I for one already have to deal with enough projects already. However, the shining beauty of this umpteenth incredibly useful feature of .NET quickly dissipates any shadow of doubt. Man, I can't believe I just wrote that.<br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com2tag:blogger.com,1999:blog-7673606540941800376.post-75027891543374267742008-10-20T10:00:00.004+02:002008-10-20T14:08:19.123+02:00Of Shame<span style="font-family:trebuchet ms;">I'd like to crystallize in a blog post the <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=511790&whichpage=1&#3334524">wisdom</a> of an australian "developer" named "openglaussie", as seen over at Gamedev.net.</span><br /><br /><blockquote>I guess nothing good will come from spaghetti eaters, mafia bosses and short , tan people, who bullshit others as a way of living, italians are the worst catergory in everything.<br /><br />[...]<br /><br />I don't think i have a wrong attitude, is just my way to put things on, i don't sugar coat, no way, italians aren't good at making games, i am not talking about knowledge, since we all know that italians universities are among the best ( only in litterature ), [...] technologically italy is many steps behind, no entertainment culture finalized at videogames [...], they don't use their cars anymore to spare oil</blockquote><br /><br /><span style="font-family:trebuchet ms;">Please note how he also edited his posts later on. I'm not sure I feel like commenting on this right now.<br /><br />Edit: well, while I'm waiting for the report I'm working on to finish crunching numbers, I guess I can spend a few minutes writing down how I feel about this.<br />That people of other countries have a low consideration for italians is nothing new. It's a sad reality, not shared across everyone of course, but it does happen. However, we're talking about game development here and I'll keep it at that.<br />I think Italy never ever had the possibility to grow in the gaming industry. We simply don't have a business for that. Many bright minds fly away from this country towards more fertile fields, where they can actually work and make a good living out of their talent. The idea of a game dev convention is both a good and an irrelevant news. A good news, seeing as there's always the need to spark a start, but irrelevant, since I really doubt it'll help investors create business. It's all about earning a living eventually (for big companies even more so). We had a few good productions in a distant past (Milestone with Screamer and a few other racing games, or Lightshock with Pray for Death which was a very nice fighting game at the time), but then it all stopped.<br /><br />I really think it's hard to start competing with multi-millionaire companies ex nihilo. I also think we wouldn't be able to create a Cave Story clone (which is an amazing game, a one man effort worth gold) even if we really wanted. Why is it so? I don't know, all I know is that they can convention all they want, but that's not gonna help unless someone starts changing the business. And this is something not happening overnight.<br /><br />I for one have always been interested and secretly in love with game programming. I never found anyone to share this passion of mine with where I live. The italian game dev site reminds me of the desert, with a few, lone explorers along its path.<br /><br />But then again, I can't complain. I for one am not doing much to change this. I cannot.<br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com4tag:blogger.com,1999:blog-7673606540941800376.post-81797766925032806602008-10-02T10:13:00.004+02:002008-10-02T10:32:39.482+02:00Designing a Magic System<span style="font-family:trebuchet ms;">I just found out this amazing series thanks to gamedev.net dailies.</span><br /><br /><a style="font-family: trebuchet ms;" href="http://roguelikedeveloper.blogspot.com/2008/05/unangband-magic-system-part-one.html">Designing a Magic System by Andrew Doull</a><br /><br /><span style="font-family:trebuchet ms;">(Plus </span><a style="font-family: trebuchet ms;" href="http://projectperko.blogspot.com/2008/07/landscapes-and-level-designs-boring.html">a fine article from Craig Perko</a><span style="font-family:trebuchet ms;"> - found in the series above)</span><br /><br /><span style="font-family:trebuchet ms;">Seeing how magic and its systems have gotten a formal definition over time is both entertaining and enlightening. I used to design a pen and paper RPG rules for fun when I was in my teens. The act of balancing, adding to or removing from a specific rule set is not as straightforward as it might seem. Actually, while I'm all for coming up with cool ideas about magic and so on, I must admit players (including me) are used to defined schemes. So, I guess, we're not just balancing fireballs versus shields, but also marketability versus innovation.<br /><br />And makes me wonder if we will eventually get used to "common" magic...</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-53749721872052364992008-09-29T17:02:00.005+02:002008-10-06T10:05:28.961+02:00A change of... hosting<span style="font-family:trebuchet ms;">About to move to my newly bought domain... redirect your bookmarks (as if you bookmarked this site, ha!) ;P<br /><br />Edit: as I mentioned in the comments, the new site is not ready and I'm not sure how long it'll take... :]<br /><br />Edit 2: I guess I shouldn't have mentioned this "change" seeing as I'm finding blogspot so much more comfortable. It has everything I need at the moment. I'll post again should I ever actually change the hosting of my blog. Hurrah for pointless posts! :D<br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com2tag:blogger.com,1999:blog-7673606540941800376.post-80510415470526343022008-09-23T12:02:00.004+02:002008-09-23T12:04:37.065+02:00A wicker soldier<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://darkmana.com/WebAPP/images/uploads/design_test.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px;" src="http://darkmana.com/WebAPP/images/uploads/design_test.jpg" alt="" border="0" /></a><span style="font-family:trebuchet ms;">Orel keeps on amazing us with new modifications. I can't wait to see this guy hacking and slashing. I wish I could model and texture like this...!</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-72148757720489419352008-09-16T14:38:00.008+02:002008-09-22T15:41:33.376+02:00Parallel Profiling<span style="font-size:100%;"><span style="font-family:courier new;"><span style="font-family:trebuchet ms;">Did some profiling during my lunch break, since I was curious to see how a one-day implementation of a parallel library would perform against a super rival like Microsoft's TPL. This simple console app has been run in release mode, so no debug stuff lying around. My work laptop's a Fujitsu-Siemens Amilo Pro, Intel Core Duo 1.86 GHz, 1.75 GB RAM.</span><br /><br /><span style="font-size:85%;">Rainweaver.Parallel Tester</span></span><span style="font-size:85%;"><br /></span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" >100000 iterations Bessel function.</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" >Comparison mode.</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" >Parallel (RNW): 21076 msecs elapsed.</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" >Parallel (TPL): 15877 msecs elapsed.</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" >Sequential: 44302 msecs elapsed.</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" >Ratio: Parallel RNW is <span style="font-weight: bold;">2,1020117669387</span> times faster.</span><span style="font-size:85%;"><br /></span><span style=";font-family:courier new;font-size:85%;" >Ratio: Parallel TPL is <span style="font-weight: bold;">2,79032562826731</span> times faster.</span><br /></span><br /><span style="font-family:trebuchet ms;">The results are pretty self explanatory, considering noise and everything. While this makes me a bit sad, I'm still happy to see that the difference is not that humiliating - at least, that's how I see it, and it's granted it could be oh so much better. All in all, my implementation is not optimized nor has been given that much forethought, so I can consider this a small step towards Nirvana and a great first-hand experience in parallel coding, which is invaluable.<br /><br />I'd like to congratulate the TPL team on an awesome job. Can't wait for the release of this great library. </span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com4tag:blogger.com,1999:blog-7673606540941800376.post-75928735386619629232008-09-15T13:33:00.003+02:002008-09-15T13:47:39.747+02:00Coming next...<span style="font-family:trebuchet ms;">I've been dealing with a few interesting issues and finalized a good part of my base libraries. The time has come for me to start working on Darkmana. I've been messing around with my codebase to find out I was misusing a bunch of objects, resulting in a few annoying exceptions while using TV3D. Hopefully the problem has been understood; the lessons is, when dealing with multithreading, don't assume to follow the same sequential logic you'd use normally. This might be a given, but it's usually not. One enters in this focused state of mind in which everything clicks perfectly, just to find out an important thing has been left out at the very base of the structure.<br /><br />Enough intro. In the next days, I'll commit some time to work on these subjects:<br /></span><ul style="font-family: trebuchet ms;"><li>Parallel library: why, yes, even if there's one available for download over at Microsoft, I needed to roll my own. I can't rely on their release date (which is unknown at the moment) and on code in beta stage (adding to my own). Luckily a superb Channel 9 video with a throrugh explanation helped me disentangle a few doubts (<a href="http://channel9.msdn.com/shows/Going+Deep/Joe-Duffy-Huseyin-Yildiz-Daan-Leijen-Stephen-Toub-Parallel-Extensions-Inside-the-Task-Parallel/?Page=2">link</a> for the interested).</li><li>Using the above library to create a proper loading screen. Loading screens are cool, but only if I'm the one making them, otherwise they're annoying as hell. I'd love to let the player move the main character around until the world fades in around him upon load completion. Wouldn't it be cool? I think so.</li><li>Programmatic animations and AI. This is going to become a big matter, there are so many things I need to finalize first.</li><li>User interface: that will be one of my last concerns. I'd rather have a simple guy running around and jumping than a working user interface at the moment. I have learned a lot from my past experiments with user interfaces, and this time I'm sure it won't be as painful as the first time (I'm not even considering the actual first time, since it was a mess :P).</li></ul><span style="font-family:trebuchet ms;">The people who subscribed in our forums for the beta version will receive the link to download the various tests I'll be uploading (when there's something juicy for them to test of course).</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com2tag:blogger.com,1999:blog-7673606540941800376.post-74948402670863144422008-09-06T11:49:00.003+02:002008-09-07T12:45:03.386+02:00Of Cyclical Rewriting<span style="font-family:trebuchet ms;">Sometimes I wonder why I even bother. It all started because there was a bug in the NTL compiler apparently not recognizing handler tokens. I could have sat down and probably fixed it in a bunch of hours. But no. I had to put the whole NTL language idea aside (as I said to Zak, it was mainly a "programming masturbation", but a cool one ;( ) and fall back to XML.<br /><br />Well, I think it's eventually a good choice since XML is widespread, can be read by almost anything, espresso machines included, and is an accepted standard.<br /><br />Luckily I didn't have to rewrite all the code that actually creates CLR assemblies out of the entity system definitions you spam in, or it would have been serious pain. Much pain.<br /><br />Anyway. While I was at it, I also removed a feature which I didn't like. When the entities were processed and turned to IL, they were added a field named Prototype, which contained an EntityPrototype object basically describing the objects referenced by the entity; this means components, handlers and handled messages. All of this just to speed up entity creation at runtime.<br /><br />However, I had forgotten once again about Attributes, and why they're in the CLR. So, armed with loads of patience but handicapped by lack of proper sleep, I set to remove this prototype stuff and go on with attributes. Now I'm in the middle of realizing what's the next step.<br /><br />The most annoying part is that I am storing Types via their TypeHandles (actually their RuntimeTypeHandle.Values ToInt32()ed); this basically means creating a type storage via indices; this so reminds me of the database stuff I have going on at work - though, when I started to ramble about entity systems, I kind of expected it.<br /><br />I had a nice demo going on but it's no more. Raaargh. Here's hoping it won't be long until I have something actually doing its job again.<br /><br />I'm out.<br /><br />07 Sept. Edit: Well, it wasn't as bad as I initially thought. I managed to get things up and running again, now including some things like proper component installation and uninstallation. Since my programming life is full of happy gummybears again, I can commit some time to the actual entity system editor. I'll keep you posted.<br /><br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-25192763271532297492008-09-02T10:30:00.004+02:002008-09-02T12:21:07.673+02:00Entity System and Lua<span style="font-family:trebuchet ms;">Lately the Entity System code has been getting more and more complex, to the point that I had to read what I was writing very carefully (and sometimes reading aloud too... go figure).<br />I have some news about it... about time!<br /><br />The good news is that it is almost complete! It's a joyful day for me. Object pooling, message dispatching... stuff that works! I still have to finish adding and removing components dynamically (right now we just get the components we defined per entity in an NTL file).<br /><br />The bad news is that Lua hates me, and it's giving me all kind of exceptions. I think I know what's going on and the relative fix, but if said fix did not work, I'd be in serious troubles. Basically, Lua needs to know what types you're working with, otherwise it would just sit and cry pitifully, making you feel guilty for such carelessness. And it makes sense, of course. LuaInterface is a mysterious world, I still have to figure out thoroughly how the .NET bridging works - luckily the source code is freely available.<br /><br />At some point of yesterday evening, while bashing my head on the desk for the umpteenth exception, I even felt like writing a Lua compiler / interpreter from scratch in order to get rid of problems when interfacing with the CLR. Sadly, it's a task beyond my available time and most likely experience as well. It would be a great challenge, though.<br /><br />I still haven't performed any performance tests, but I know in advance I will have to make sure a) the object pool isn't raping the heap b) entity creation is quick and painless, and so is its disposal.<br /><br />I know it's all a bit vague, but I'll be sure to release the NTL environment as soon as I have something worth attention.<br /><br />Have a good and productive .NET day! (...rolololflol.)<br /><br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-26496897932372128842008-08-23T12:03:00.000+02:002008-08-23T12:16:10.436+02:00Shameless plug here<span style="font-family: trebuchet ms;">Aloha to everyone reading this blog (hi granma!), I'm now back from holidays and ready for a quick recap about my latest endeavours (whoa).<br /><br />As if the Entity System weren't enough to keep me entertained and make my fellow team mates doubt about my commitment, I've restarted the long-forgotten UI project. This time it's been redesigned the good way. The good thing of the stuff I'm writing lately is that is it 3d engine-independant, I'm just providing managed Truevision3D implementations since this is what we're using at the moment.<br /><br />The UI includes / will include the following features:<br /></span><ul style="font-family: trebuchet ms;"><li>Full scripting support</li><li>Multiple views (UI on meshes and on screen, for instance)</li><li>Markup compiler (a la WoW interface)</li><li>Event driven design (in combo with the Input Manager contained in the Rainweaver.Core library)</li><li>Layout Customization, allowing your artists to do their job and snap pieces together</li></ul><span style="font-family: trebuchet ms;">I meant to add Add-on support by default but it's very implementation specific and I'm not sure everyone would use it. It'll be very easy to plug stuff into the interface, though.<br /><br />I decided to restart the interface project since it's the best environment where to test my libraries (engine, input, scripting, console, data structures etc...).</span><br /><br /><span style="font-family: trebuchet ms;">Stay tuned-zorz.</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-70853144588587543802008-08-14T13:36:00.000+02:002008-08-23T12:17:12.736+02:00Away Notice<span style="font-family:trebuchet ms;">To everybody who sent me an email in these last days: I'm on holiday, I'll be sure to reply as soon as I come back.</span><br /><br />Wien (Vienna) and Budapest are awesome :)<br /><br />PS: If you plan on going abroad with your trusty laptop, be sure to bring a power adapter.<br /><br />PPS: I'm away for another week and I won't have an internet connection... take good care everyone and see you soon!Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-65571561630483324802008-08-06T22:04:00.000+02:002008-08-06T22:11:59.781+02:00Getting back on track...<span style="font-family: trebuchet ms;">Well, these have been very busy days. I managed to rewrite a good part of the Entity System, which now supports object pooling.<br /><br />I have to brush up my Lua knowledge before implementing message handlers properly.<br /><br />Here's hoping it won't be too long before I post again with more substantial news.<br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-17274259087026334982008-07-30T10:20:00.000+02:002008-07-30T15:03:36.676+02:00Of Disappointment<span style="font-family:trebuchet ms;">I came to the conclusion that I really wanted to implement object pooling for the Entity System, but I think I've hit two or three (or many more) snags along the way.<br /><br />The more I try to add this feature to the ES, the more I realize I have to rewrite a good part of the compiler too (make it 80%). I have based the design of the ES upon different assumptions, and now stitching new stuff is proving to be very difficult.<br /><br />Moreover, I'm not sure all of this will be eventually worth the effort.<br /><br />So, as much as I'd love to release an ES with an object pool, I don't seem able to pull it off with the current design. It'll have to wait for a new ES version, when perhaps I'll have the time to rewrite it from scratch. This will also mean I'll break the compatibility with assemblies produced with the old compiler.<br /><br />Bah.<br /><br />Edit: hell, since I love to rewrite code, I think I'm going to redo the compiler from scratch, this time taking in account everything. I haven't been analysing the problem at hand enough, and that's the result! Don't follow my example! ç_ç/<br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com3tag:blogger.com,1999:blog-7673606540941800376.post-58128858431627306242008-07-29T15:21:00.000+02:002008-07-29T16:08:24.630+02:00Entity System (Part 4)<span style="font-family:trebuchet ms;">As I said in part 2, the core of this entity system is how messages are dispatched to entities (technically, to their message handlers). Since handlers have a state and a priority flag, it'd make sense to create an ordered list of handlers, and shoot the message down this list. Of course, upon component installation, the order must be kept and it depends on the above flags.<br /><br />At this point, I don't care if the "message pipe" must be a list, a tree, an array, whatever; I'm worried about the performance of the system, to be precise about allocations.<br /><br />In a game, especially such as ours, it is common to have many similar enemies which share the same type of components (to keep the es terminology) - we know that all of them, at least, have a Health component. Since I mentioned allocations, the attentive reader might have already understood that I'm about to talk about object pooling.<br /><br />Why pooling? I find it logical to reuse some objects over and over, since I'm not sure how long they'll live. They might be short-termed (entity insta-kill), or long-lived, or anything in between. We know that GCs kick in post allocations, and that short-lived objects are fast to collect. We also know that caches need a policy, or they're just disguised memory leaks (and if <a href="http://blogs.msdn.com/ricom/archive/2007/06/25/caching-redux.aspx">Rico Mariani says so...</a>).<br />However, in our case scenario, I cannot predict the life of the objects composing an entity (plus the entity itself). Should I just allocate whatever I want and focus my attention on, say, a funny youtube video? Or should I consider creating a pool of reusable objects, instead of allocating without a specific order? Still, allocations are very fast in the CLR.<br /><br />And the story isn't over, yet. A message pipe contains many references to handlers. And there will be x message pipes equal to the number of entities times the number of system messages, each of which will contain y references to y different handlers. It's a lot of references to be tracked by the garbage collection, and I'm scared to just think what'd happen if these references kept some objects alive instead of letting the GC collect them.<br /><br />My solution (and it's far from being the right one, I suppose) would be to pool stuff, even if I have just advised against it in a recent gamedev.net post. With pooling, I have collections of objects ready to be used or already used, and I can access them via an integer "handle" (namely an index). All my message pipes would contain is a list of these integers - thus no actual pointers but indices. Would my garbage collector be happy? Am I wasting my time? I tend to think the latter, since I haven't managed to make up my mind about this matter yet.<br /><br />I gotta say I find many .net perf advices a bit obscure.<br /><br />There's also something else which has kept my mind a bit busy between a general ledger entry table and a C/AL codeunit this morning (brrrrr!). Should I suggest the GC to perform a collection when, say, the user reloads the level or changes map? I'd say so, but it isn't necessarily right. I must remember to test this as well at some point...<br /><br />Premature optimization, anyone?<br /><br /><br /><br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-33448591229308671152008-07-25T23:52:00.000+02:002008-07-25T23:53:43.117+02:00.NETAsm<span style="font-family:trebuchet ms;">You HAVE to check <a href="http://www.codeplex.com/netasm">this</a> out. Sounds bloody amazing to me.</span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-44163153876744445642008-07-25T23:22:00.000+02:002008-07-29T16:02:19.525+02:00Entity System (Part 3)<span style="font-family:trebuchet ms;">Well, the compiler looks almost done; a ntl file in, a .net assembly out. I'm sure there will be a few bugs to iron out, but it conforts me to just think I'm not too far from its release.<br /><br />The next step will be releasing an editor for the language; for now, I think I'm going to use <a href="http://code.google.com/p/alsing/">Roger Alsing's Syntaxbox</a> and some other stuff found in the net.<br /><br />Another aspect worth discussing is that the Entity System will work on its own thread, and it will communicate with the main thread via the so-called "action gateway". Every action sent to the ES is queued and executed serially; the inverse is alike, however the main thread has to take care of serializing the actions the ES has sent and execute them after whatever comes first (usually rendering and physics update).<br /><br />Now, in my mind this looks like a good plan, but I know it's bound to change somehow. I can't wait to have some working results to show.<br /><br />Good weekend, Raine out (nerdish goodbye).<br /><br />Part 4 is <a href="http://arainsong.blogspot.com/2008/07/entity-system-part-4.html">here</a>.<br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-20964713065942960152008-07-22T18:34:00.001+02:002008-07-29T16:10:16.132+02:00Tree awesomeness<span style="font-family:trebuchet ms;">When you have an artist doing stuff like this...<br /></span><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://img144.imageshack.us/img144/3017/testgj4.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 371px; height: 277px;" src="http://img144.imageshack.us/img144/3017/testgj4.jpg" alt="" border="0" /></a><br /><span style="font-family:trebuchet ms;">Awesomeness rating: 100%<br /><br />Well, check out our <a href="www.darkmana.com"></a><a href="www.darkmana.com">website</a> if you're interested in how the tools are coming along. :)<br /><br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com0tag:blogger.com,1999:blog-7673606540941800376.post-7774150651292395762008-07-20T18:47:00.000+02:002008-07-20T19:12:13.034+02:00Async Resource Loader<span style="font-family: trebuchet ms;">A few months ago I had the map loading stuff done, and wanted to try some landscape paging. I thought a worker thread would save my day but, as it turned out, loading stuff from HD was still blocking the rendering. I took a look around and found out that synchronous calls (even in a different thread) wouldn't act any better than if they were in the main (rendering) thread.<br /><br />Real life then set in, and I couldn't get much done. Some weeks ago I rewrote the async loader, and this time it'd include asynchronous calls. So, a worker thread + asynchronous calls (Begin... / End... methods). I soon realized a bad design mistake and I wiped the folder (lesson learned: don't code anything until you've filled at least a page of a good old paper notebook).<br /><br />I'm going to write it again before implementing anything else since I want all loads to be performed without rendering hiccups (or at least, as few as possible, since the OS has the final say on everything). So, since it's to be rewritten, I'll take more time to design it carefully.<br /><br />The ARL (async resource loader, blah blah blah) allows you to use custom loaders (since all it does, on its own, is to load a stream of bytes asynchronously from somewhere). Once you have added at least a loader, you start the "service" and call the Load(ResourceInfo) method wherever you like (provided it's in the main thread). Once it's ready, you get a Resource object back (from a callback, I guess). That's about it.<br /><br />There are details to consider, however; load requests have to be queued, can be aborted, the object which does the final loading (that is, converting the stream of bytes into an useable resource) must be locked (both inside the custom loader and outside), and last but not least, it really has to be threadsafe and performing, otherwise it's useless.<br /><br />That's all for the moment, ran out of inspiration....<br /></span>Rainehttp://www.blogger.com/profile/02575831434483351838noreply@blogger.com2