moved startFrame(), endFrame() and setCamera() into Engine
git-svn-id: svn://anubis/anaglym/trunk@39 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
4bca35ee69
commit
a1c8736488
14
ag.cc
14
ag.cc
@ -27,6 +27,7 @@ namespace ag
|
||||
{ "videoStop", videoStop },
|
||||
{ "sleep", sleep },
|
||||
{ "endFrame", endFrame },
|
||||
{ "setCamera", setCamera },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
luaL_register(L, "ag", functions);
|
||||
@ -171,10 +172,19 @@ namespace ag
|
||||
return 0;
|
||||
}
|
||||
|
||||
int startFrame(lua_State * L)
|
||||
{
|
||||
return g_engine->startFrame(L);
|
||||
}
|
||||
|
||||
int endFrame(lua_State * L)
|
||||
{
|
||||
SDL_GL_SwapBuffers();
|
||||
return 0;
|
||||
return g_engine->endFrame(L);
|
||||
}
|
||||
|
||||
int setCamera(lua_State * L)
|
||||
{
|
||||
return g_engine->setCamera(L);
|
||||
}
|
||||
|
||||
namespace object
|
||||
|
2
ag.h
2
ag.h
@ -13,7 +13,9 @@ namespace ag
|
||||
int videoStart(lua_State * L);
|
||||
int videoStop(lua_State * L);
|
||||
int sleep(lua_State * L);
|
||||
int startFrame(lua_State * L);
|
||||
int endFrame(lua_State * L);
|
||||
int setCamera(lua_State * L);
|
||||
|
||||
namespace object
|
||||
{
|
||||
|
33
anaglym.cc
33
anaglym.cc
@ -9,6 +9,8 @@
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
using namespace std;
|
||||
|
||||
static void usage();
|
||||
@ -61,6 +63,15 @@ Engine::Engine()
|
||||
{
|
||||
m_video = new Video();
|
||||
m_next_object_index = 1;
|
||||
m_eye[0] = 0;
|
||||
m_eye[1] = -1;
|
||||
m_eye[2] = 0;
|
||||
m_center[0] = 0;
|
||||
m_center[1] = 0;
|
||||
m_center[2] = 0;
|
||||
m_up[0] = 0;
|
||||
m_up[1] = 0;
|
||||
m_up[2] = 1;
|
||||
}
|
||||
|
||||
Engine::~Engine()
|
||||
@ -167,6 +178,28 @@ Engine::Object * Engine::getObject(int id)
|
||||
return m_objects.find(id) != m_objects.end() ? m_objects[id] : NULL;
|
||||
}
|
||||
|
||||
int Engine::startFrame(lua_State * L)
|
||||
{
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(m_eye[0], m_eye[1], m_eye[2],
|
||||
m_center[0], m_center[1], m_center[2],
|
||||
m_up[0], m_up[1], m_up[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Engine::endFrame(lua_State * L)
|
||||
{
|
||||
SDL_GL_SwapBuffers();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Engine::setCamera(lua_State * L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Engine::run()
|
||||
{
|
||||
}
|
||||
|
@ -38,6 +38,11 @@ class Engine
|
||||
int addObject(WFObj * obj);
|
||||
Object * getObject(int id);
|
||||
|
||||
/* lua services */
|
||||
int startFrame(lua_State * L);
|
||||
int endFrame(lua_State * L);
|
||||
int setCamera(lua_State * L);
|
||||
|
||||
protected:
|
||||
void registerLibraries();
|
||||
bool fileExists(const std::string & path);
|
||||
@ -48,6 +53,9 @@ class Engine
|
||||
OdeWorld m_world;
|
||||
std::map<int, Object *> m_objects;
|
||||
int m_next_object_index;
|
||||
GLdouble m_eye[3];
|
||||
GLdouble m_center[3];
|
||||
GLdouble m_up[3];
|
||||
};
|
||||
|
||||
extern Engine * g_engine;
|
||||
|
Loading…
x
Reference in New Issue
Block a user