added ag::videoStart() and ag::videoStop()
git-svn-id: svn://anubis/anaglym/trunk@20 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
c99b3308b6
commit
5fac9f133b
21
Video.cc
21
Video.cc
@ -30,16 +30,19 @@ Video::Video()
|
||||
|
||||
void Video::start(int width, int height, bool fullscreen)
|
||||
{
|
||||
if (width == 0)
|
||||
width = m_defaultWidth;
|
||||
if (height == 0)
|
||||
height = m_defaultHeight;
|
||||
int flags = SDL_HWSURFACE | SDL_OPENGL;
|
||||
if (fullscreen)
|
||||
flags |= SDL_FULLSCREEN;
|
||||
if (m_surface == NULL)
|
||||
{
|
||||
if (width == 0)
|
||||
width = m_defaultWidth;
|
||||
if (height == 0)
|
||||
height = m_defaultHeight;
|
||||
int flags = SDL_HWSURFACE | SDL_OPENGL;
|
||||
if (fullscreen)
|
||||
flags |= SDL_FULLSCREEN;
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
m_surface = SDL_SetVideoMode(width, height, 32, flags);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
m_surface = SDL_SetVideoMode(width, height, 32, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void Video::stop()
|
||||
|
13
ag.cc
13
ag.cc
@ -1,6 +1,7 @@
|
||||
|
||||
#include "anaglym.h"
|
||||
#include "ag.h"
|
||||
#include "Video.h"
|
||||
#include "wfobj/WFObj.hh"
|
||||
#include <lua.hpp>
|
||||
#include <iostream>
|
||||
@ -15,6 +16,8 @@ namespace ag
|
||||
{ "print", print },
|
||||
{ "println", println },
|
||||
{ "loadModel", loadModel },
|
||||
{ "videoStart", videoStart },
|
||||
{ "videoStop", videoStop },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
luaL_register(L, "ag", functions);
|
||||
@ -108,4 +111,14 @@ namespace ag
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int videoStart(lua_State * L)
|
||||
{
|
||||
g_video->start();
|
||||
}
|
||||
|
||||
int videoStop(lua_State * L)
|
||||
{
|
||||
g_video->stop();
|
||||
}
|
||||
}
|
||||
|
2
ag.h
2
ag.h
@ -10,6 +10,8 @@ namespace ag
|
||||
int print(lua_State * L);
|
||||
int println(lua_State * L);
|
||||
int loadModel(lua_State * L);
|
||||
int videoStart(lua_State * L);
|
||||
int videoStop(lua_State * L);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -11,6 +11,8 @@ static void usage();
|
||||
static void report_errors(lua_State * L, int status);
|
||||
static void register_libraries(lua_State * L);
|
||||
|
||||
Video * g_video = NULL;
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
const char * program = NULL;
|
||||
@ -39,7 +41,7 @@ int main(int argc, char * argv[])
|
||||
usage();
|
||||
}
|
||||
|
||||
Video video;
|
||||
g_video = new Video();
|
||||
|
||||
lua_State * L = lua_open();
|
||||
|
||||
@ -61,6 +63,8 @@ int main(int argc, char * argv[])
|
||||
report_errors(L, s);
|
||||
lua_close(L);
|
||||
|
||||
delete g_video;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user