Hello OpenGL World in Ocaml
I swear, if I read one more programming tutorial that starts with a recursive factorial function instead of a simple “Hello world” I’ll pray for perpetual nigerian spam on their inboxes. So, I was delighted to try out some Ocaml stuff today that didn’t involve factorials. Since I like dabbling with data visualization I was happy to find the following snippet: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 () 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. ...