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
3
Video.cc
3
Video.cc
@ -30,6 +30,8 @@ Video::Video()
|
|||||||
|
|
||||||
void Video::start(int width, int height, bool fullscreen)
|
void Video::start(int width, int height, bool fullscreen)
|
||||||
{
|
{
|
||||||
|
if (m_surface == NULL)
|
||||||
|
{
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
width = m_defaultWidth;
|
width = m_defaultWidth;
|
||||||
if (height == 0)
|
if (height == 0)
|
||||||
@ -40,6 +42,7 @@ void Video::start(int width, int height, bool fullscreen)
|
|||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
m_surface = SDL_SetVideoMode(width, height, 32, flags);
|
m_surface = SDL_SetVideoMode(width, height, 32, flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Video::stop()
|
void Video::stop()
|
||||||
|
13
ag.cc
13
ag.cc
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "anaglym.h"
|
#include "anaglym.h"
|
||||||
#include "ag.h"
|
#include "ag.h"
|
||||||
|
#include "Video.h"
|
||||||
#include "wfobj/WFObj.hh"
|
#include "wfobj/WFObj.hh"
|
||||||
#include <lua.hpp>
|
#include <lua.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -15,6 +16,8 @@ namespace ag
|
|||||||
{ "print", print },
|
{ "print", print },
|
||||||
{ "println", println },
|
{ "println", println },
|
||||||
{ "loadModel", loadModel },
|
{ "loadModel", loadModel },
|
||||||
|
{ "videoStart", videoStart },
|
||||||
|
{ "videoStop", videoStop },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
luaL_register(L, "ag", functions);
|
luaL_register(L, "ag", functions);
|
||||||
@ -108,4 +111,14 @@ namespace ag
|
|||||||
|
|
||||||
return 0;
|
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 print(lua_State * L);
|
||||||
int println(lua_State * L);
|
int println(lua_State * L);
|
||||||
int loadModel(lua_State * L);
|
int loadModel(lua_State * L);
|
||||||
|
int videoStart(lua_State * L);
|
||||||
|
int videoStop(lua_State * L);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,6 +11,8 @@ static void usage();
|
|||||||
static void report_errors(lua_State * L, int status);
|
static void report_errors(lua_State * L, int status);
|
||||||
static void register_libraries(lua_State * L);
|
static void register_libraries(lua_State * L);
|
||||||
|
|
||||||
|
Video * g_video = NULL;
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
const char * program = NULL;
|
const char * program = NULL;
|
||||||
@ -39,7 +41,7 @@ int main(int argc, char * argv[])
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
Video video;
|
g_video = new Video();
|
||||||
|
|
||||||
lua_State * L = lua_open();
|
lua_State * L = lua_open();
|
||||||
|
|
||||||
@ -61,6 +63,8 @@ int main(int argc, char * argv[])
|
|||||||
report_errors(L, s);
|
report_errors(L, s);
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
|
|
||||||
|
delete g_video;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
#define ANAGLYM_H
|
#define ANAGLYM_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "Video.h"
|
||||||
|
|
||||||
#define FILENAME_SAFE_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
|
#define FILENAME_SAFE_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
|
||||||
|
|
||||||
std::string locateResource(const std::string & shortname);
|
std::string locateResource(const std::string & shortname);
|
||||||
|
extern Video * g_video;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user