added ag::drawObjects() to draw all objects in the scene from a lua script
git-svn-id: svn://anubis/anaglym/trunk@65 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
2107a67d08
commit
bd2d3d8b25
7
ag.cc
7
ag.cc
@ -30,6 +30,7 @@ namespace ag
|
||||
{ "setCamera", setCamera },
|
||||
{ "elapsedTime", elapsedTime },
|
||||
{ "doPhysics", doPhysics },
|
||||
{ "drawObjects", drawObjects },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
luaL_register(L, "ag", functions);
|
||||
@ -214,6 +215,12 @@ namespace ag
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drawObjects(lua_State * L)
|
||||
{
|
||||
g_engine->drawObjects();
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace object
|
||||
{
|
||||
static Engine::Object * getObject(lua_State * L, int index)
|
||||
|
1
ag.h
1
ag.h
@ -17,6 +17,7 @@ namespace ag
|
||||
int setCamera(lua_State * L);
|
||||
int elapsedTime(lua_State * L);
|
||||
int doPhysics(lua_State * L);
|
||||
int drawObjects(lua_State * L);
|
||||
|
||||
namespace object
|
||||
{
|
||||
|
@ -334,6 +334,15 @@ void Engine::doPhysics()
|
||||
last_updated = current_ticks;
|
||||
}
|
||||
|
||||
void Engine::drawObjects()
|
||||
{
|
||||
std::map<int, Object *>::iterator it;
|
||||
for (it = m_objects.begin(); it != m_objects.end(); it++)
|
||||
{
|
||||
it->second->draw();
|
||||
}
|
||||
}
|
||||
|
||||
Engine::Object::Object(const Engine::Object & orig)
|
||||
{
|
||||
m_display_list = orig.m_display_list;
|
||||
|
@ -61,6 +61,7 @@ class Engine
|
||||
int cloneObject(const Object * obj);
|
||||
Object * getObject(int id);
|
||||
void doPhysics();
|
||||
void drawObjects();
|
||||
|
||||
/* lua services */
|
||||
int startFrame(lua_State * L);
|
||||
|
@ -4,11 +4,7 @@ function update()
|
||||
ag.setCamera(7, -6, 15, ballx, bally, ballz, 0, 0, 1)
|
||||
ag.doPhysics()
|
||||
ag.startFrame()
|
||||
arena:draw()
|
||||
ball:draw()
|
||||
ball2:draw()
|
||||
ball3:draw()
|
||||
logo:draw()
|
||||
ag.drawObjects()
|
||||
ag.endFrame()
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user