|
|
@@ -25,16 +25,19 @@ void luaRegister_Pass()
|
|
|
{
|
|
|
const luaL_Reg lua_members[] =
|
|
|
{
|
|
|
+ {"addParameter", lua_Pass_addParameter},
|
|
|
{"addRef", lua_Pass_addRef},
|
|
|
{"bind", lua_Pass_bind},
|
|
|
- {"clearParameter", lua_Pass_clearParameter},
|
|
|
{"getEffect", lua_Pass_getEffect},
|
|
|
{"getId", lua_Pass_getId},
|
|
|
{"getParameter", lua_Pass_getParameter},
|
|
|
+ {"getParameterByIndex", lua_Pass_getParameterByIndex},
|
|
|
+ {"getParameterCount", lua_Pass_getParameterCount},
|
|
|
{"getRefCount", lua_Pass_getRefCount},
|
|
|
{"getStateBlock", lua_Pass_getStateBlock},
|
|
|
{"getVertexAttributeBinding", lua_Pass_getVertexAttributeBinding},
|
|
|
{"release", lua_Pass_release},
|
|
|
+ {"removeParameter", lua_Pass_removeParameter},
|
|
|
{"setParameterAutoBinding", lua_Pass_setParameterAutoBinding},
|
|
|
{"setStateBlock", lua_Pass_setStateBlock},
|
|
|
{"setVertexAttributeBinding", lua_Pass_setVertexAttributeBinding},
|
|
|
@@ -92,7 +95,7 @@ int lua_Pass__gc(lua_State* state)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int lua_Pass_addRef(lua_State* state)
|
|
|
+int lua_Pass_addParameter(lua_State* state)
|
|
|
{
|
|
|
// Get the number of parameters.
|
|
|
int paramCount = lua_gettop(state);
|
|
|
@@ -100,23 +103,33 @@ int lua_Pass_addRef(lua_State* state)
|
|
|
// Attempt to match the parameters to a valid binding.
|
|
|
switch (paramCount)
|
|
|
{
|
|
|
- case 1:
|
|
|
+ case 2:
|
|
|
{
|
|
|
- if ((lua_type(state, 1) == LUA_TUSERDATA))
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
+ (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
|
|
|
{
|
|
|
+ // Get parameter 1 off the stack.
|
|
|
+ bool param1Valid;
|
|
|
+ gameplay::ScriptUtil::LuaArray<MaterialParameter> param1 = gameplay::ScriptUtil::getObjectPointer<MaterialParameter>(2, "MaterialParameter", false, ¶m1Valid);
|
|
|
+ if (!param1Valid)
|
|
|
+ {
|
|
|
+ lua_pushstring(state, "Failed to convert parameter 1 to type 'MaterialParameter'.");
|
|
|
+ lua_error(state);
|
|
|
+ }
|
|
|
+
|
|
|
Pass* instance = getInstance(state);
|
|
|
- instance->addRef();
|
|
|
+ instance->addParameter(param1);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- lua_pushstring(state, "lua_Pass_addRef - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_pushstring(state, "lua_Pass_addParameter - Failed to match the given parameters to a valid function signature.");
|
|
|
lua_error(state);
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
|
{
|
|
|
- lua_pushstring(state, "Invalid number of parameters (expected 1).");
|
|
|
+ lua_pushstring(state, "Invalid number of parameters (expected 2).");
|
|
|
lua_error(state);
|
|
|
break;
|
|
|
}
|
|
|
@@ -124,7 +137,7 @@ int lua_Pass_addRef(lua_State* state)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int lua_Pass_bind(lua_State* state)
|
|
|
+int lua_Pass_addRef(lua_State* state)
|
|
|
{
|
|
|
// Get the number of parameters.
|
|
|
int paramCount = lua_gettop(state);
|
|
|
@@ -137,12 +150,12 @@ int lua_Pass_bind(lua_State* state)
|
|
|
if ((lua_type(state, 1) == LUA_TUSERDATA))
|
|
|
{
|
|
|
Pass* instance = getInstance(state);
|
|
|
- instance->bind();
|
|
|
+ instance->addRef();
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- lua_pushstring(state, "lua_Pass_bind - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_pushstring(state, "lua_Pass_addRef - Failed to match the given parameters to a valid function signature.");
|
|
|
lua_error(state);
|
|
|
break;
|
|
|
}
|
|
|
@@ -156,7 +169,7 @@ int lua_Pass_bind(lua_State* state)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int lua_Pass_clearParameter(lua_State* state)
|
|
|
+int lua_Pass_bind(lua_State* state)
|
|
|
{
|
|
|
// Get the number of parameters.
|
|
|
int paramCount = lua_gettop(state);
|
|
|
@@ -164,27 +177,23 @@ int lua_Pass_clearParameter(lua_State* state)
|
|
|
// Attempt to match the parameters to a valid binding.
|
|
|
switch (paramCount)
|
|
|
{
|
|
|
- case 2:
|
|
|
+ case 1:
|
|
|
{
|
|
|
- if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
- (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA))
|
|
|
{
|
|
|
- // Get parameter 1 off the stack.
|
|
|
- const char* param1 = gameplay::ScriptUtil::getString(2, false);
|
|
|
-
|
|
|
Pass* instance = getInstance(state);
|
|
|
- instance->clearParameter(param1);
|
|
|
+ instance->bind();
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- lua_pushstring(state, "lua_Pass_clearParameter - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_pushstring(state, "lua_Pass_bind - Failed to match the given parameters to a valid function signature.");
|
|
|
lua_error(state);
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
|
{
|
|
|
- lua_pushstring(state, "Invalid number of parameters (expected 2).");
|
|
|
+ lua_pushstring(state, "Invalid number of parameters (expected 1).");
|
|
|
lua_error(state);
|
|
|
break;
|
|
|
}
|
|
|
@@ -319,6 +328,89 @@ int lua_Pass_getParameter(lua_State* state)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+int lua_Pass_getParameterByIndex(lua_State* state)
|
|
|
+{
|
|
|
+ // Get the number of parameters.
|
|
|
+ int paramCount = lua_gettop(state);
|
|
|
+
|
|
|
+ // Attempt to match the parameters to a valid binding.
|
|
|
+ switch (paramCount)
|
|
|
+ {
|
|
|
+ case 2:
|
|
|
+ {
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
+ lua_type(state, 2) == LUA_TNUMBER)
|
|
|
+ {
|
|
|
+ // Get parameter 1 off the stack.
|
|
|
+ unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
|
|
|
+
|
|
|
+ Pass* instance = getInstance(state);
|
|
|
+ void* returnPtr = (void*)instance->getParameterByIndex(param1);
|
|
|
+ if (returnPtr)
|
|
|
+ {
|
|
|
+ gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
|
|
|
+ object->instance = returnPtr;
|
|
|
+ object->owns = false;
|
|
|
+ luaL_getmetatable(state, "MaterialParameter");
|
|
|
+ lua_setmetatable(state, -2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lua_pushnil(state);
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ lua_pushstring(state, "lua_Pass_getParameterByIndex - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_error(state);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ lua_pushstring(state, "Invalid number of parameters (expected 2).");
|
|
|
+ lua_error(state);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int lua_Pass_getParameterCount(lua_State* state)
|
|
|
+{
|
|
|
+ // Get the number of parameters.
|
|
|
+ int paramCount = lua_gettop(state);
|
|
|
+
|
|
|
+ // Attempt to match the parameters to a valid binding.
|
|
|
+ switch (paramCount)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA))
|
|
|
+ {
|
|
|
+ Pass* instance = getInstance(state);
|
|
|
+ unsigned int result = instance->getParameterCount();
|
|
|
+
|
|
|
+ // Push the return value onto the stack.
|
|
|
+ lua_pushunsigned(state, result);
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ lua_pushstring(state, "lua_Pass_getParameterCount - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_error(state);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ lua_pushstring(state, "Invalid number of parameters (expected 1).");
|
|
|
+ lua_error(state);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int lua_Pass_getRefCount(lua_State* state)
|
|
|
{
|
|
|
// Get the number of parameters.
|
|
|
@@ -474,6 +566,42 @@ int lua_Pass_release(lua_State* state)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+int lua_Pass_removeParameter(lua_State* state)
|
|
|
+{
|
|
|
+ // Get the number of parameters.
|
|
|
+ int paramCount = lua_gettop(state);
|
|
|
+
|
|
|
+ // Attempt to match the parameters to a valid binding.
|
|
|
+ switch (paramCount)
|
|
|
+ {
|
|
|
+ case 2:
|
|
|
+ {
|
|
|
+ if ((lua_type(state, 1) == LUA_TUSERDATA) &&
|
|
|
+ (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
|
|
|
+ {
|
|
|
+ // Get parameter 1 off the stack.
|
|
|
+ const char* param1 = gameplay::ScriptUtil::getString(2, false);
|
|
|
+
|
|
|
+ Pass* instance = getInstance(state);
|
|
|
+ instance->removeParameter(param1);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ lua_pushstring(state, "lua_Pass_removeParameter - Failed to match the given parameters to a valid function signature.");
|
|
|
+ lua_error(state);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ lua_pushstring(state, "Invalid number of parameters (expected 2).");
|
|
|
+ lua_error(state);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int lua_Pass_setParameterAutoBinding(lua_State* state)
|
|
|
{
|
|
|
// Get the number of parameters.
|