GetDroppedFiles and SetShaderValue in Lua working
Exposed Texture2D.id to Lua Lights now have settable/gettable fields
This commit is contained in:
parent
1950085893
commit
6f27941e28
3 changed files with 96 additions and 21 deletions
|
@ -28,7 +28,10 @@ SetTargetFPS(60)
|
||||||
while not WindowShouldClose() do -- Detect window close button or ESC key
|
while not WindowShouldClose() do -- Detect window close button or ESC key
|
||||||
-- Update
|
-- Update
|
||||||
---------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------
|
||||||
if (IsFileDropped()) then droppedFiles = GetDroppedFiles(count) end
|
if (IsFileDropped()) then
|
||||||
|
droppedFiles = GetDroppedFiles()
|
||||||
|
count = #droppedFiles
|
||||||
|
end
|
||||||
---------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- Draw
|
-- Draw
|
||||||
|
@ -41,11 +44,11 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
|
||||||
else
|
else
|
||||||
DrawText("Dropped files:", 100, 40, 20, DARKGRAY)
|
DrawText("Dropped files:", 100, 40, 20, DARKGRAY)
|
||||||
|
|
||||||
for i = 0, count do
|
for i = 0, count-1 do
|
||||||
if (i%2 == 0) then DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5))
|
if (i%2 == 0) then DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5))
|
||||||
else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3)) end
|
else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3)) end
|
||||||
|
|
||||||
DrawText(droppedFiles[i], 120, 100 + 40*i, 10, GRAY)
|
DrawText(droppedFiles[i+1], 120, 100 + 40*i, 10, GRAY)
|
||||||
end
|
end
|
||||||
|
|
||||||
DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY)
|
DrawText("Drop new files...", 100, 110 + 40*count, 20, DARKGRAY)
|
||||||
|
|
|
@ -60,11 +60,11 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
|
||||||
---------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------
|
||||||
local mousePosition = GetMousePosition()
|
local mousePosition = GetMousePosition()
|
||||||
|
|
||||||
swirlCenter[0] = mousePosition.x
|
swirlCenter[1] = mousePosition.x
|
||||||
swirlCenter[1] = screenHeight - mousePosition.y
|
swirlCenter[2] = screenHeight - mousePosition.y
|
||||||
|
|
||||||
-- Send new value to the shader to be used on drawing
|
-- Send new value to the shader to be used on drawing
|
||||||
SetShaderValue(shader, swirlCenterLoc, swirlCenter, 2)
|
SetShaderValue(shader, swirlCenterLoc, swirlCenter)
|
||||||
|
|
||||||
camera = UpdateCamera(camera) -- Update internal camera and our camera
|
camera = UpdateCamera(camera) -- Update internal camera and our camera
|
||||||
---------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------
|
||||||
|
|
102
src/rlua.h
102
src/rlua.h
|
@ -126,7 +126,7 @@ RLUADEF void CloseLuaDevice(void); // De-initialize Lua system
|
||||||
#define LuaPush_SpriteFont(L, sf) LuaPushOpaqueTypeWithMetatable(L, sf, SpriteFont)
|
#define LuaPush_SpriteFont(L, sf) LuaPushOpaqueTypeWithMetatable(L, sf, SpriteFont)
|
||||||
#define LuaPush_Mesh(L, vd) LuaPushOpaqueType(L, vd)
|
#define LuaPush_Mesh(L, vd) LuaPushOpaqueType(L, vd)
|
||||||
#define LuaPush_Shader(L, s) LuaPushOpaqueType(L, s)
|
#define LuaPush_Shader(L, s) LuaPushOpaqueType(L, s)
|
||||||
#define LuaPush_Light(L, light) LuaPushOpaqueType(L, light)
|
#define LuaPush_Light(L, light) LuaPushOpaqueTypeWithMetatable(L, light, Light)
|
||||||
#define LuaPush_Sound(L, snd) LuaPushOpaqueType(L, snd)
|
#define LuaPush_Sound(L, snd) LuaPushOpaqueType(L, snd)
|
||||||
#define LuaPush_Wave(L, wav) LuaPushOpaqueType(L, wav)
|
#define LuaPush_Wave(L, wav) LuaPushOpaqueType(L, wav)
|
||||||
#define LuaPush_Music(L, mus) LuaPushOpaqueType(L, mus)
|
#define LuaPush_Music(L, mus) LuaPushOpaqueType(L, mus)
|
||||||
|
@ -263,6 +263,8 @@ static int LuaIndexTexture2D(lua_State* L)
|
||||||
lua_pushinteger(L, img.mipmaps);
|
lua_pushinteger(L, img.mipmaps);
|
||||||
else if (!strcmp(key, "format"))
|
else if (!strcmp(key, "format"))
|
||||||
lua_pushinteger(L, img.format);
|
lua_pushinteger(L, img.format);
|
||||||
|
else if (!strcmp(key, "id"))
|
||||||
|
lua_pushinteger(L, img.id);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -296,6 +298,58 @@ static int LuaIndexSpriteFont(lua_State* L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int LuaIndexLight(lua_State* L)
|
||||||
|
{
|
||||||
|
Light light = LuaGetArgument_Light(L, 1);
|
||||||
|
const char *key = luaL_checkstring(L, 2);
|
||||||
|
if (!strcmp(key, "id"))
|
||||||
|
lua_pushinteger(L, light->id);
|
||||||
|
else if (!strcmp(key, "enabled"))
|
||||||
|
lua_pushboolean(L, light->enabled);
|
||||||
|
else if (!strcmp(key, "type"))
|
||||||
|
lua_pushinteger(L, light->type);
|
||||||
|
else if (!strcmp(key, "position"))
|
||||||
|
LuaPush_Vector3(L, light->position);
|
||||||
|
else if (!strcmp(key, "target"))
|
||||||
|
LuaPush_Vector3(L, light->target);
|
||||||
|
else if (!strcmp(key, "radius"))
|
||||||
|
lua_pushnumber(L, light->radius);
|
||||||
|
else if (!strcmp(key, "diffuse"))
|
||||||
|
LuaPush_Color(L, light->diffuse);
|
||||||
|
else if (!strcmp(key, "intensity"))
|
||||||
|
lua_pushnumber(L, light->intensity);
|
||||||
|
else if (!strcmp(key, "coneAngle"))
|
||||||
|
lua_pushnumber(L, light->coneAngle);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int LuaNewIndexLight(lua_State* L)
|
||||||
|
{
|
||||||
|
Light light = LuaGetArgument_Light(L, 1);
|
||||||
|
const char *key = luaL_checkstring(L, 2);
|
||||||
|
if (!strcmp(key, "id"))
|
||||||
|
light->id = LuaGetArgument_int(L, 3);
|
||||||
|
else if (!strcmp(key, "enabled"))
|
||||||
|
light->enabled = lua_toboolean(L, 3);
|
||||||
|
else if (!strcmp(key, "type"))
|
||||||
|
light->type = LuaGetArgument_int(L, 3);
|
||||||
|
else if (!strcmp(key, "position"))
|
||||||
|
light->position = LuaGetArgument_Vector3(L, 3);
|
||||||
|
else if (!strcmp(key, "target"))
|
||||||
|
light->target = LuaGetArgument_Vector3(L, 3);
|
||||||
|
else if (!strcmp(key, "radius"))
|
||||||
|
light->radius = LuaGetArgument_float(L, 3);
|
||||||
|
else if (!strcmp(key, "diffuse"))
|
||||||
|
light->diffuse = LuaGetArgument_Color(L, 3);
|
||||||
|
else if (!strcmp(key, "intensity"))
|
||||||
|
light->intensity = LuaGetArgument_float(L, 3);
|
||||||
|
else if (!strcmp(key, "coneAngle"))
|
||||||
|
light->coneAngle = LuaGetArgument_float(L, 3);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void LuaBuildOpaqueMetatables(void)
|
static void LuaBuildOpaqueMetatables(void)
|
||||||
{
|
{
|
||||||
luaL_newmetatable(L, "Image");
|
luaL_newmetatable(L, "Image");
|
||||||
|
@ -313,10 +367,17 @@ static void LuaBuildOpaqueMetatables(void)
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
luaL_newmetatable(L, "SpriteFont");
|
luaL_newmetatable(L, "SpriteFont");
|
||||||
lua_pushcfunction(L, &LuaIndexSpriteFont);
|
lua_pushcfunction(L, &LuaIndexSpriteFont);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
luaL_newmetatable(L, "Light");
|
||||||
|
lua_pushcfunction(L, &LuaIndexLight);
|
||||||
|
lua_setfield(L, -2, "__index");
|
||||||
|
lua_pushcfunction(L, &LuaNewIndexLight);
|
||||||
|
lua_setfield(L, -2, "__newindex");
|
||||||
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -1057,15 +1118,20 @@ int lua_IsFileDropped(lua_State* L)
|
||||||
lua_pushboolean(L, result);
|
lua_pushboolean(L, result);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
int lua_*GetDroppedFiles(lua_State* L)
|
int lua_GetDroppedFiles(lua_State* L)
|
||||||
{
|
{
|
||||||
int * arg1 = LuaGetArgument_int *(L, 1);
|
int count = 0;
|
||||||
//char * result = *GetDroppedFiles(arg1);
|
char ** result = GetDroppedFiles(&count);
|
||||||
LuaPush_//char *(L, result);
|
lua_createtable(L, count, 0);
|
||||||
return 1;
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
lua_pushstring(L, result[i]);
|
||||||
|
lua_rawseti(L, -2, i + 1);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
int lua_ClearDroppedFiles(lua_State* L)
|
int lua_ClearDroppedFiles(lua_State* L)
|
||||||
{
|
{
|
||||||
ClearDroppedFiles();
|
ClearDroppedFiles();
|
||||||
|
@ -1638,7 +1704,6 @@ int lua_DrawPoly(lua_State* L)
|
||||||
sz++; \
|
sz++; \
|
||||||
lua_pop(L, 1); \
|
lua_pop(L, 1); \
|
||||||
} \
|
} \
|
||||||
lua_pop(L, 1); \
|
|
||||||
name = calloc(sz, sizeof(type)); \
|
name = calloc(sz, sizeof(type)); \
|
||||||
sz = 0; \
|
sz = 0; \
|
||||||
lua_pushnil(L); \
|
lua_pushnil(L); \
|
||||||
|
@ -2334,7 +2399,12 @@ int lua_DrawGizmo(lua_State* L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: DrawLight(Light light);
|
int lua_DrawLight(lua_State* L)
|
||||||
|
{
|
||||||
|
Light arg1 = LuaGetArgument_Light(L, 1);
|
||||||
|
DrawLight(arg1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int lua_Draw3DLine(lua_State* L)
|
int lua_Draw3DLine(lua_State* L)
|
||||||
{
|
{
|
||||||
|
@ -3544,7 +3614,7 @@ static luaL_Reg raylib_functions[] = {
|
||||||
REG(ShowLogo)
|
REG(ShowLogo)
|
||||||
|
|
||||||
REG(IsFileDropped)
|
REG(IsFileDropped)
|
||||||
//REG(*GetDroppedFiles)
|
REG(GetDroppedFiles)
|
||||||
REG(ClearDroppedFiles)
|
REG(ClearDroppedFiles)
|
||||||
REG(StorageSaveValue)
|
REG(StorageSaveValue)
|
||||||
REG(StorageLoadValue)
|
REG(StorageLoadValue)
|
||||||
|
@ -3699,6 +3769,8 @@ static luaL_Reg raylib_functions[] = {
|
||||||
REG(DrawGrid)
|
REG(DrawGrid)
|
||||||
REG(DrawGizmo)
|
REG(DrawGizmo)
|
||||||
|
|
||||||
|
REG(DrawLight)
|
||||||
|
|
||||||
REG(LoadModel)
|
REG(LoadModel)
|
||||||
REG(LoadModelEx)
|
REG(LoadModelEx)
|
||||||
REG(LoadModelFromRES)
|
REG(LoadModelFromRES)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue