reworked startFrame() and endFrame()
git-svn-id: svn://anubis/anaglym/trunk@81 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
59818a253d
commit
b9a4ce22ed
10
Engine.cc
10
Engine.cc
@ -159,7 +159,7 @@ Engine::Object * Engine::getObject(int id)
|
|||||||
return m_objects.find(id) != m_objects.end() ? m_objects[id] : NULL;
|
return m_objects.find(id) != m_objects.end() ? m_objects[id] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::startFrame(lua_State * L)
|
void Engine::startFrame()
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
@ -167,13 +167,6 @@ int Engine::startFrame(lua_State * L)
|
|||||||
gluLookAt(m_eye[0], m_eye[1], m_eye[2],
|
gluLookAt(m_eye[0], m_eye[1], m_eye[2],
|
||||||
m_center[0], m_center[1], m_center[2],
|
m_center[0], m_center[1], m_center[2],
|
||||||
m_up[0], m_up[1], m_up[2]);
|
m_up[0], m_up[1], m_up[2]);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Engine::endFrame(lua_State * L)
|
|
||||||
{
|
|
||||||
/* TODO: figure out how to SDL_GL_SwapBuffers(); */
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::setCamera(lua_State * L)
|
int Engine::setCamera(lua_State * L)
|
||||||
@ -214,6 +207,7 @@ int Engine::setCamera(lua_State * L)
|
|||||||
|
|
||||||
void Engine::update()
|
void Engine::update()
|
||||||
{
|
{
|
||||||
|
startFrame();
|
||||||
if (m_autoPhysics)
|
if (m_autoPhysics)
|
||||||
doPhysics();
|
doPhysics();
|
||||||
lua_getfield(m_luaState, LUA_GLOBALSINDEX, "update");
|
lua_getfield(m_luaState, LUA_GLOBALSINDEX, "update");
|
||||||
|
3
Engine.h
3
Engine.h
@ -63,8 +63,6 @@ class Engine
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
/* lua services */
|
/* lua services */
|
||||||
int startFrame(lua_State * L);
|
|
||||||
int endFrame(lua_State * L);
|
|
||||||
int setCamera(lua_State * L);
|
int setCamera(lua_State * L);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -75,6 +73,7 @@ class Engine
|
|||||||
{
|
{
|
||||||
return new Object(is_static, m_world, display_list, scale);
|
return new Object(is_static, m_world, display_list, scale);
|
||||||
}
|
}
|
||||||
|
void startFrame();
|
||||||
|
|
||||||
lua_State * m_luaState;
|
lua_State * m_luaState;
|
||||||
std::string m_program_path;
|
std::string m_program_path;
|
||||||
|
12
ag.cc
12
ag.cc
@ -26,8 +26,6 @@ namespace ag
|
|||||||
{ "loadModel", loadModel },
|
{ "loadModel", loadModel },
|
||||||
{ "loadStaticModel", loadStaticModel },
|
{ "loadStaticModel", loadStaticModel },
|
||||||
{ "sleep", sleep },
|
{ "sleep", sleep },
|
||||||
{ "startFrame", startFrame },
|
|
||||||
{ "endFrame", endFrame },
|
|
||||||
{ "setCamera", setCamera },
|
{ "setCamera", setCamera },
|
||||||
{ "elapsedTime", elapsedTime },
|
{ "elapsedTime", elapsedTime },
|
||||||
{ "doPhysics", doPhysics },
|
{ "doPhysics", doPhysics },
|
||||||
@ -199,16 +197,6 @@ namespace ag
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int startFrame(lua_State * L)
|
|
||||||
{
|
|
||||||
return g_engine->startFrame(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
int endFrame(lua_State * L)
|
|
||||||
{
|
|
||||||
return g_engine->endFrame(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
int setCamera(lua_State * L)
|
int setCamera(lua_State * L)
|
||||||
{
|
{
|
||||||
return g_engine->setCamera(L);
|
return g_engine->setCamera(L);
|
||||||
|
2
ag.h
2
ag.h
@ -12,8 +12,6 @@ namespace ag
|
|||||||
int loadModel(lua_State * L);
|
int loadModel(lua_State * L);
|
||||||
int loadStaticModel(lua_State * L);
|
int loadStaticModel(lua_State * L);
|
||||||
int sleep(lua_State * L);
|
int sleep(lua_State * L);
|
||||||
int startFrame(lua_State * L);
|
|
||||||
int endFrame(lua_State * L);
|
|
||||||
int setCamera(lua_State * L);
|
int setCamera(lua_State * L);
|
||||||
int elapsedTime(lua_State * L);
|
int elapsedTime(lua_State * L);
|
||||||
int doPhysics(lua_State * L);
|
int doPhysics(lua_State * L);
|
||||||
|
@ -167,6 +167,8 @@ static void mainloop()
|
|||||||
goto RET;
|
goto RET;
|
||||||
break;
|
break;
|
||||||
case SDL_USEREVENT:
|
case SDL_USEREVENT:
|
||||||
|
if (lastUpdateCompleted)
|
||||||
|
SDL_GL_SwapBuffers();
|
||||||
if (event.user.code == 0)
|
if (event.user.code == 0)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user