<?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>A Party to the World &#187; webgl</title>
	<atom:link href="http://dan.lecocq.us/wordpress/tag/webgl/feed/" rel="self" type="application/rss+xml" />
	<link>http://dan.lecocq.us/wordpress</link>
	<description>Life, love, and computer science</description>
	<lastBuildDate>Sun, 25 Jul 2010 16:20:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The Pains of Nightly Builds</title>
		<link>http://dan.lecocq.us/wordpress/2010/04/24/the-pains-of-nightly-builds/</link>
		<comments>http://dan.lecocq.us/wordpress/2010/04/24/the-pains-of-nightly-builds/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 06:24:19 +0000</pubDate>
		<dc:creator>dan.lecocq</dc:creator>
				<category><![CDATA[computer science]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[floating point textures]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://dan.lecocq.us/wordpress/?p=823</guid>
		<description><![CDATA[I&#8217;ve been working with WebKit a lot lately. Specifically, WebGL. It&#8217;s fantastic, and it has the potential to change a lot of important applications, but working with nightly builds is&#8230; well, frustrating. I&#8217;ve been using a revision released in December. Some later revisions have weird behaviors and draw pixelated, but I&#8217;ve finally come across a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with WebKit a lot lately.  Specifically, WebGL.  It&#8217;s fantastic, and it has the potential to change a lot of important applications, but working with nightly builds is&#8230; well, frustrating.</p>
<p>I&#8217;ve been using a revision released in December.  Some later revisions have weird behaviors and draw pixelated, but I&#8217;ve finally come across a problem with r52426 that I just can&#8217;t circumvent &#8211; floating-point textures.  They just don&#8217;t seem to work properly.  I had noticed the bug before, but it wasn&#8217;t absolutely crucial before.  Rather, the real bug is that you can&#8217;t initialize floating-point textures from the JavaScript side.</p>
<p>They&#8217;ve fixed this in later versions, but many of these that have this bug fixed also have a problem with gl.viewport, which is pretty mission-critical.  So now I&#8217;m sifting through the changelog, hoping to find a release somewhere in the middle that isn&#8217;t completely broken.</p>
<p><strong>Update:</strong> Victory! If you&#8217;re going to be developing WebGL stuff on Mac, I&#8217;d recommend WebKit r53036.  It seems to have everything I need (so far) fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.lecocq.us/wordpress/2010/04/24/the-pains-of-nightly-builds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Triangle Strip for Grids &#8211; A Construction</title>
		<link>http://dan.lecocq.us/wordpress/2009/12/25/triangle-strip-for-grids-a-construction/</link>
		<comments>http://dan.lecocq.us/wordpress/2009/12/25/triangle-strip-for-grids-a-construction/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 09:02:36 +0000</pubDate>
		<dc:creator>dan.lecocq</dc:creator>
				<category><![CDATA[computer science]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[mesh]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[triangle strip]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://dan.lecocq.us/wordpress/?p=791</guid>
		<description><![CDATA[I&#8217;m working with WebGL and as such, I&#8217;m discovering some quirks about OpenGL ES 2.0. I have been using display lists as long as I&#8217;ve been using OpenGL, but WebGL doesn&#8217;t have support for them. So, I&#8217;m buckled down and familiarized myself with vertex buffer objects, the (perhaps better) alternative. At any rate, I need [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working with WebGL and as such, I&#8217;m discovering some quirks about OpenGL ES 2.0.  I have been using display lists as long as I&#8217;ve been using OpenGL, but WebGL doesn&#8217;t have support for them.  So, I&#8217;m buckled down and familiarized myself with vertex buffer objects, the (perhaps better) alternative.</p>
<p>At any rate, I need to render a regular 2D grid, and as it doesn&#8217;t support quads, either, I was forced to use triangles.  In the interest of getting things running, I just provided a wasteful list of discrete triangles.  This is wasteful because it references many more vertices than necessary &#8211; I ended up declaring <img src="http://dan.lecocq.us/wordpress/wp-content/cache/tex_7c692719ce1b4ecd3a0f6128b07e30d4.png" align="absmiddle" class="tex" alt="6n^2" /> vertices when in reality there are only <img src="http://dan.lecocq.us/wordpress/wp-content/cache/tex_86dbfdfcc50f616505123d87957ce5cb.png" align="absmiddle" class="tex" alt="n^2 + n + 1" /> unique vertices.  This worked fine, until I wanted to increase the resolution.  It turns out, JavaScript doesn&#8217;t like large arrays.</p>
<p>That&#8217;s fair, because the implementation was pretty wasteful.  A triangle strip was the best choice anyway.  <strong><em>A triangle strip is a highly compact form of representing a mesh.  For <img src="http://dan.lecocq.us/wordpress/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> triangles, it requires only <img src="http://dan.lecocq.us/wordpress/wp-content/cache/tex_ee380f3087822767aa0e74ac2bfc631b.png" align="absmiddle" class="tex" alt="n + 2" /> vertices defined.</em></strong>  Well, that&#8217;s roughly true.  We&#8217;ll see another case in a minute.  It&#8217;s useful when many triangles share vertices, and perhaps I&#8217;ll let <a href="http://en.wikipedia.org/wiki/Triangle_strip" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/Triangle_strip?referer=');">Wikipedia&#8217;s explanation</a> stand.</p>
<p>It wasn&#8217;t immediately obvious how to define a grid out of a single triangle strip and so I got out a pen and paper.  I kept in mind a neat trick: <strong><em>if in a triangle strip, you need to skip the use of a vertex, a vertex can be introduced twice in a row.</em></strong>  That is, if I need triangles (6, 3, 7) and (7, 11, 6) in that order, you can just make your strip with 6, 3, 7, 7, 11, 6.  You can think of it as if there are two triangles created (3, 7, 7) and (7, 7, 11), but they have no area and a degenerate case &#8211; a line.  Furthermore, these lines lie on triangles already defined.</p>
<p>Perhaps the obvious choice doesn&#8217;t yield any results, and in fact in this layout, it can&#8217;t be easily done (you have to have vertices appear three times in a row):</p>
<div id="attachment_792" class="wp-caption aligncenter" style="width: 217px"><a href="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_bad.png"><img src="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_bad.png" alt="" title="mesh_bad" width="207" height="193" class="size-full wp-image-792" /></a><p class="wp-caption-text">This is a bad idea for a topology if you want to use a single triangle strip.</p></div>
<p>To better convince yourself, try to come up with a good way to put this in a triangle strip.  I&#8217;ll make the case that it is pretty difficult with a claim from graph theory.  In order for a triangle mesh to be turned into a triangle strip, each consecutive triangle must share an edge.  We can then think of the mesh as a connectivity graph (the <a href="http://en.wikipedia.org/wiki/Dual_graph" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/Dual_graph?referer=');">dual</a> of the mesh) and then the problem will emerge more clearly:</p>
<div id="attachment_794" class="wp-caption aligncenter" style="width: 217px"><a href="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_bad_dual.png"><img src="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_bad_dual.png" alt="" title="mesh_bad_dual" width="207" height="193" class="size-full wp-image-794" /></a><p class="wp-caption-text">The dual graph of the bad idea.</p></div>
<p>To make the triangle strip &#8220;nice,&#8221; we ought to be able to visit each node once and exactly once.  There&#8217;s good and bad news in this &#8211; it&#8217;s the same problem as finding a <a href="http://en.wikipedia.org/wiki/Hamiltonian_path" onclick="urchinTracker('/outgoing/en.wikipedia.org/wiki/Hamiltonian_path?referer=');">Hamlitonian path</a> which is NP complete.  The good news is that if we find a solution to our small problem, we&#8217;ve found a solution to all such grids (with arbitrarily many triangles).  Note that we don&#8217;t need an Eulerian path.</p>
<p>If you stare long enough at the above connectivity graph, you&#8217;ll hopefully convince yourself that there&#8217;s no way to traverse it visiting each node once and exactly once.  Go ahead and try &#8211; it&#8217;s pretty infuriating.</p>
<p>Looking at how we would traverse one strip (triangles a, b, c, d, e and f) actually gives us a clue.  A triangular strip for that case would be 0, 4, 1, 5, 2, 6, 3, 7, and happiness ensues and we should move onto the next row.  Unfortunately, in the context of this new row, we&#8217;re starting in a different place (topologically) than we started with the first strip.  Vertex 0 has two connected neighbors in its row &#8211; 1 and 4.  Vertex 7 has three in its row: 6, 10 and 11.  It turns out we can change up the topology to remedy this simply:</p>
<div id="attachment_795" class="wp-caption aligncenter" style="width: 217px"><a href="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_good.png"><img src="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_good.png" alt="A much better topology for drawing this with a single triangle strip." title="mesh_good" width="207" height="193" class="size-full wp-image-795" /></a><p class="wp-caption-text">A much better topology for drawing this with a single triangle strip.</p></div>
<p>We can also see that this is a much better solution by looking at this new graph&#8217;s dual:</p>
<div id="attachment_796" class="wp-caption aligncenter" style="width: 217px"><a href="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_good_dual.png"><img src="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/mesh_good_dual.png" alt="" title="mesh_good_dual" width="207" height="193" class="size-full wp-image-796" /></a><p class="wp-caption-text">The dual of the better topological choice.</p></div>
<p>You can probably easily find a Hamlitonian path in this case.  But this still leaves us with how to determine the vertex orderings.  We decided that the first row ought to be 0, 4, 1, 5, 2, 6, 3, 7, but moving on from there we need a bit of &#8220;glue&#8221; to move onto the next row.  We insert 7 again, and then continue on from there: 7, 11, 6, 10, 5, 9, 4, 8.  A bit more glue for the third row: 8, 12, 9, 13, 10, 14, 11, and 15:</p>
<div id="attachment_797" class="wp-caption aligncenter" style="width: 261px"><a href="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/strip.png"><img src="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/strip.png" alt="" title="strip" width="251" height="193" class="size-full wp-image-797" /></a><p class="wp-caption-text">An alternative representation of the vertex ordering</p></div>
<p>Looking at the indices from the first row, starting at 0, we can get the next index by alternately adding 4 and then subtracting 3.  On the next row, we&#8217;ll continue to add 4, but then alternately subtract 5.  The 4 is derived as being the number of vertices on a side (if there are <img src="http://dan.lecocq.us/wordpress/wp-content/cache/tex_7b8b965ad4bca0e41ab51de7b31363a1.png" align="absmiddle" class="tex" alt="n" /> divisions, then there are <img src="http://dan.lecocq.us/wordpress/wp-content/cache/tex_40b85027598d87611b1c8d5d11e46812.png" align="absmiddle" class="tex" alt="n+1" /> vertices), and the 3 and 5 are explained by the fact that we need to change columns in the mesh, by one step at a time.</p>
<p>An clean implementation is not trivial, but not extremely difficult.  In terms of results, I can fit more than 4 times as many vertices into the mesh than with a per-triangle implementation.  And to boot, it has cut the work of the vertex shader a great deal.</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.lecocq.us/wordpress/2009/12/25/triangle-strip-for-grids-a-construction/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>webGLot &#8211; A Preview</title>
		<link>http://dan.lecocq.us/wordpress/2009/12/24/webglot-a-preview/</link>
		<comments>http://dan.lecocq.us/wordpress/2009/12/24/webglot-a-preview/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 12:14:40 +0000</pubDate>
		<dc:creator>dan.lecocq</dc:creator>
				<category><![CDATA[computer science]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[openglot]]></category>
		<category><![CDATA[plotting]]></category>
		<category><![CDATA[webgl]]></category>
		<category><![CDATA[webglot]]></category>

		<guid isPermaLink="false">http://dan.lecocq.us/wordpress/?p=787</guid>
		<description><![CDATA[I&#8217;ve mentioned WebGL before, and I think it could be very important. There is a competitor from Google, but like OpenGL and OpenCL, this API is managed by the Khronos Group and that fact appeals to me. Perhaps it&#8217;s that I&#8217;ve used it fairly extensively, but I really like OpenGL. Despite its quirks, it&#8217;s quite [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve <a href="http://dan.lecocq.us/wordpress/2009/09/22/the-future-of-the-internet/">mentioned WebGL before</a>, and I think it could be very important.  There is a <a href="http://code.google.com/apis/o3d/" onclick="urchinTracker('/outgoing/code.google.com/apis/o3d/?referer=');">competitor from Google</a>, but like OpenGL and OpenCL, this API is managed by the <a href="http://www.khronos.org/" onclick="urchinTracker('/outgoing/www.khronos.org/?referer=');">Khronos Group</a> and that fact appeals to me.  Perhaps it&#8217;s that I&#8217;ve used it fairly extensively, but I really like OpenGL.  Despite its quirks, it&#8217;s quite powerful.</p>
<p>The big &#8220;get&#8221; is that it gives programmers access to hardware-accelerated graphics from directly within the browser.  There&#8217;s a lot of interest in this arena for game development as it would obviate much of the need for separate distributions based on operating system.  (Skip to the end for more of an opinion on this subject.)</p>
<p>As such, I&#8217;ve been working with WebGL as opposed to the Google-proposed O3D.  (I have every intention to explore O3D, time permitting, as there are some jagged edges to the current specification.)  The result of this recent toil is a budding WebGL implementation of my OpenGLot project.  It&#8217;s still in early stages, but in the coming weeks, it should develop even further.  To whet appetites, I have a few pictures.</p>
<div id="attachment_788" class="wp-caption aligncenter" style="width: 310px"><a href="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/Picture-105.png"><img src="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/Picture-105-300x182.png" alt="A scalar field, my persistent test function." title="Picture 105" width="300" height="182" class="size-medium wp-image-788" /></a><p class="wp-caption-text">A scalar field, my persistent test function.</p></div>
<div id="attachment_789" class="wp-caption aligncenter" style="width: 310px"><a href="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/Picture-111.png"><img src="http://dan.lecocq.us/wordpress/wp-content/uploads/2009/12/Picture-111-300x215.png" alt="A 3D surface, again one of my usual test functions." title="Picture 111" width="300" height="215" class="size-medium wp-image-789" /></a><p class="wp-caption-text">A 3D surface, again one of my usual test functions.</p></div>
<p>I seriously doubt that WebGL will every match the performance of OpenGL.  Even though JavaScript interpreters are getting faster at a somewhat alarming rate, they won&#8217;t match the speed of C or C++.  That said, if one can appropriately offload work onto the GPU, it won&#8217;t matter as much, but there will always be that overhead.</p>
<p>It won&#8217;t so much be a matter of having the same performance, but <em>enough</em> performance.  If a person can go to a single webpage and get 60 frames per second performance in a game or tool without having to install software, that&#8217;s tremendous.  Currently I&#8217;ve been getting between 60 and 90 frames per second with WebGLot, and I&#8217;m sure I can keep that number up as more features are added.</p>
<p>My hope is that this will be a tool and library that has a wide-enough feature set by the time WebGL is widely adopted that becomes often-used.  But that&#8217;s just ego.  The purer motivation is that if you&#8217;re a math teacher, and you want to have interactive demonstrations of Newton&#8217;s method, or parametric surfaces, or even flow fields, you can write an application in 20 minutes that does all the heavy lifting of graphing it for you.  As long as you can describe the mathematical primitives, you should be able to render it.  Of course there will be a general-purpose grapher available for any calculus student who&#8217;s having trouble visualizing this or that, too.  Or a resourceful PDE student who need to solve his homework (the GPU-based PDE solver will take a little bit more time, but it&#8217;s very nearly complete).</p>
<p>In short, the strength of WebGL is that is has respectable performance, and in a year&#8217;s time, half the browsers (well maybe not half) on computers will support it, giving the average internet-user access to a wealth of media.</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.lecocq.us/wordpress/2009/12/24/webglot-a-preview/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The Future of the Internet</title>
		<link>http://dan.lecocq.us/wordpress/2009/09/22/the-future-of-the-internet/</link>
		<comments>http://dan.lecocq.us/wordpress/2009/09/22/the-future-of-the-internet/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 15:38:50 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[computer science]]></category>
		<category><![CDATA[future]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[webgl]]></category>

		<guid isPermaLink="false">http://dan.lecocq.us/wordpress/?p=581</guid>
		<description><![CDATA[In the far-off year of 2009, there will be a series of tubes that connects people over great distances at tremendous speeds. You&#8217;ll interact with it with a browser &#8211; a veritable portal to the world. And it will be able to render 3D graphics efficiently. WebGL is the future of the internet. I&#8217;ve been [...]]]></description>
			<content:encoded><![CDATA[<p>In the far-off year of 2009, there will be a series of tubes that connects people over great distances at tremendous speeds.  You&#8217;ll interact with it with a browser &#8211; a veritable portal to the world.  And it will be able to render 3D graphics efficiently.</p>
<p>WebGL is the future of the internet.  I&#8217;ve been hoping for something like this to come out for a while, and in Firefox&#8217;s latest nightly builds, it&#8217;s included.  You should read more about it <a href="http://blog.vlad1.com/2009/09/18/webgl-in-firefox-nightly-builds/" onclick="urchinTracker('/outgoing/blog.vlad1.com/2009/09/18/webgl-in-firefox-nightly-builds/?referer=');">straight from the horse&#8217;s mouth</a>, but this is going to be amazing.</p>
<p>I love OpenGL, and to have a framework from which to call these commands I know and love for the web will be fantastic.  No need to worry about system requirements beyond whether or not WebKit runs on your computer&#8230; no need to download the latest versions of some piece of software&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.lecocq.us/wordpress/2009/09/22/the-future-of-the-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
