Author: fperrad
Date: Sat Jul 26 13:46:50 2008
New Revision: 29772

Added:
   trunk/languages/lua/demo/
   trunk/languages/lua/demo/triangle.lua   (contents, props changed)
Modified:
   trunk/MANIFEST

Log:
[Lua] triangle.lua, an OpenGL demo

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Sat Jul 26 13:46:50 2008
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sat Jul 26 16:04:22 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sat Jul 26 17:14:04 2008 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -1610,6 +1610,7 @@
 languages/lolcode/t/harness                                 [lolcode]
 languages/lua/MAINTAINER                                    [lua]
 languages/lua/config/makefiles/root.in                      [lua]
+languages/lua/demo/triangle.lua                             [lua]
 languages/lua/doc/lua51.bnf                                 [lua]
 languages/lua/doc/lua51.y                                   [lua]
 languages/lua/doc/running.pod                               [lua]

Added: trunk/languages/lua/demo/triangle.lua
==============================================================================
--- (empty file)
+++ trunk/languages/lua/demo/triangle.lua       Sat Jul 26 13:46:50 2008
@@ -0,0 +1,53 @@
+
+--[[
+
+  triangle.lua - Initialize GLUT and render a simple OpenGL animation
+
+]]
+
+require 'glut'
+require 'gl'
+
+rotating = true
+prev_time = os.time()
+
+function Draw ()
+    gl.Clear('COLOR_BUFFER_BIT,DEPTH_BUFFER_BIT')
+    gl.Begin('TRIANGLE')
+    gl.Color( {1, 0, 0} )
+    gl.Vertex( {-0.5, -0.5, 0} )
+    gl.Color( {0, 1, 0} )
+    gl.Vertex( {0.5, -0.5, 0} )
+    gl.Color( {0, 0, 1} )
+    gl.Vertex( {0, 0.5, 0} )
+    gl.End()
+    glut.SwapBuffer()
+end
+
+function Idle ()
+    now = os.time()
+    dt = (now - prev_time) * 360
+    prev_time = now
+    if rotating then
+        gl.Rotate(dt, 0, 1, 0)
+       glut.PostRedisplay()
+    end
+end
+
+function Keyboard (key)
+    print(key)
+    if key == 27 or key == 81 or key == 113 then
+       os.exit()
+    end
+    rotating = not rotating
+end
+
+glut.Init()
+glut.InitDisplayMode()
+glut.CreateWindow('Test')
+glut.DisplayFunc('Draw')
+glut.IdleFunc('Idle')
+glut.KeyboardFunc('Keyboard')
+
+glut.MainLoop()
+

Reply via email to