Author: fperrad
Date: Sun Jul 27 05:43:45 2008
New Revision: 29792

Modified:
   trunk/languages/lua/demo/triangle.lua
   trunk/languages/lua/src/lib/glut.pir

Log:
[Lua] OpenGL, add glut.DestroyWindow()

Modified: trunk/languages/lua/demo/triangle.lua
==============================================================================
--- trunk/languages/lua/demo/triangle.lua       (original)
+++ trunk/languages/lua/demo/triangle.lua       Sun Jul 27 05:43:45 2008
@@ -10,9 +10,6 @@
 require 'glut'
 require 'gl'
 
-rotating = true
-prev_time = os.time()
-
 function Draw ()
     gl.Clear('COLOR_BUFFER_BIT,DEPTH_BUFFER_BIT')
     gl.Begin('TRIANGLES')
@@ -38,14 +35,16 @@
 
 function Keyboard (key)
     if key == 27 or key == 81 or key == 113 then
-       os.exit()
+       glut.DestroyWindow(glut_window)
     end
     rotating = not rotating
 end
 
+rotating = true
+prev_time = os.time()
 glut.Init()
 glut.InitDisplayMode()
-glut.CreateWindow('Test')
+glut_window = glut.CreateWindow('Test')
 glut.DisplayFunc('Draw')
 glut.IdleFunc('Idle')
 glut.KeyboardFunc('Keyboard')

Modified: trunk/languages/lua/src/lib/glut.pir
==============================================================================
--- trunk/languages/lua/src/lib/glut.pir        (original)
+++ trunk/languages/lua/src/lib/glut.pir        Sun Jul 27 05:43:45 2008
@@ -53,6 +53,11 @@
     set $P1, 'CreateWindow'
     _glut[$P1] = _glut_CreateWindow
 
+    .const .Sub _glut_DestroyWindow= 'DestroyWindow'
+    _glut_DestroyWindow.'setfenv'(_lua__GLOBAL)
+    set $P1, 'DestroyWindow'
+    _glut[$P1] = _glut_DestroyWindow
+
     .const .Sub _glut_DisplayFunc= 'DisplayFunc'
     _glut_DisplayFunc.'setfenv'(_lua__GLOBAL)
     set $P1, 'DisplayFunc'
@@ -121,7 +126,28 @@
     lua_error("incorrect argument to function 'glut.CreateWindow'")
   L1:
     $S1 = title
-    glutCreateWindow($S1)
+    $I0 = glutCreateWindow($S1)
+    new $P0, 'LuaNumber'
+    set $P0, $I0
+    .return ($P0)
+.end
+
+
+=item C<glut.DestroyWindow (window)>
+
+not LuaGL
+
+=cut
+
+.sub 'DestroyWindow' :anon
+    .param pmc window :optional
+    .param pmc extra :slurpy
+    $I0 = lua_isnumber(window)
+    if $I0 goto L1
+    lua_error("incorrect argument to function 'glut.DestroyWindow'")
+  L1:
+    $I1 = window
+    glutDestroyWindow($I1)
 .end
 
 

Reply via email to