summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/LuaGL.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/LuaGL.cc b/lib/LuaGL.cc
index 19eb0b2..375be99 100644
--- a/lib/LuaGL.cc
+++ b/lib/LuaGL.cc
@@ -4544,6 +4544,42 @@ static int gl_viewport(lua_State *L)
return 0;
}
+/*LookAt (eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ ) -> none*/
+static int gl_lookat(lua_State *L)
+{
+ /* test arguments type */
+ if(!( lua_isnumber(L, 1) && lua_isnumber(L, 2) &&
+ lua_isnumber(L, 3) && lua_isnumber(L, 4) &&
+ lua_isnumber(L, 5) && lua_isnumber(L, 6) &&
+ lua_isnumber(L, 7) && lua_isnumber(L, 8) &&
+ lua_isnumber(L, 9) ))
+ luaL_error(L, "incorrect argument to function 'gl.LookAt'");
+
+ /* call openGL function */
+ gluLookAt((GLdouble)lua_tonumber(L, 1), (GLdouble)lua_tonumber(L, 2),
+ (GLdouble)lua_tonumber(L, 3), (GLdouble)lua_tonumber(L, 4),
+ (GLdouble)lua_tonumber(L, 5), (GLdouble)lua_tonumber(L, 6),
+ (GLdouble)lua_tonumber(L, 7), (GLdouble)lua_tonumber(L, 8),
+ (GLdouble)lua_tonumber(L, 9));
+
+ return 0;
+}
+
+/*Perspective (eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ ) -> none*/
+static int gl_perspective(lua_State *L)
+{
+ /* test arguments type */
+ if(!( lua_isnumber(L, 1) && lua_isnumber(L, 2) &&
+ lua_isnumber(L, 3) && lua_isnumber(L, 4) ))
+ luaL_error(L, "incorrect argument to function 'gl.Perspective'");
+
+ /* call openGL function */
+ gluPerspective((GLdouble)lua_tonumber(L, 1), (GLdouble)lua_tonumber(L, 2),
+ (GLdouble)lua_tonumber(L, 3), (GLdouble)lua_tonumber(L, 4));
+
+ return 0;
+}
+
static const luaL_reg gllib[] = {
{"Accum", gl_accum},
{"AlphaFunc", gl_alpha_func},
@@ -4683,6 +4719,8 @@ static const luaL_reg gllib[] = {
{"Vertex", gl_vertex},
{"VertexPointer", gl_vertex_pointer},
{"Viewport", gl_viewport},
+ {"LookAt", gl_lookat},
+ {"Perspective", gl_perspective},
{NULL, NULL}
};