<?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>Peter Krantz &#187; Ocaml</title>
	<atom:link href="http://www.peterkrantz.com/category/ocaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peterkrantz.com</link>
	<description>A blog about technology, visualization, music and unmanned vehicle experiments</description>
	<lastBuildDate>Mon, 12 Jul 2010 14:47:03 +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>Hello OpenGL World in Ocaml</title>
		<link>http://www.peterkrantz.com/2008/hello-opengl-world-in-ocaml/</link>
		<comments>http://www.peterkrantz.com/2008/hello-opengl-world-in-ocaml/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 20:12:18 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Ocaml]]></category>
		<category><![CDATA[opengl]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/?p=198</guid>
		<description><![CDATA[I swear, if I read one more programming tutorial that starts with a recursive factorial function instead of a simple &#8220;Hello world&#8221; I&#8217;ll pray for perpetual nigerian spam on their inboxes. So, I was delighted to try out some Ocaml stuff today that didn&#8217;t involve factorials.  Since I like dabbling with data visualization I was [...]]]></description>
			<content:encoded><![CDATA[<p>I swear, if I read one more programming tutorial that starts with a recursive factorial function instead of a simple &#8220;Hello world&#8221; I&#8217;ll pray for perpetual nigerian spam on their inboxes. So, I was delighted to try out some <a href="http://caml.inria.fr/ocaml/index.en.html">Ocaml</a> stuff today that didn&#8217;t involve factorials.  Since I like dabbling with data visualization I was happy to find the following snippet:</p>
<pre> let _ =
   ignore( Glut.init Sys.argv );
   Glut.initDisplayMode ~double_buffer:true ();
   ignore (Glut.createWindow ~title:"OpenGL Demo");
   let angle t = 10. *. t *. t in
   let render () =
     GlClear.clear [ `color ];
     GlMat.load_identity ();
     GlMat.rotate ~angle: (angle (Sys.time ())) ~z:1. ();
     GlDraw.begins `triangles;
     List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];
     GlDraw.ends ();
     Glut.swapBuffers () in
   GlMat.mode `modelview;
   Glut.displayFunc ~cb:render;
   Glut.idleFunc ~cb:(Some Glut.postRedisplay);
   Glut.mainLoop ()</pre>
<p>Simple enough, apparently draws something on an OpenGL display. According to a friend of mine I am supposed to be able to compile ocaml code to a native app. Being on Mac OS X I was sceptical. Native OS X apps usually involves drawing arrows between events and boxes in some funky XCode window.</p>
<p>But, lo and behold:</p>
<p><kbd>sudo port install ocaml</kbd><br />
<kbd>sudo port install LablGL</kbd><br />
<kbd>ocamlopt -I +lablGL lablglut.cmxa lablgl.cmxa ogldemo.ml -o ogldemo</kbd></p>
<p>&#8230;creates an app that opens a window with the spinning triangle on OS X. And compilation is fast! I need to learn more about ocaml&#8230;</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2008%2Fhello-opengl-world-in-ocaml%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2008/hello-opengl-world-in-ocaml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
