From 7bc249599f752ed643758b17237db8e9427941ee Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 30 Sep 2009 15:32:24 +0000 Subject: [PATCH] made startFrame() callable from lua, filled in Engine::setCamera() git-svn-id: svn://anubis/anaglym/trunk@40 99a6e188-d820-4881-8870-2d33a10e2619 --- ag.cc | 1 + anaglym.cc | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ag.cc b/ag.cc index 2e812f8..af322e9 100644 --- a/ag.cc +++ b/ag.cc @@ -26,6 +26,7 @@ namespace ag { "videoStart", videoStart }, { "videoStop", videoStop }, { "sleep", sleep }, + { "startFrame", startFrame }, { "endFrame", endFrame }, { "setCamera", setCamera }, { NULL, NULL } diff --git a/anaglym.cc b/anaglym.cc index 93fd280..257c6ab 100644 --- a/anaglym.cc +++ b/anaglym.cc @@ -180,6 +180,7 @@ Engine::Object * Engine::getObject(int id) int Engine::startFrame(lua_State * L) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(m_eye[0], m_eye[1], m_eye[2], @@ -197,6 +198,36 @@ int Engine::endFrame(lua_State * L) int Engine::setCamera(lua_State * L) { int argc = lua_gettop(L); + + vector args; + for (int i = 1; i <= argc; i++) + { + int type = lua_type(L, i); + if (type == LUA_TNUMBER || type == LUA_TSTRING) + args.push_back(lua_tonumber(L, i)); + else + args.push_back(0); + } + + if (argc >= 3) + { + m_eye[0] = args[0]; + m_eye[1] = args[1]; + m_eye[2] = args[2]; + } + if (argc >= 6) + { + m_center[0] = args[3]; + m_center[1] = args[4]; + m_center[2] = args[5]; + } + if (argc >= 9) + { + m_up[0] = args[6]; + m_up[1] = args[7]; + m_up[2] = args[8]; + } + return 0; }