added ag::videoStart() and ag::videoStop()

git-svn-id: svn://anubis/anaglym/trunk@20 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-09-20 01:32:25 +00:00
parent c99b3308b6
commit 5fac9f133b
5 changed files with 34 additions and 10 deletions

View File

@ -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
View File

@ -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
View File

@ -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

View File

@ -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;
}

View File

@ -3,9 +3,11 @@
#define ANAGLYM_H
#include <string>
#include "Video.h"
#define FILENAME_SAFE_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
std::string locateResource(const std::string & shortname);
extern Video * g_video;
#endif