<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.jacius.info</title>
	<atom:link href="http://blog.jacius.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jacius.info</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 21:05:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Complicated Code and Creative Blocks</title>
		<link>http://blog.jacius.info/2012/02/02/complicated-code-and-creative-blocks/</link>
		<comments>http://blog.jacius.info/2012/02/02/complicated-code-and-creative-blocks/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 21:01:09 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ambienome]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=843</guid>
		<description><![CDATA[The past several weeks have been a struggle, productivity-wise. First, I spent quite a lot of time working on proto-slots. That may seem productive, but the amount of effort I put into polishing and documenting it was way out of proportion to the benefit I would get from it. I think I did a pretty [...]]]></description>
			<content:encoded><![CDATA[<p>The past several weeks have been a struggle, productivity-wise.</p>
<p>First, I spent quite a lot of time working on <a href="https://github.com/jacius/proto-slots">proto-slots</a>. That may seem productive, but the amount of effort I put into polishing and documenting it was way out of proportion to the benefit I would get from it. I think I did a pretty good job on that project, but I also recognize now that I was using it as a way to avoid actually working on Ambienome.</p>
<p>It was about three weeks ago that I realized what was happening, so I tried to force myself to focus on Ambienome. That didn&#8217;t really work, and I just ended up with a serious creative block. I spent about two weeks making almost no progress. My code had been accruing unnecessary complexity, mostly due to exploring a lot of unfamiliar territory (Lisp, and OpenGL), which made it difficult to work on when my motivation was not very high. Each time I would try to focus on Ambienome, I&#8217;d run into some obstacle, grimace, and reflexively go find some way to distract myself. (In hindsight, it was probably not wise to start a challenging new project at the beginning of winter, since my energy levels and motivation always dip during the winter.)</p>
<p>(Those two weeks weren&#8217;t a complete loss, though; I did beat a lot of games! :P If you&#8217;re curious: <a href="http://dungeonsofdredmor.com/">Dungeons of Dredmor</a>, <a href="http://bindingofisaac.com/">The Binding of Isaac</a>, <a href="http://limbogame.org/">Limbo</a>, <a href="http://www.mumbojumbo.com/game/Glowfish/prod370033?technology=WINDOWS">Glowfish</a>, <a href="http://www.swingswingsubmarine.com/games/blocks-that-matter/">Blocks That Matter</a>, and a couple others that I can&#8217;t recall at the moment.)</p>
<p><span id="more-843"></span>I finally broke through the creative block about a week ago, by unplugging the internet, shutting out all distractions, and just tackling my code head-on. I spent 3 days just simplifying and cleaning up my code to make further development feasible. All told, I managed to eliminate 9 classes:</p>
<ul>
<li><code>job</code>, which acted as a central coordinating structure for the OpenGL rendering pipeline. The important functionality was transformed into methods of the <code>program</code> class, which is slightly lower-level coordinating structure for the rendering pipeline. The rest of the code was scrapped.</li>
<li><code>uniform</code> and <code>attribute</code>, which represented OpenGL shader uniforms and attributes. These classes were also reduced into methods of <code>program</code>, and the unnecessary code scrapped.</li>
<li><code>rectangle</code>, <code>triangle</code>, and <code>circle</code>, which represented instances of those geometric shapes. They were reduced into a <code>render-shape</code> generic function, with a method implemented for each shape based on a keyword. For example, to render a circle you&#8217;d do <code>(render-shape :circle ...)</code>. Lisp&#8217;s method dispatching system is pretty handy sometimes!</li>
<li><code>shape</code>, which was the parent class of the three shapes mentioned above. Aside from the rendering code, which (as I said) became methods, this class also stored the shape&#8217;s transformation (position, rotation, scale), and other properties such as color. I moved this functionality to the <code>part</code> class, which represents a creature body part.</li>
<li><code>group</code>, which held multiple shapes that would move together, just like SVG&#8217;s <code>g</code> element. Instead, I decided that it&#8217;s simpler and more intuitive to allow body parts to be parented to other parts. To handle the case of an invisible pivot point, the parent shape can be made invisible, in which case it&#8217;s functionally equivalent to a group.</li>
<li><code>prop</code>, which represented a property of a shape, such as its color. The idea behind this class was that it would contain not only the data, but also some metadata (its type, human-readable name, etc.) that could be used later to generate an appropriate user interface to edit the property. For example, the color property would have some metadata indicating that the data was a color, so it should be edited using a color swatch widget. I decided to just store the data and metadata in hash tables instead.</li>
</ul>
<p>My code is now much leaner and more function-oriented than before, and much more approachable and easier to work with. I actually  eliminated (temporarily, I think) the need for my proto-slots library &mdash; which, after all the work I put into it, is either really funny or really frustrating.</p>
<p>Yesterday and today, I&#8217;ve been making progress (not a great deal, but enough) on new code, specifically the ability to serialize and deserialize creatures and their body parts, so that they can be saved and loaded from file. I&#8217;m nearly done with this, but I&#8217;m not sure yet what I&#8217;ll tackle next.</p>
<p>Perhaps I&#8217;ll try to plot out a more concrete roadmap, start to define and narrow the scope of the game, and lay out some specific tasks and goals. I&#8217;m sure my unorganized, exploratory approach is a significant cause of my slow progress. It would be good to have some concrete milestones to chase after, and maybe even some deadlines to push myself forward. What a radical notion!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2012/02/02/complicated-code-and-creative-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mini-project: proto-slots</title>
		<link>http://blog.jacius.info/2012/01/05/mini-project-proto-slots/</link>
		<comments>http://blog.jacius.info/2012/01/05/mini-project-proto-slots/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 06:35:07 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=838</guid>
		<description><![CDATA[I&#8217;ve just released proto-slots, a mini-project I created as part of Ambienome. From the README: proto-slots provides a macro for defining prototypal accessor methods so that CLOS instances will support protoypal inheritance. Prototypal inheritance means that an instance&#8217;s slots can inherit values from another instance, known in these docs as the &#8220;base object&#8221; (but more [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released <strong><a href="https://github.com/jacius/proto-slots">proto-slots</a></strong>, a mini-project I created as part of <a href="http://blog.jacius.info/category/projects/ambienome/">Ambienome</a>. From the README:</p>
<blockquote><p>proto-slots provides a macro for defining prototypal accessor methods so that CLOS instances will support protoypal inheritance. Prototypal inheritance means that an instance&#8217;s slots can inherit values from another instance, known in these docs as the &#8220;base object&#8221; (but more commonly known elsewhere as the &#8220;prototype&#8221;).</p></blockquote>
<p>I wrote the first version of what eventually because the def-proto-slots macro to solve a problem I described in my previous post:</p>
<blockquote><p>But, for each shape instance to have its own color (or other such data in the future), each shape instance must have its own job, because the color would be a uniform contained in that job. If I set the color in the base job, all instances of that kind of shape would have the same color. But if each instance has its own job, I lose the benefit of having the vertex data stored in one place.</p>
<p>I solved this by letting a job have a &#8220;parent&#8221;, from which it inherits anything it’s missing, such as a program or elements. For vertex attribs and uniforms, the inheritance works by merging the parent’s list of attribs/uniforms with the child&#8217;s list, with any of the child&#8217;s attribs/uniforms taking precedence when it has the same name as one of the parent&#8217;s.</p></blockquote>
<p>I realized later that I was going to need prototypal inheritance for other parts of Ambienome, too. For example, I&#8217;m pretty sure the creature class will use this pretty heavily. So, I took my ad hoc macro, made it more flexible (it now supports different &#8220;inheritance strategies&#8221;), and polished it up. Along the way I decided to release it as a separate library, to maybe save someone else the trouble of implementing this same sort of thing.</p>
<p>proto-slots is <a href="https://github.com/jacius/proto-slots">available at GitHub</a>, released under the X11/MIT license. If you find a bug, <a href="https://github.com/jacius/proto-slots/issues">make an issue</a>. To submit a patch, fork my repo and send a pull request.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2012/01/05/mini-project-proto-slots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Colored Shapes</title>
		<link>http://blog.jacius.info/2011/12/17/colored-shapes/</link>
		<comments>http://blog.jacius.info/2011/12/17/colored-shapes/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 23:19:51 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ambienome]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=831</guid>
		<description><![CDATA[I got a bit sidetracked while working on creature components, but still ended up making important progress for the overall system. First, I created a new transform class by abstracting and cleaning up the shape class&#8217;s position, angle, and size attributes and methods. I also created a transformable &#8220;mixin&#8221; class, which can be used by [...]]]></description>
			<content:encoded><![CDATA[<p>I got a bit sidetracked while working on creature components, but still ended up making important progress for the overall system.</p>
<p>First, I created a new <code>transform</code> class by abstracting and cleaning up the <code>shape</code> class&#8217;s position, angle, and size attributes and methods. I also created a <code>transformable</code> &#8220;mixin&#8221; class, which can be used by any class that has a transform. (Lisp doesn&#8217;t have mixins in the same sense that Ruby does, but since Lisp supports multiple inheritance, you can get more or less the same effect by designing a class in a mixin-ish style.) The transformable class provides accessors for the transform&#8217;s position, angle, and size, so that you can treat them as if they were direct slots of the object holding the transform.</p>
<p>Next, I decided to enhance the shape class so that shapes can have a color. This turned out to be somewhat challenging, because of how I had designed the OpenGL wrapper classes.</p>
<p><span id="more-831"></span>I have a <code>job</code> class that holds a program object (which is a collection of compiled shaders linked together) and the vertex attribs, uniforms, and elements used to render a certain thing (such as a shape). For memory efficiency, each kind of shape (rectangle, triangle, or circle) has a base job which holds the generated vertex data and elements. </p>
<p>But, for each shape instance to have its own color (or other such data in the future), each shape instance must have its own job, because the color would be a uniform contained in that job. If I set the color in the base job, all instances of that kind of shape would have the same color. But if each instance has its own job, I lose the benefit of having the vertex data stored in one place.</p>
<p>I solved this by letting a job have a &#8220;parent&#8221;, from which it inherits anything it&#8217;s missing, such as a program or elements. For vertex attribs and uniforms, the inheritance works by merging the parent&#8217;s list of attribs/uniforms with the child&#8217;s list, with any of the child&#8217;s attribs/uniforms taking precedence when it has the same name as one of the parent&#8217;s. It&#8217;s wonderfully easy to do that in Lisp:</p>
<pre><code>(union (attribs parent) (own-attribs job)
       :key #'name :test #'string=)</code></pre>
<p>This code takes the attribs list from the parent, including any attribs the parent itself inherits from <em>its</em> parent, and the list of attribs belonging directly to the job, and performs a set union of those two lists, which discards duplicates. But what is a &#8220;duplicate&#8221;? By providing the <code>:key #'name</code>, I&#8217;m telling it to call the <code>name</code> function on each attrib, and then check the names to see if they are duplicates. The <code>:test #'string=</code> part tells it to use the <code>string=</code> function, which performs case-sensitive string comparison, to decide if the two names are the same. The result is that if an attrib in the parent&#8217;s list and an attrib in the child&#8217;s list have the same name, only the child&#8217;s is used (since it is given as a later argument to the <code>union</code> function).</p>
<p>While doing this, I noticed that the inheritance code was exactly the same for attribs and uniforms, except for the word &#8220;attrib&#8221; or &#8220;uniform&#8221;. So, I wrote a fairly simple, albeit long, macro to keep things <abbrev title="Don't Repeat Yourself">DRY. Then I wrote shorter macro to reduce the redundancy in the simpler inheritance behavior for the other slots, which only inherit from the parent if their slot is empty/null, but don&#8217;t have to perform any merging.</p>
<p>Now that jobs can have a parent, I can use each shape class base job (the job containing the vertex data and elements) as the parent for each shape instance&#8217;s job (the job containing the color and other instance-specific data). So, the instance&#8217;s job can inherit the vertex data and elements, while still having its own color. And later, I&#8217;ll be able to have base jobs at different levels of detail, and easily change the instances&#8217; parents whenever I want to change their level of detail.</p>
<p>After a bit more work, I finally had support for different colors in each shape instance. Victory!</p>
<p><img src="http://blog.jacius.info/wp-content/uploads/2011/12/colored_shapes.png" alt="Screenshot of a purple square, blue triangle, and orange circle." title="Colored Shapes" width="406" height="326" class="aligncenter size-full wp-image-832" /></p>
<p>It was a long detour, but my code base is much better for all the work. Now I can <em>finally</em> get around to shape groups and creature components!</abbrev></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2011/12/17/colored-shapes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shape Mesh Progress</title>
		<link>http://blog.jacius.info/2011/12/09/shape-mesh-progress/</link>
		<comments>http://blog.jacius.info/2011/12/09/shape-mesh-progress/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 18:26:13 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ambienome]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=826</guid>
		<description><![CDATA[Yesterday, I completed the code to generate triangle and circle meshes: The triangle looks like it&#8217;s too small, but it fits perfectly in the circle, and the circle fits perfectly in the square. Yay, geometry! Of course, when building a creature, they can be scaled to whatever size you like, and the algorithms can produce [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I completed the code to generate triangle and circle meshes:</p>
<p><img src="http://blog.jacius.info/wp-content/uploads/2011/12/meshes.png" alt="Screenshot of a rectangle mesh, a triangle mesh, and a circle mesh." title="Meshes" width="406" height="326" class="aligncenter size-full wp-image-828" /></p>
<p>The triangle looks like it&#8217;s too small, but it fits perfectly in the circle, and the circle fits perfectly in the square. Yay, geometry! Of course, when building a creature, they can be scaled to whatever size you like, and the algorithms can produce meshes at any level of detail. Eventually, I&#8217;ll make it so the game automatically adjusts the level of detail based on the shape&#8217;s size on the screen.</p>
<p>As I mentioned in the previous post, these aren&#8217;t the only shapes that will be available, but they are enough to let me move on to other things. One of the core concepts of Ambienome is that I can program new shapes later, even after the game has been released. If I&#8217;m feeling really clever, I could probably leverage Lisp&#8217;s power to allow users to program new kinds of shapes, too. That&#8217;s not a high priority, though.</p>
<p>Today I&#8217;ll start code-sketching the concept of components and creatures. A creature is built from one or more components, which are basically shapes with some associated behavior. Components can be grouped to move together, and groups can contain other groups, so it&#8217;s essentially a &#8220;tree&#8221; (hierarchy) of transformation nodes, with each &#8220;leaf&#8221; being a shape. This is the same concept as grouping in SVG or Flash, or parenting in 3D software like Blender or Maya.</p>
<p>After weeks of just studying and debugging OpenGL, it sure is nice to be making visible progress again!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2011/12/09/shape-mesh-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures with the OpenGL shader pipeline</title>
		<link>http://blog.jacius.info/2011/12/07/adventures-opengl-shader-pipeline/</link>
		<comments>http://blog.jacius.info/2011/12/07/adventures-opengl-shader-pipeline/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 18:31:41 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ambienome]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=812</guid>
		<description><![CDATA[For the past several weeks, I&#8217;ve been learning &#8220;modern&#8221; OpenGL programming practices, by which I mean using a GLSL shader pipeline with vertex and fragment shaders. Even before starting Ambienome, I was already somewhat familiar with the old OpenGL &#8220;fixed function pipeline&#8221;, using glBegin/glEnd, glColor, glVertex, etc. Ambienome is going to be visually simple enough [...]]]></description>
			<content:encoded><![CDATA[<p>For the past several weeks, I&#8217;ve been learning &#8220;modern&#8221; OpenGL programming practices, by which I mean using a <a href="https://en.wikipedia.org/wiki/GLSL">GLSL</a> shader pipeline with vertex and fragment shaders.</p>
<p>Even before starting Ambienome, I was already somewhat familiar with the old OpenGL &#8220;fixed function pipeline&#8221;, using glBegin/glEnd, glColor, glVertex, etc. Ambienome is going to be visually simple enough that I probably could have used the fixed function pipeline, but I decided to learn the shader pipeline to improve my knowledge and skills, to allow nicer visual effects, and to leverage the GPU&#8217;s number-crunching power as much as I can.</p>
<p>Grokking the shader pipeline was a challenge. There are many separate concepts to learn, and then you must understand how they fit together. Also, there are fewer learning resources for the shader pipeline than there are for the older fixed function pipeline. I relied mostly on <a href="http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Table-of-Contents.html">Joe Groff&#8217;s &#8220;An intro to modern OpenGL&#8221; article series</a>, but if I were doing it over again, I might try to find a good book. Unfortunately, the selection is somewhat thin. I&#8217;m considering <a href="http://www.amazon.com/OpenGL-Shading-Language-Randi-Rost/dp/0321637631/"><i>OpenGL Shading Language</i><i></i></a> (the so-called &#8220;Orange Book&#8221;) or the <a href="http://www.amazon.com/OpenGL-ES-2-0-Programming-Guide/dp/0321502795/"><i>OpenGL ES 2.0 Programming Guide</i></a>. (OpenGL ES 2.0 is conceptually very similar to the OpenGL shader pipeline, and also very similar to WebGL.) Unfortunately, the reviews suggest those two are not very well written, organized, or proofread. <a href="http://www.amazon.com/Real-Time-Rendering-Third-Tomas-Akenine-Moller/dp/1568814240/"><i>Real-Time Rendering</i></a> looks like it might provide a good high-level understanding of shaders and rendering, but it&#8217;s not specific to OpenGL or GLSL, and I&#8217;m not really interested in advanced photorealistic shader effects. Maybe if there are any book stores still open in this town, I&#8217;ll see if any of these books are on the shelf so I can assess them before I buy.</p>
<p>Anyway, even after I had scraped together a modest understanding of the concepts behind the shader pipeline, applying that knowledge in practice took longer than I anticipated. It was fairly frustrating at times, partly due to some (minor) shortcomings of cl-opengl and lispbuilder-sdl, and partly due to me misinterpreting some vague parts of the OpenGL documentation. There were many times when I felt like putting the shader pipeline aside, and just using the fixed function pipeline for a while, so I could keep my momentum up. But I stubbornly stuck with it, and now I&#8217;ve got a working, reusable rendering framework built atop the shader pipeline. Huzzah!</p>
<p>My next task is to write code to algorithmically generate mesh data for several geometric primitives. Yesterday, I finished the code for a rectangle mesh built from triangle strips (well, actually one long strip with degenerate triangles connecting each row). Here&#8217;s a screenshot of a 10&times;10 rectangle mesh rendered in wireframe mode:</p>
<p><img src="http://blog.jacius.info/wp-content/uploads/2011/11/rectangle_mesh.png" alt="Screenshot of a rectangle mesh" title="Rectangle Mesh" width="406" height="326" class="aligncenter size-full wp-image-809" /></p>
<p>It&#8217;s not much to look at in itself. I could have achieved that in an afternoon using the fixed function pipeline! But that humble mesh, rendered here using the simplest possible vertex and fragment shaders, represents weeks of learning. Now that I have the basics working, I can write more interesting shaders to morph the shape and create cool visual effects. For example, Ambienome takes place underwater, so I&#8217;ll probably write a shader to make things sway and ripple as if they were being affected by a water current.</p>
<p>Next, I&#8217;ll be writing the code for a triangle mesh, and then a circle mesh. I have plans for more shapes, like teardrop, leaf, ring (circle with a hole in the middle), and tentacle (a Bézier curve with thickness controlled by another Bézier curve). But, I&#8217;m going to save those for later. Once I&#8217;ve got rectangle, triangle, and circle, I&#8217;m going to take a step back from the low-level foundation for a while, and start fleshing out higher-level concepts like components, creatures, and scenes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2011/12/07/adventures-opengl-shader-pipeline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ambienome &#8211; Technology</title>
		<link>http://blog.jacius.info/2011/11/13/ambienome-technology/</link>
		<comments>http://blog.jacius.info/2011/11/13/ambienome-technology/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 06:24:45 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ambienome]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=766</guid>
		<description><![CDATA[In my previous post, I described the concept and roadmap for my new project, Ambienome. In this post, I&#8217;ll be describing the technology (programming language and libraries) I&#8217;m using, and why I chose them. Even though I have seven years of experience with Ruby, and my own game library, Rubygame, already available and ready to [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://blog.jacius.info/2011/11/04/new-project-ambienome/">previous post</a>, I described the concept and roadmap for my new project, Ambienome. In this post, I&#8217;ll be describing the technology (programming language and libraries) I&#8217;m using, and why I chose them.</p>
<p>Even though I have seven years of experience with Ruby, and my own game library, Rubygame, already available and ready to use, I&#8217;ve decided not to write Ambienome in Ruby. Instead, I&#8217;m writing it in Common Lisp, using OpenGL and OpenAL for graphics and audio.</p>
<h3>Libraries</h3>
<p>OpenGL and OpenAL were natural choices, since they&#8217;re free, cross-platform, and widely supported with pretty much any programming language. I would have chosen these no matter what language I settled on.</p>
<p>OpenGL doesn&#8217;t provide window management or input event processing, though, so I&#8217;ll need another library to handle that. The main choices for that are <a href="http://www.libsdl.org/">SDL</a>, <a href="http://www.glfw.org/">GLFW</a>, and GLUT.</p>
<p>GLUT is a very popular and widely supported framework, but I don&#8217;t like how you have to shape your entire program structure around GLUT&#8217;s expectations, so I quickly dismissed it. SDL is also popular, but my years of experience with it have made me keenly aware of its shortcomings. So, I decided to try GLFW first.</p>
<p>GLFW is pretty nice, like a less obtrusive version of GLUT. I played around with it long enough to create an abstraction layer for opening and closing the window, but then discovered that GLFW currently has no API for setting the window&#8217;s icon. That may seem like a minor detail, but it was enough to nudge me into reconsidering SDL.</p>
<p>Two other points in SDL&#8217;s favor are that I&#8217;m already familiar with it &mdash; unlike everything else about this project! &mdash; and that SDL 1.3 will have support for multi-touch devices, and possibly multiple mice, both of which could provide some cool ways of interacting with the game. SDL 1.3 hasn&#8217;t been released yet (after many years&#8230;), but I might try taking a snapshot of the development repository, and working with that.</p>
<p>So, I ported the window abstraction layer from GLFW to SDL (1.2), and added an input event abstraction layer. I&#8217;m not entirely happy with it, so I might reevaluate GLFW (or even GLUT, since I&#8217;ve read that freeglut and Apple&#8217;s GLUT let you avoid the glutMainLoop function). But for now, SDL will be enough while I figure out the challenging new stuff with OpenGL and OpenAL.</p>
<p>One final library worth mentioning is <a href="http://www.clutter-project.org/">Clutter</a>, which I&#8217;m considering using to create the in-game GUI. When it gets to that point, I&#8217;ll try Clutter, then look into alternative libraries if Clutter doesn&#8217;t work out. As a last resort, I could just roll my own GUI widgets, but I&#8217;d rather avoid that if I can.</p>
<h3>Lisp</h3>
<p>OpenGL and OpenAL are pretty popular, &#8220;safe&#8221; choices of technology for game development. There are countless web articles, tutorials, books, and other learning resources available, and many experienced programmers I could turn to for help if needed. Both libraries are available on Linux, Mac, and Windows, and have bindings for many programming languages. There&#8217;s nothing particularly surprising or unusual about using OpenGL or OpenAL.</p>
<p><a href="http://www.lisperati.com/logo.html"><img src="http://blog.jacius.info/wp-content/uploads/2011/11/lisplogo_fancy_128.png" alt="The Lisp Alien Mascot; Made with secret alien technology" title="Lisp Alien" width="128" height="111" class="alignleft size-full wp-image-777" /></a></p>
<p>The choice to use Common Lisp, on the other hand, is likely to raise a few eyebrows. After all, it&#8217;s <a href="http://lispers.org/">secret alien technology</a> powered by excessive parentheses!</p>
<p>Lisp, despite its elegance and power, is not nearly as commonly used for game programming as the C language family (C++, C#, Java, etc.), Python, or probably even Ruby. If I had to speculate as to why Lisp has a low adoption rate among game programmers, I&#8217;d cite the usual factors that affect Lisp&#8217;s adoption rate in general: difficulty getting started (choosing and installing a Lisp implementation and IDE, finding good tutorials, etc.), the &#8220;strange&#8221; syntax, Lisp&#8217;s reputation as being more academic than practical, and the Lisp community&#8217;s reputation (whether deserved or not) for being somewhat elitist and unfriendly. Also, many game programmers are obsessed with raw performance, as if brute-force number crunching was the key ingredient in making a fun game. Those programmers will usually stick with C or C++, and dismiss anything else as being &#8220;too slow&#8221;.</p>
<p>But, I don&#8217;t particularly care about Lisp&#8217;s popularity or why other people like or dislike it. I care about having an interesting, powerful language that fits the project well.</p>
<ul>
<li>Like Ruby, Python, etc., Lisp promotes rapid prototyping with concise and flexible code, and sustains <em>creative flow</em> in a way &#8220;stop-and-compile&#8221; languages like C cannot.</li>
<li>Common Lisp can be compiled to native executables, and I can declare optimizations for those situations where number crunching efficiency is needed, such as generating custom audio data.</li>
<li>Lisp&#8217;s notion of &#8220;code as data&#8221; should work well with the concept of expressing behaviors as objects, and saving each creature&#8217;s behavior in a file.</li>
<li>Lisp&#8217;s macro and package systems should make it really easy to create a safe, simple, and efficient domain-specific language to allow users to define new creature parts and behaviors.</li>
<li>Lisp is a novel language to me, so this project is sure to be an interesting learning experience!</li>
</ul>
<p>Before settling on Common Lisp, I also considered CoffeeScript and Clojure. CoffeeScript (using HTML5 Canvas and Audio elements) was very tempting because of the ease of deployment and cross-platform compatibility. But, HTML5 does not yet have a workable API for generating and manipulating audio data, and running in a browser would also limit my options for player-to-player file sharing and multiplayer gameplay.</p>
<p>As for Clojure: it&#8217;s a really interesting Lisp, and the ability to use Java libraries and compile to Java bytecode could be useful. But, learning to write a game using only immutable data structures and <abbrev title="Software Transactional Memory">STM</abbrev>/agents would be a bit <em>too much</em> of a novel learning experience, and this project is going to be a lot to wrap my head around already. Also, Clojure&#8217;s strengths, such as safe multithreading, don&#8217;t provide much of a practical benefit to this particular project.</p>
<p>So far, I&#8217;m really enjoying Common Lisp. I&#8217;ve been reading <a href="http://gigamonkeys.com/book/">Practical Common Lisp</a>, which is a really excellent resource for learning Common Lisp, and available online at no cost. I&#8217;m certainly not a Lisp guru yet, but I can already feel the amazing expressive power and freedom Lisp provides. This is sure to be an interesting project!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2011/11/13/ambienome-technology/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New Project: Ambienome</title>
		<link>http://blog.jacius.info/2011/11/04/new-project-ambienome/</link>
		<comments>http://blog.jacius.info/2011/11/04/new-project-ambienome/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 22:48:42 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ambienome]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=756</guid>
		<description><![CDATA[I&#8217;ve started a new project: Ambienome. This is a game (or, rather, a toy) I&#8217;ve wanted to create for years &#8212; I blogged about it in May 2007 and November 2009 &#8212; and now I&#8217;m finally making a serious attempt. I&#8217;ll be blogging about my development progress, both to solidify my ideas by putting them [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started a new project: <strong>Ambienome</strong>. This is a game (or, rather, a toy) I&#8217;ve wanted to create for years &mdash; I blogged about it in <a href="http://blog.jacius.info/2007/05/30/ambient-wildlife-and-bouldered-paths/">May 2007</a> and <a href="http://blog.jacius.info/2009/11/24/dreaming-of-ambienome/">November 2009</a> &mdash; and now I&#8217;m finally making a serious attempt.</p>
<p>I&#8217;ll be blogging about my development progress, both to solidify my ideas by putting them into words, and to keep myself &#8220;accountable&#8221; for maintaining progress. I&#8217;m starting off with a two-part announcement and introduction to the project. In this part, I&#8217;ll describe Ambienome&#8217;s concept and a tentative list of progress milestones. In the second part, I&#8217;ll write about the tools (programming language and library) I&#8217;m using, and why I chose them.</p>
<h3>Concept</h3>
<p>Ambienome will be a freeform creative toy/playground, where players design and interact with colorful, musical, AI-driven aquatic creatures. The concept is heavily inspired by Toshio Iwai&#8217;s <a href="http://en.wikipedia.org/wiki/Electroplankton">Electroplankton</a>, and by Will Wright&#8217;s <a href="http://en.wikipedia.org/wiki/Spore_(2008_video_game)">Spore</a>.</p>
<p>I loved Electroplankton, but wished there was a way to create new types of creatures, to have multiple types of creatures in the same scene, and to save and share scenes with my friends. Spore&#8217;s easy-to-use method for creating new creatures out of parts, and integrated system for saving, uploading, and downloading creations online, suggested a workable model for creating and sharing Ambienome creatures and scenes.</p>
<h3>Roadmap</h3>
<p>This is a very novel kind of project for me, and it will have many challenges to overcome and problems to solve. I can&#8217;t even guess how long it might take to finish, so I&#8217;m not going to bother speculating about a project timeline. But, I have plotted out some of the major milestones for the project, in terms of functionality to be implemented:</p>
<ol>
<li>Players can interact with a variety of built-in creatures, and watch/hear them interact with each other.</li>
<li>Players can assemble new types of creatures from a variety of built-in parts.</li>
<li>Players can import and export creations (creatures and scenes), to share with other players.</li>
<li>Players can upload and download creations from a central site (a la <a href="http://www.spore.com/sporepedia">Sporepedia</a>), and rate and comment on other players&#8217; creations.</li>
<li>Players can design custom parts, and share them with other players.</li>
<li>Multiple players can build and interact with the same scene simultaneously, over the network.</li>
</ol>
<p>I consider 1-3 to be essential, and the rest to be icing on the cake. I&#8217;ll do at least one release per milestone. I haven&#8217;t decided yet whether this will be an open source project or not. If it seems to be turning out well, I might try to make some money off it.</p>
<p>Currently, I&#8217;m still laying the foundation, implementing low-level functionality. For reasons I&#8217;ll discuss in the next post, I&#8217;ve chosen not to use Ruby or Rubygame for this project. So, in many ways I&#8217;m starting from square one, reimplementing the basics: opening a window, handling input events, drawing to the screen, managing the game loop, etc. Well, not exactly square one &mdash; I&#8217;m building atop other libraries, and I can borrow the basic concepts from Rubygame, so I don&#8217;t have to solve those problems all over again.</p>
<p>In the next post, I&#8217;ll be writing about the programming language and libraries I&#8217;ll be using, and why I chose them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2011/11/04/new-project-ambienome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sup email client keybindings and filters</title>
		<link>http://blog.jacius.info/2010/11/08/sup-email-client-keybindings-and-filters/</link>
		<comments>http://blog.jacius.info/2010/11/08/sup-email-client-keybindings-and-filters/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 05:59:24 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[sup]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=752</guid>
		<description><![CDATA[Lately I&#8217;ve been playing with Sup, a geeky console-based email client written in Ruby. I&#8217;ve used it enough to understand it and settle in a bit, but unfortunately also enough to realize that it&#8217;s probably not right for me. Along the way, though, I&#8217;ve done some work with keybindings and message filters that I&#8217;d like [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been playing with <a href="http://sup.rubyforge.org/">Sup</a>, a geeky console-based email client written in Ruby. I&#8217;ve used it enough to understand it and settle in a bit, but unfortunately also enough to realize that it&#8217;s probably not right for me. Along the way, though, I&#8217;ve done some work with keybindings and message filters that I&#8217;d like to share with you.</p>
<p>Before I get to that, though, a brief review of Sup. What first attracted me to Sup was the fact that it&#8217;s written in Ruby (with fairly clean code, from what I&#8217;ve seen), and has a fairly extensive system of hooks for customizing and extending the client behavior (the hooks are also written in Ruby). Also, it has a nice label-based filing system and powerful search utilities (a la Gmail), rather than the tired old folders metaphor. It runs in the console and is entirely keyboard driven, the workflow is pretty quick and easy, and you compose messages in the text editor of your choice (emacs, vim, etc.).</p>
<p>Those are the strong points, for me. Unfortunately, there are a number of issues that made me decide to look elsewhere. Foremost is the console-based interface using Curses, which holds it back in a variety of ways. One issue I ran into was that there&#8217;s no way to define keybindings that use the Alt key; Curses simply doesn&#8217;t support that. Sup also doesn&#8217;t seem to be able to render non-Latin characters, which is occasionally an issue for me. And naturally, being console-based, modern luxuries like HTML mail and previews of attached images are out of the question.</p>
<p>So, Sup turns out not to be my cup of tea after all. But, maybe it is yours, so I&#8217;ll share the fruits of my brief foray.</p>
<ul>
<li>
<p>The first obstacle was the fact that Sup, like many Unix-style &#8220;mail user agents&#8221;, has no facilities for the actual fetching or sending of email over a network. Instead, it leverages programs like fetchmail, offlineimap, and sendmail to handle those things. This Unix-style mail system was something I had no prior experience in, so I had a lot to learn. After a lot of research and a fair bit of frustration, my advice is to forget the traditional fetchmail and sendmail, and instead use <a href="http://pyropus.ca/software/getmail/">getmail</a> and <a href="http://msmtp.sourceforge.net/">msmtp</a>. They are a <em>lot</em> simpler to set up, and do everything most people need.</p>
</li>
<li>
<p>After I got my email imported into Sup, I wanted to change some key bindings to be more comfortable. In particular, being an Emacs user, I am used to Ctrl-n/Ctrl-p to move the cursor up and down lines, while Sup defaults to the vi-style hjkl bindings (which make no sense for me, using the Dvorak keyboard layout). Unfortunately, I could find very little documentation about how to change the keybindings, other than the fact that there was a &#8220;keybindings.rb&#8221; hook that I could write&#8230; if I knew what to write in it.</p>
<p>Undeterred, I dove into the source code and learned all about the keybindings system. Then, I turned that knowledge into a <a href="http://sup.rubyforge.org/wiki/wiki.pl?CustomizingKeys">comprehensive CustomizingKeys wiki page</a>, so that the next guy wouldn&#8217;t have to dig through the code like I did. That was a fun afternoon project.</p>
</li>
<li>
<p>Next, I realized I needed a system to filter my incoming mail, automatically apply appropriate labels, and so on. Sup doesn&#8217;t have a filtering system like that built in, but it&#8217;s fairly straightforward to create one by taking advantage of Sup&#8217;s hook system. There is some documentation about this on the <a href="http://sup.rubyforge.org/wiki/wiki.pl?AutoAddLabelsToNewMessages">AutoAddLabelsToNewMessages wiki page</a>, but as I started writing my filters, I began to realize that, although writing ruby code for every filter gives you a lot of flexibility and power, it also involves a lot of redundant code and is not very easy to read or maintain.</p>
<p>So, I started writing my own filter system, which loads rules from a YAML file (<a href="https://github.com/jacius/sup-filters/blob/master/filters.example.yaml">see the example filters file</a>). I&#8217;ve posted the result to <a href="https://github.com/jacius/sup-filters">my sup-filters repository on GitHub</a>. Actually, what I&#8217;ve posted there is even more polished and better documented than what I used myself. Even after I had decided I wasn&#8217;t going to use Sup myself, I spent a couple days cleaning it up for other people, to call it a job well done. That&#8217;s Just How I Roll &#8482;.</p>
</li>
</ul>
<p>Anyway, if you use Sup, I hope you will find this stuff useful. As for myself, I will miss Sup&#8217;s labels and easy searching, but it&#8217;s time to continue my quest for a well-fitting email client. Next on my list to try is <a href="http://www.gohome.org/wl/">Wanderlust</a>. If you have any recommendations for other clients to try, leave a comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2010/11/08/sup-email-client-keybindings-and-filters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nice-FFI 0.4 released</title>
		<link>http://blog.jacius.info/2010/03/31/nice-ffi-0-4-released/</link>
		<comments>http://blog.jacius.info/2010/03/31/nice-ffi-0-4-released/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 04:10:34 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[nice-ffi]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=747</guid>
		<description><![CDATA[Nice-FFI 0.4 is now available. You can install the new version with gem install nice-ffi, as usual. Please note that Nice-FFI is still not considered API-stable, so if you aren&#8217;t willing to update your code when a new version comes out, you shouldn&#8217;t use it until version 1.0. Version 0.4 fixes several major bugs related [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jacius.github.com/nice-ffi/">Nice-FFI</a> 0.4 is now available. You can install the new version with <code>gem install nice-ffi</code>, as usual. Please note that Nice-FFI is still not considered API-stable, so if you aren&#8217;t willing to update your code when a new version comes out, you shouldn&#8217;t use it until version 1.0.</p>
<p>Version 0.4 fixes several major bugs related to finding and loading dynamic libraries:</p>
<ul>
<li>PathSet now properly expands globs (&#8220;*&#8221;) in file and directory names, like it was supposed to.</li>
<li>PathSet now works even when a directory path has no trailing separator (&#8220;/&#8221; or &#8220;\&#8221;).</li>
<li>Fixed a typo which caused NameError when using <code>load_library</code> with the default paths.</li>
</ul>
<p>You can get Nice-FFI:</p>
<ul>
<li>Via RubyGems: <code>gem install nice-ffi</code></li>
<li>Via Github: <a href="http://github.com/jacius/nice-ffi/">http://github.com/jacius/nice-ffi/</a></li>
<li>As a <a href="http://github.com/jacius/nice-ffi/tarball/master">tarball</a> or <a href="http://github.com/jacius/nice-ffi/zipball/master">zip</a>.</li>
</ul>
<p>Please send bug reports and feature requests to the <a href="http://github.com/jacius/nice-ffi/issues">issue tracker</a> on Github.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2010/03/31/nice-ffi-0-4-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nice-FFI 0.3 (and 0.2)</title>
		<link>http://blog.jacius.info/2010/01/17/nice-ffi-0-3-and-0-2/</link>
		<comments>http://blog.jacius.info/2010/01/17/nice-ffi-0-3-and-0-2/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 05:56:55 +0000</pubDate>
		<dc:creator>John Croisant</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[nice-ffi]]></category>

		<guid isPermaLink="false">http://blog.jacius.info/?p=742</guid>
		<description><![CDATA[I&#8217;ve just released a new version of Nice-FFI, my convenience library for Ruby FFI libraries. You can install the new version with gem install nice-ffi, as usual. Please note that Nice-FFI is still not considered API-stable, so if you aren&#8217;t willing to update your code when a new version comes out, you shouldn&#8217;t use it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just released a new version of <a href="http://jacius.github.com/nice-ffi/">Nice-FFI</a>, my convenience library for <a href="http://wiki.github.com/ffi/ffi/">Ruby FFI</a> libraries. You can install the new version with <code>gem install nice-ffi</code>, as usual. Please note that Nice-FFI is still not considered API-stable, so if you aren&#8217;t willing to update your code when a new version comes out, you shouldn&#8217;t use it until version 1.0.</p>
<p>Version 0.3 has a few changes:</p>
<ul>
<li>The default PathSet has a less restrictive filename search pattern, so it is better at detecting libraries.</li>
<li>Struct.new can now accept FFI::Buffers. Buffers are like MemoryPointers, but with improved performance on JRuby in some situations.</li>
<li>Struct.new will now create a Buffer instead of a MemoryPointer when you create a new struct instance by value from an array, hash, bytestring, or another struct.</li>
</ul>
<p>Also, since I never posted an announcement for 0.2, here are the changes for that version:</p>
<ul>
<li>Added automatic memory management to the Struct class, if you define a &#8220;release&#8221; class method. It can be disabled per-instance by passing <code>:autorelease => false</code> to MyStruct.new.</li>
<li>Added new OpaqueStruct class. This class is useful for when the struct layout is not declared in the C library header. It also features automatic memory management like Struct.</li>
<li>Added Struct.typed_pointer, as a convenient alternative to <code>TypedPointer.new(MyStruct)</code>. You can also pass <code>:autorelease => false</code> to disable memory management for all structs created via that TypedPointer, which is useful when using the TypedPointer as a function return type.</li>
<li>Structs can now be dumped to a bytestring (<code>Struct#to_bytes</code>), and also created from a bytestring (by passing a String to Struct.new).</li>
<li>Revamped the PathSet class. It now has separate patterns for paths (directories to search) and files (filename patterns), to be more flexible and easy to customize (e.g. you can add a new directory without caring about the filename pattern).</li>
<li>Removed <code>Pathset#&lt;&lt;</code> and <code>Pathset#&gt;&gt;</code>. Use append and prepend instead.</li>
<li>Renamed Library::DEFAULT_PATHS to PathSet::DEFAULT.</li>
<li>Added Library.optional, for when you want to continue loading the library even if a certain function or variable doesn&#8217;t exist in the library (e.g. because it&#8217;s not defined in old versions). It takes a code block, and will rescue and emit a warning if there is a FFI load error.</li>
<li>Also added Library.opt_func, which is the same as doing attach_function within an optional block.</li>
<li>Added some convenience aliases in Library: <code>func</code> = <code>attach_function</code>, <code>var</code> = <code>attach_variable</code>.</li>
<li>Nice-FFI no longer depends on the &#8220;need&#8221; library. We don&#8217;t need no stinking need!</li>
</ul>
<p>You can get Nice-FFI:</p>
<ul>
<li>Via RubyGems: <code>gem install nice-ffi</code></li>
<li>Via Github: <a href="http://github.com/jacius/nice-ffi/">http://github.com/jacius/nice-ffi/</a></li>
<li>As a <a href="http://github.com/jacius/nice-ffi/tarball/master">tarball</a> or <a href="http://github.com/jacius/nice-ffi/zipball/master">zip</a>.</li>
</ul>
<p>Please send bug reports and feature requests to the <a href="http://github.com/jacius/nice-ffi/issues">issue tracker</a> on Github.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jacius.info/2010/01/17/nice-ffi-0-3-and-0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

