added getScreenSize()

git-svn-id: svn://anubis/anaglym/trunk@159 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-11-08 03:48:45 +00:00
parent f7f6c83795
commit 3f429be13b
6 changed files with 26 additions and 0 deletions

View File

@ -496,6 +496,12 @@ int Engine::renderText(const char * text, int mode, Uint8 r, Uint8 g, Uint8 b,
return 0; return 0;
} }
void Engine::getScreenSize(int * width, int * height)
{
*width = m_video.getWidth();
*height = m_video.getHeight();
}
/* called by SDL when the update timer expires */ /* called by SDL when the update timer expires */
Uint32 Engine::updateCallback(Uint32 interval, void * param) Uint32 Engine::updateCallback(Uint32 interval, void * param)
{ {

View File

@ -137,6 +137,7 @@ class Engine
void debug_hook(lua_Debug * debug); void debug_hook(lua_Debug * debug);
int renderText(const char * text, int mode, Uint8 r, Uint8 g, Uint8 b, int renderText(const char * text, int mode, Uint8 r, Uint8 g, Uint8 b,
Uint8 br = 0, Uint8 bg = 0, Uint8 bb = 0); Uint8 br = 0, Uint8 bg = 0, Uint8 bb = 0);
void getScreenSize(int * width, int * height);
/* lua services */ /* lua services */
int setCamera(lua_State * L); int setCamera(lua_State * L);

View File

@ -29,6 +29,8 @@ Video::Video()
m_surface = NULL; m_surface = NULL;
m_inputGrabbed = false; m_inputGrabbed = false;
m_width = 0;
m_height = 0;
} }
void Video::start(int width, int height, bool fullscreen, bool grab_input, void Video::start(int width, int height, bool fullscreen, bool grab_input,
@ -58,6 +60,8 @@ void Video::start(int width, int height, bool fullscreen, bool grab_input,
} }
m_inputGrabbed = grab_input; m_inputGrabbed = grab_input;
m_fullscreen = fullscreen; m_fullscreen = fullscreen;
m_width = width;
m_height = height;
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);

View File

@ -15,10 +15,14 @@ class Video
int getDefaultWidth() { return m_defaultWidth; } int getDefaultWidth() { return m_defaultWidth; }
int getDefaultHeight() { return m_defaultHeight; } int getDefaultHeight() { return m_defaultHeight; }
void toggleFullScreen() { SDL_WM_ToggleFullScreen(m_surface); } void toggleFullScreen() { SDL_WM_ToggleFullScreen(m_surface); }
int getWidth() { return m_width; }
int getHeight() { return m_height; }
protected: protected:
int m_defaultWidth; int m_defaultWidth;
int m_defaultHeight; int m_defaultHeight;
int m_width;
int m_height;
SDL_Surface * m_surface; SDL_Surface * m_surface;
bool m_fullscreen; bool m_fullscreen;
bool m_inputGrabbed; bool m_inputGrabbed;

10
ag.cc
View File

@ -43,6 +43,7 @@ namespace ag
{ "exit", exit }, { "exit", exit },
{ "import", import }, { "import", import },
{ "loadTexture", loadTexture }, { "loadTexture", loadTexture },
{ "getScreenSize", getScreenSize },
{ "createBox", createBox}, { "createBox", createBox},
{ "createStaticBox", createStaticBox}, { "createStaticBox", createStaticBox},
@ -337,6 +338,15 @@ namespace ag
return 1; return 1;
} }
int getScreenSize(lua_State * L)
{
int width, height;
g_engine->getScreenSize(&width, &height);
lua_pushinteger(L, width);
lua_pushinteger(L, height);
return 2;
}
static void addManagedObject(lua_State * L, bool is_static, static void addManagedObject(lua_State * L, bool is_static,
OdeWorld::GeomType geom_type, refptr< vector<float> > args) OdeWorld::GeomType geom_type, refptr< vector<float> > args)
{ {

1
ag.h
View File

@ -29,6 +29,7 @@ namespace ag
int exit(lua_State * L); int exit(lua_State * L);
int import(lua_State * L); int import(lua_State * L);
int loadTexture(lua_State * L); int loadTexture(lua_State * L);
int getScreenSize(lua_State * L);
int createBox(lua_State * L); int createBox(lua_State * L);
int createStaticBox(lua_State * L); int createStaticBox(lua_State * L);