Author: fperrad
Date: Sun Jul 27 02:05:37 2008
New Revision: 29791

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

Log:
[Lua] OpenGL, fix demo

Modified: trunk/languages/lua/demo/triangle.lua
==============================================================================
--- trunk/languages/lua/demo/triangle.lua       (original)
+++ trunk/languages/lua/demo/triangle.lua       Sun Jul 27 02:05:37 2008
@@ -15,7 +15,7 @@
 
 function Draw ()
     gl.Clear('COLOR_BUFFER_BIT,DEPTH_BUFFER_BIT')
-    gl.Begin('TRIANGLE')
+    gl.Begin('TRIANGLES')
     gl.Color( {1, 0, 0} )
     gl.Vertex( {-0.5, -0.5, 0} )
     gl.Color( {0, 1, 0} )
@@ -23,21 +23,20 @@
     gl.Color( {0, 0, 1} )
     gl.Vertex( {0, 0.5, 0} )
     gl.End()
-    glut.SwapBuffer()
+    glut.SwapBuffers()
 end
 
 function Idle ()
-    now = os.time()
-    dt = (now - prev_time) * 360
+    now = os.time() -- unit is second
+    dt = now - prev_time
     prev_time = now
-    if rotating then
-        gl.Rotate(dt, 0, 1, 0)
+    if rotating and dt ~= 0 then
+        gl.Rotate(10*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

Modified: trunk/languages/lua/src/lib/gl.pir
==============================================================================
--- trunk/languages/lua/src/lib/gl.pir  (original)
+++ trunk/languages/lua/src/lib/gl.pir  Sun Jul 27 02:05:37 2008
@@ -2926,13 +2926,33 @@
 .end
 
 
-=item C<gl.Rotate ()>
+=item C<gl.Rotate (angle, x, y, z))>
 
 =cut
 
 .sub 'Rotate' :anon
+    .param pmc angle :optional
+    .param pmc x :optional
+    .param pmc y :optional
+    .param pmc z :optional
     .param pmc extra :slurpy
-    not_implemented()
+    $I0 = lua_isnumber(angle)
+    unless $I0 goto L1
+    $I0 = lua_isnumber(x)
+    unless $I0 goto L1
+    $I0 = lua_isnumber(y)
+    unless $I0 goto L1
+    $I0 = lua_isnumber(z)
+    unless $I0 goto L1
+    goto L2
+  L1:
+    lua_error("incorrect argument to function 'gl.Rotate'")
+  L2:
+    $N1 = angle
+    $N2 = x
+    $N3 = y
+    $N4 = z
+    glRotated($N1, $N2, $N3, $N4)
 .end
 
 
@@ -3133,7 +3153,7 @@
     $P1 = vararg[0]
     $I0 = lua_istable($P1)
     unless $I0 goto L2
-    (num_args, $P0) = get_arrayd($P1)
+    (num_args, $P0) = get_arrayf($P1)
     goto L3
   L2:
     unless num_args < 2 goto L4

Reply via email to