<?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></description>
	<lastBuildDate>Sat, 04 Feb 2012 09:57:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</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 ...]]></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.<span id="more-198"></span></p>
<p>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>
]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2008/hello-opengl-world-in-ocaml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: www.peterkrantz.com @ 2012-02-04 11:20:35 -->
