This commit is contained in:
parent
513fc5c545
commit
0576670d68
|
@ -11,6 +11,7 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<DebuggerFlavor>AndroidDebugger</DebuggerFlavor>
|
||||
<LaunchActivity>com.GGELUA.game.ggemain</LaunchActivity>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<DebuggerFlavor>AndroidDebugger</DebuggerFlavor>
|
||||
|
|
|
@ -19,7 +19,6 @@ static int LUA_GetError(lua_State* L)
|
|||
static int LUA_ClearError(lua_State* L)
|
||||
{
|
||||
SDL_ClearError();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,42 +33,99 @@ static int LUA_LogResetPriorities(lua_State *L)
|
|||
|
||||
static int LUA_Log(lua_State *L)
|
||||
{
|
||||
luaL_checktype(L, 1, LUA_TSTRING);
|
||||
int n = lua_gettop(L);
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 1, "format");
|
||||
lua_insert(L, 1);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
|
||||
SDL_Log("%s", lua_tostring(L, 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_LogVerbose(lua_State *L)
|
||||
{
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
int n = lua_gettop(L)-1;
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 2, "format");
|
||||
lua_insert(L, 2);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
SDL_LogVerbose((int)luaL_checkinteger(L, 1),"%s",luaL_checkstring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_LogDebug(lua_State *L)
|
||||
{
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
int n = lua_gettop(L) - 1;
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 2, "format");
|
||||
lua_insert(L, 2);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
SDL_LogDebug((int)luaL_checkinteger(L, 1),"%s",luaL_checkstring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_LogInfo(lua_State *L)
|
||||
{
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
int n = lua_gettop(L) - 1;
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 2, "format");
|
||||
lua_insert(L, 2);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
SDL_LogInfo((int)luaL_checkinteger(L, 1),"%s",luaL_checkstring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_LogWarn(lua_State *L)
|
||||
{
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
int n = lua_gettop(L) - 1;
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 2, "format");
|
||||
lua_insert(L, 2);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
SDL_LogWarn((int)luaL_checkinteger(L, 1),"%s",luaL_checkstring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_LogError(lua_State *L)
|
||||
{
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
int n = lua_gettop(L) - 1;
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 2, "format");
|
||||
lua_insert(L, 2);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
SDL_LogError((int)luaL_checkinteger(L, 1),"%s",luaL_checkstring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_LogCritical(lua_State *L)
|
||||
{
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
int n = lua_gettop(L) - 1;
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 2, "format");
|
||||
lua_insert(L, 2);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
SDL_LogCritical((int)luaL_checkinteger(L, 1),"%s",luaL_checkstring(L, 2));
|
||||
return 0;
|
||||
}
|
||||
|
@ -77,6 +134,14 @@ static int LUA_LogMessage(lua_State *L)
|
|||
{
|
||||
int category = (int)luaL_checkinteger(L, 1);
|
||||
int priority = (int)luaL_checkinteger(L, 2);
|
||||
luaL_checktype(L, 3, LUA_TSTRING);
|
||||
int n = lua_gettop(L) - 2;
|
||||
if (n > 1)
|
||||
{
|
||||
lua_getfield(L, 3, "format");
|
||||
lua_insert(L, 3);
|
||||
lua_call(L, n, 1);
|
||||
}
|
||||
const char *msg = luaL_checkstring(L, 3);
|
||||
|
||||
SDL_LogMessage(category, priority, "%s", msg);
|
||||
|
|
|
@ -79,7 +79,7 @@ static int LUA_GetDisplayUsableBounds(lua_State *L)
|
|||
|
||||
static int LUA_GetDisplayDPI(lua_State *L)
|
||||
{
|
||||
int display_index = (int)luaL_checkinteger(L, 1);
|
||||
int display_index = (int)luaL_optinteger(L, 1, 0);
|
||||
float ddpi, hdpi, vdpi;
|
||||
|
||||
if (SDL_GetDisplayDPI(display_index, &ddpi, &hdpi, &vdpi) == 0){
|
||||
|
@ -93,7 +93,7 @@ static int LUA_GetDisplayDPI(lua_State *L)
|
|||
|
||||
static int LUA_GetDisplayOrientation(lua_State *L)
|
||||
{
|
||||
int displayIndex = (int)luaL_checkinteger(L, 1);
|
||||
int displayIndex = (int)luaL_optinteger(L, 1, 0);
|
||||
lua_pushinteger(L,SDL_GetDisplayOrientation(displayIndex));
|
||||
return 1;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ static int LUA_GetDisplayMode(lua_State *L)
|
|||
|
||||
static int LUA_GetDesktopDisplayMode(lua_State *L)
|
||||
{
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_optinteger(L, 1, 0);
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
if (SDL_GetDesktopDisplayMode(index, &mode) == 0){
|
||||
|
@ -151,7 +151,7 @@ static int LUA_GetDesktopDisplayMode(lua_State *L)
|
|||
|
||||
static int LUA_GetCurrentDisplayMode(lua_State *L)
|
||||
{
|
||||
int index = (int)luaL_checkinteger(L, 1);
|
||||
int index = (int)luaL_optinteger(L, 1, 0);
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
if (SDL_GetCurrentDisplayMode(index, &mode) == 0){
|
||||
|
@ -175,18 +175,18 @@ static int LUA_GetClosestDisplayMode(lua_State *L)
|
|||
{
|
||||
SDL_DisplayMode mode,closest;
|
||||
int displayIndex = (int)luaL_checkinteger(L, 1);
|
||||
if (lua_istable(L,2))
|
||||
{
|
||||
lua_getfield(L,-1,"h");
|
||||
mode.h = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,-2,"w");
|
||||
mode.w = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,-3,"format");
|
||||
mode.format = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,-4,"refresh_rate");
|
||||
mode.refresh_rate = (int)luaL_checkinteger(L, -1);
|
||||
lua_pop(L, 4);
|
||||
}
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
|
||||
lua_getfield(L,2,"h");
|
||||
mode.h = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,2,"w");
|
||||
mode.w = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,2,"format");
|
||||
mode.format = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,2,"refresh_rate");
|
||||
mode.refresh_rate = (int)luaL_checkinteger(L, -1);
|
||||
lua_pop(L, 4);
|
||||
|
||||
|
||||
if (SDL_GetClosestDisplayMode(displayIndex, &mode, &closest) ){
|
||||
lua_createtable(L, 0, 5);
|
||||
|
@ -216,20 +216,19 @@ static int LUA_SetWindowDisplayMode(lua_State *L)
|
|||
{
|
||||
SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
SDL_DisplayMode mode;
|
||||
if (lua_istable(L,2))
|
||||
{
|
||||
lua_getfield(L,-1,"h");
|
||||
mode.h = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,-2,"w");
|
||||
mode.w = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,-3,"format");
|
||||
mode.format = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,-4,"refresh_rate");
|
||||
mode.refresh_rate = (int)luaL_checkinteger(L, -1);
|
||||
lua_pop(L, 4);
|
||||
mode.driverdata = NULL;
|
||||
}
|
||||
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
lua_getfield(L,2,"h");
|
||||
mode.h = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,2,"w");
|
||||
mode.w = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,2,"format");
|
||||
mode.format = (int)luaL_checkinteger(L, -1);
|
||||
lua_getfield(L,2,"refresh_rate");
|
||||
mode.refresh_rate = (int)luaL_checkinteger(L, -1);
|
||||
lua_pop(L, 4);
|
||||
mode.driverdata = NULL;
|
||||
|
||||
lua_pushboolean(L,SDL_SetWindowDisplayMode(win, &mode) == 0);
|
||||
return 1;
|
||||
|
||||
|
@ -534,18 +533,23 @@ static int LUA_UpdateWindowSurface(lua_State *L)
|
|||
lua_pushboolean(L,SDL_UpdateWindowSurface(win) == 0);
|
||||
return 1;
|
||||
}
|
||||
//TODO
|
||||
|
||||
static int LUA_UpdateWindowSurfaceRects(lua_State *L)
|
||||
{
|
||||
//SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
//SDL_Rect * rect = (SDL_Rect*)luaL_checkudata(L, 2, "SDL_Rect");
|
||||
//int numrects = luaL_checkinteger(L,2);
|
||||
// if (SDL_UpdateWindowSurfaceRects(win, rect, numrects) == 0){
|
||||
// lua_pushboolean(L,1);
|
||||
// return 1;
|
||||
// }
|
||||
//?
|
||||
return 0;
|
||||
SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
int num = (int)lua_rawlen(L, 2);
|
||||
SDL_Rect * rects = SDL_malloc(sizeof(SDL_Rect)*num);
|
||||
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
lua_geti(L, 2, i + 1);
|
||||
rects[i] = *(SDL_Rect*)luaL_checkudata(L, -1, "SDL_Rect");
|
||||
}
|
||||
|
||||
lua_pushboolean(L, SDL_UpdateWindowSurfaceRects(win, rects, num) == 0);
|
||||
SDL_free(rects);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_SetWindowGrab(lua_State *L)
|
||||
|
@ -633,100 +637,101 @@ static int LUA_SetWindowInputFocus(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_SetWindowGammaRamp(lua_State *L)
|
||||
{
|
||||
//SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
//Uint16 red[256];
|
||||
//Uint16 green[256];
|
||||
//Uint16 blue[256];
|
||||
|
||||
//TODO
|
||||
|
||||
//if (SDL_SetWindowGammaRamp(win, red, green, blue) == 0){
|
||||
// lua_pushboolean(L,1);
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_GetWindowGammaRamp(lua_State *L)
|
||||
{
|
||||
//SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
//Uint16 red[256];
|
||||
//Uint16 green[256];
|
||||
//Uint16 blue[256];
|
||||
//TODO
|
||||
//if (SDL_GetWindowGammaRamp(win, red, green, blue) == 0){
|
||||
// lua_createtable(L, 3, 3);
|
||||
// //?
|
||||
// return 1;
|
||||
//}
|
||||
return 0;
|
||||
}
|
||||
//static int LUA_SetWindowGammaRamp(lua_State *L)
|
||||
//{
|
||||
// //SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
// //Uint16 red[256];
|
||||
// //Uint16 green[256];
|
||||
// //Uint16 blue[256];
|
||||
//
|
||||
// //TODO
|
||||
//
|
||||
// //if (SDL_SetWindowGammaRamp(win, red, green, blue) == 0){
|
||||
// // lua_pushboolean(L,1);
|
||||
// // return 1;
|
||||
// //}
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GetWindowGammaRamp(lua_State *L)
|
||||
//{
|
||||
// //SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
// //Uint16 red[256];
|
||||
// //Uint16 green[256];
|
||||
// //Uint16 blue[256];
|
||||
// //TODO
|
||||
// //if (SDL_GetWindowGammaRamp(win, red, green, blue) == 0){
|
||||
// // lua_createtable(L, 3, 3);
|
||||
// // //?
|
||||
// // return 1;
|
||||
// //}
|
||||
// return 0;
|
||||
//}
|
||||
//TODO
|
||||
|
||||
typedef struct {
|
||||
lua_State* L; // The Lua state the callback is in
|
||||
int ref; // The registry index of the function to call
|
||||
} CallbackData;
|
||||
//typedef struct {
|
||||
// lua_State* L; // The Lua state the callback is in
|
||||
// int ref; // The registry index of the function to call
|
||||
//} CallbackData;
|
||||
//
|
||||
//static SDL_HitTestResult
|
||||
//hitTestCallback(SDL_Window* win, const SDL_Point* area, CallbackData* cd)
|
||||
//{
|
||||
// SDL_HitTestResult ht;
|
||||
// lua_State* L = cd->L;
|
||||
// int st = lua_gettop(L);
|
||||
// //SDL_Window ** ud;
|
||||
// lua_geti(L, LUA_REGISTRYINDEX, cd->ref);
|
||||
//
|
||||
// //ud = (SDL_Window**)lua_newuserdata(L, sizeof (SDL_Window*));
|
||||
// //*ud = win;
|
||||
// //luaL_setmetatable(L, "SDL_Window");
|
||||
// lua_pushinteger(L, area->x);
|
||||
// lua_pushinteger(L, area->y);
|
||||
// lua_pcall(cd->L, 2, 1, 0);
|
||||
//
|
||||
// ht = luaL_optinteger(L, -1, SDL_HITTEST_NORMAL);
|
||||
// lua_settop(L, st);
|
||||
//
|
||||
// return ht;
|
||||
//}
|
||||
//
|
||||
//static int LUA_SetWindowHitTest(lua_State* L)
|
||||
//{
|
||||
// //SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
// //CallbackData *cd;
|
||||
// //if (lua_isfunction(L,2)) {
|
||||
//
|
||||
// // if (lua_getuservalue(L, 1)== LUA_TUSERDATA){
|
||||
// // cd = lua_touserdata(L, -1);
|
||||
// // luaL_unref(L, LUA_REGISTRYINDEX, cd->ref);
|
||||
// // }else{
|
||||
// // cd = lua_newuserdata(L, sizeof(CallbackData));
|
||||
// // lua_setuservalue(L, 1);
|
||||
// // cd->L = lua_newthread(L);
|
||||
// // }
|
||||
// //
|
||||
// // cd->ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
//
|
||||
// // if (SDL_SetWindowHitTest(win, hitTestCallback, cd) == 0){
|
||||
// // lua_pushboolean(L,1);
|
||||
// // return 1;
|
||||
// // }
|
||||
// //}else {
|
||||
// // if (lua_getuservalue(L, 1)== LUA_TUSERDATA){
|
||||
// // cd = lua_touserdata(L, -1);
|
||||
// // luaL_unref(cd->L, LUA_REGISTRYINDEX, cd->ref);
|
||||
// // }
|
||||
// // if (SDL_SetWindowHitTest(win, NULL, NULL) == 0){
|
||||
// // lua_pushboolean(L,1);
|
||||
// // return 1;
|
||||
// // }
|
||||
// //}
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
static SDL_HitTestResult
|
||||
hitTestCallback(SDL_Window* win, const SDL_Point* area, CallbackData* cd)
|
||||
{
|
||||
SDL_HitTestResult ht;
|
||||
lua_State* L = cd->L;
|
||||
int st = lua_gettop(L);
|
||||
//SDL_Window ** ud;
|
||||
lua_geti(L, LUA_REGISTRYINDEX, cd->ref);
|
||||
|
||||
//ud = (SDL_Window**)lua_newuserdata(L, sizeof (SDL_Window*));
|
||||
//*ud = win;
|
||||
//luaL_setmetatable(L, "SDL_Window");
|
||||
lua_pushinteger(L, area->x);
|
||||
lua_pushinteger(L, area->y);
|
||||
lua_pcall(cd->L, 2, 1, 0);
|
||||
|
||||
ht = luaL_optinteger(L, -1, SDL_HITTEST_NORMAL);
|
||||
lua_settop(L, st);
|
||||
|
||||
return ht;
|
||||
}
|
||||
|
||||
static int LUA_SetWindowHitTest(lua_State* L)
|
||||
{
|
||||
//SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
//CallbackData *cd;
|
||||
//if (lua_isfunction(L,2)) {
|
||||
|
||||
// if (lua_getuservalue(L, 1)== LUA_TUSERDATA){
|
||||
// cd = lua_touserdata(L, -1);
|
||||
// luaL_unref(L, LUA_REGISTRYINDEX, cd->ref);
|
||||
// }else{
|
||||
// cd = lua_newuserdata(L, sizeof(CallbackData));
|
||||
// lua_setuservalue(L, 1);
|
||||
// cd->L = lua_newthread(L);
|
||||
// }
|
||||
//
|
||||
// cd->ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
|
||||
// if (SDL_SetWindowHitTest(win, hitTestCallback, cd) == 0){
|
||||
// lua_pushboolean(L,1);
|
||||
// return 1;
|
||||
// }
|
||||
//}else {
|
||||
// if (lua_getuservalue(L, 1)== LUA_TUSERDATA){
|
||||
// cd = lua_touserdata(L, -1);
|
||||
// luaL_unref(cd->L, LUA_REGISTRYINDEX, cd->ref);
|
||||
// }
|
||||
// if (SDL_SetWindowHitTest(win, NULL, NULL) == 0){
|
||||
// lua_pushboolean(L,1);
|
||||
// return 1;
|
||||
// }
|
||||
//}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int LUA_DestroyWindow(lua_State *L)
|
||||
{
|
||||
SDL_Window ** win = (SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
|
@ -760,119 +765,119 @@ static int LUA_DisableScreenSaver(lua_State *L)
|
|||
//SDL_GL_LoadLibrary()
|
||||
//SDL_GL_GetProcAddress()
|
||||
//SDL_GL_UnloadLibrary
|
||||
static int LUA_GL_ExtensionSupported(lua_State *L)
|
||||
{
|
||||
const char* extension = luaL_checkstring(L, 1);
|
||||
lua_pushboolean(L,SDL_GL_ExtensionSupported(extension));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_ResetAttributes(lua_State *L)
|
||||
{
|
||||
SDL_GL_ResetAttributes();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_GL_SetAttribute(lua_State *L)
|
||||
{
|
||||
SDL_GLattr attr = (SDL_GLattr)luaL_checkinteger(L, 1);
|
||||
int value = (int)luaL_checkinteger(L, 2);
|
||||
|
||||
lua_pushboolean(L,SDL_GL_SetAttribute(attr, value)== 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_GetAttribute(lua_State *L)
|
||||
{
|
||||
SDL_GLattr attr = (SDL_GLattr)luaL_checkinteger(L, 1);
|
||||
int value;
|
||||
|
||||
if (SDL_GL_GetAttribute(attr, &value) == 0){
|
||||
lua_pushinteger(L,value);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_GL_CreateContext(lua_State *L)
|
||||
{
|
||||
SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
SDL_GLContext ctx = SDL_GL_CreateContext(win);
|
||||
|
||||
SDL_GLContext *ud = (SDL_GLContext*)lua_newuserdata(L, sizeof (SDL_GLContext));
|
||||
*ud = ctx;
|
||||
luaL_setmetatable(L, "SDL_GLContext");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_MakeCurrent(lua_State *L)
|
||||
{
|
||||
SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
SDL_GLContext ctx = *(SDL_GLContext*)luaL_checkudata(L, 2, "SDL_GLContext");
|
||||
|
||||
lua_pushboolean(L,SDL_GL_MakeCurrent(win, ctx) == 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_GetCurrentWindow(lua_State *L)
|
||||
{
|
||||
SDL_Window *win = SDL_GL_GetCurrentWindow();
|
||||
SDL_Window **ud = (SDL_Window**)lua_newuserdata(L, sizeof (SDL_Window*));
|
||||
*ud = win;
|
||||
luaL_setmetatable(L, "SDL_Window");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_GetCurrentContext(lua_State *L)
|
||||
{
|
||||
SDL_GLContext ctx = SDL_GL_GetCurrentContext();
|
||||
SDL_GLContext *ud = (SDL_GLContext*)lua_newuserdata(L, sizeof (SDL_GLContext));
|
||||
*ud = ctx;
|
||||
luaL_setmetatable(L, "SDL_GLContext");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_GetDrawableSize(lua_State *L)
|
||||
{
|
||||
SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
int width, height;
|
||||
|
||||
SDL_GL_GetDrawableSize(win, &width, &height);
|
||||
|
||||
lua_pushinteger(L,width);
|
||||
lua_pushinteger(L,height);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int LUA_GL_SetSwapInterval(lua_State *L)
|
||||
{
|
||||
int interval = (int)luaL_optinteger(L, 1, -1);
|
||||
|
||||
lua_pushboolean(L,SDL_GL_SetSwapInterval(interval) == 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_GetSwapInterval(lua_State *L)
|
||||
{
|
||||
lua_pushinteger(L,SDL_GL_GetSwapInterval());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int LUA_GL_SwapWindow(lua_State *L)
|
||||
{
|
||||
SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
SDL_GL_SwapWindow(win);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int LUA_GL_DeleteContext(lua_State *L)
|
||||
{
|
||||
SDL_GLContext ctx = *(SDL_GLContext*)luaL_checkudata(L, 1, "SDL_GLContext");
|
||||
|
||||
SDL_GL_DeleteContext(ctx);
|
||||
return 0;
|
||||
}
|
||||
//static int LUA_GL_ExtensionSupported(lua_State *L)
|
||||
//{
|
||||
// const char* extension = luaL_checkstring(L, 1);
|
||||
// lua_pushboolean(L,SDL_GL_ExtensionSupported(extension));
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_ResetAttributes(lua_State *L)
|
||||
//{
|
||||
// SDL_GL_ResetAttributes();
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_SetAttribute(lua_State *L)
|
||||
//{
|
||||
// SDL_GLattr attr = (SDL_GLattr)luaL_checkinteger(L, 1);
|
||||
// int value = (int)luaL_checkinteger(L, 2);
|
||||
//
|
||||
// lua_pushboolean(L,SDL_GL_SetAttribute(attr, value)== 0);
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_GetAttribute(lua_State *L)
|
||||
//{
|
||||
// SDL_GLattr attr = (SDL_GLattr)luaL_checkinteger(L, 1);
|
||||
// int value;
|
||||
//
|
||||
// if (SDL_GL_GetAttribute(attr, &value) == 0){
|
||||
// lua_pushinteger(L,value);
|
||||
// return 1;
|
||||
// }
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_CreateContext(lua_State *L)
|
||||
//{
|
||||
// SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
// SDL_GLContext ctx = SDL_GL_CreateContext(win);
|
||||
//
|
||||
// SDL_GLContext *ud = (SDL_GLContext*)lua_newuserdata(L, sizeof (SDL_GLContext));
|
||||
// *ud = ctx;
|
||||
// luaL_setmetatable(L, "SDL_GLContext");
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_MakeCurrent(lua_State *L)
|
||||
//{
|
||||
// SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
// SDL_GLContext ctx = *(SDL_GLContext*)luaL_checkudata(L, 2, "SDL_GLContext");
|
||||
//
|
||||
// lua_pushboolean(L,SDL_GL_MakeCurrent(win, ctx) == 0);
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_GetCurrentWindow(lua_State *L)
|
||||
//{
|
||||
// SDL_Window *win = SDL_GL_GetCurrentWindow();
|
||||
// SDL_Window **ud = (SDL_Window**)lua_newuserdata(L, sizeof (SDL_Window*));
|
||||
// *ud = win;
|
||||
// luaL_setmetatable(L, "SDL_Window");
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_GetCurrentContext(lua_State *L)
|
||||
//{
|
||||
// SDL_GLContext ctx = SDL_GL_GetCurrentContext();
|
||||
// SDL_GLContext *ud = (SDL_GLContext*)lua_newuserdata(L, sizeof (SDL_GLContext));
|
||||
// *ud = ctx;
|
||||
// luaL_setmetatable(L, "SDL_GLContext");
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_GetDrawableSize(lua_State *L)
|
||||
//{
|
||||
// SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
// int width, height;
|
||||
//
|
||||
// SDL_GL_GetDrawableSize(win, &width, &height);
|
||||
//
|
||||
// lua_pushinteger(L,width);
|
||||
// lua_pushinteger(L,height);
|
||||
// return 2;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_SetSwapInterval(lua_State *L)
|
||||
//{
|
||||
// int interval = (int)luaL_optinteger(L, 1, -1);
|
||||
//
|
||||
// lua_pushboolean(L,SDL_GL_SetSwapInterval(interval) == 0);
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_GetSwapInterval(lua_State *L)
|
||||
//{
|
||||
// lua_pushinteger(L,SDL_GL_GetSwapInterval());
|
||||
// return 1;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_SwapWindow(lua_State *L)
|
||||
//{
|
||||
// SDL_Window * win = *(SDL_Window**)luaL_checkudata(L, 1, "SDL_Window");
|
||||
// SDL_GL_SwapWindow(win);
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
//static int LUA_GL_DeleteContext(lua_State *L)
|
||||
//{
|
||||
// SDL_GLContext ctx = *(SDL_GLContext*)luaL_checkudata(L, 1, "SDL_GLContext");
|
||||
//
|
||||
// SDL_GL_DeleteContext(ctx);
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
static const luaL_Reg window_funcs[] = {
|
||||
{"GetWindowDisplayIndex" , LUA_GetWindowDisplayIndex} ,
|
||||
|
@ -885,7 +890,7 @@ static const luaL_Reg window_funcs[] = {
|
|||
{"GetWindowTitle" , LUA_GetWindowTitle} ,
|
||||
{"SetWindowIcon" , LUA_SetWindowIcon} ,
|
||||
//SetWindowData
|
||||
//LUA_GetWindowData
|
||||
//GetWindowData
|
||||
{"SetWindowPosition" , LUA_SetWindowPosition} ,
|
||||
{"GetWindowPosition" , LUA_GetWindowPosition} ,
|
||||
{"SetWindowSize" , LUA_SetWindowSize} ,
|
||||
|
@ -906,7 +911,7 @@ static const luaL_Reg window_funcs[] = {
|
|||
{"SetWindowFullscreen" , LUA_SetWindowFullscreen} ,
|
||||
{"GetWindowSurface" , LUA_GetWindowSurface} ,
|
||||
{"UpdateWindowSurface" , LUA_UpdateWindowSurface} ,
|
||||
//{"UpdateWindowSurfaceRects" , LUA_UpdateWindowSurfaceRects} ,
|
||||
{"UpdateWindowSurfaceRects" , LUA_UpdateWindowSurfaceRects} ,
|
||||
{"SetWindowGrab" , LUA_SetWindowGrab} ,
|
||||
{"GetWindowGrab" , LUA_GetWindowGrab} ,
|
||||
{"SetWindowBrightness" , LUA_SetWindowBrightness} ,
|
||||
|
@ -917,7 +922,7 @@ static const luaL_Reg window_funcs[] = {
|
|||
{"SetWindowInputFocus" , LUA_SetWindowInputFocus} ,
|
||||
//{"SetWindowGammaRamp" , LUA_SetWindowGammaRamp} ,
|
||||
//{"GetWindowGammaRamp" , LUA_GetWindowGammaRamp} ,
|
||||
{"SetWindowHitTest" , LUA_SetWindowHitTest} ,
|
||||
//{"SetWindowHitTest" , LUA_SetWindowHitTest} ,
|
||||
{"DestroyWindow" , LUA_DestroyWindow} ,
|
||||
|
||||
|
||||
|
@ -926,7 +931,6 @@ static const luaL_Reg window_funcs[] = {
|
|||
//{ "GL_MakeCurrent" , LUA_GL_MakeCurrent} ,
|
||||
//{ "GL_SwapWindow" , LUA_GL_SwapWindow} ,
|
||||
|
||||
|
||||
{"__index", NULL},
|
||||
{ NULL, NULL}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue