lua_RenderStateStateBlock.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_RenderStateStateBlock.h"
  4. #include "Base.h"
  5. #include "Game.h"
  6. #include "Node.h"
  7. #include "Pass.h"
  8. #include "Ref.h"
  9. #include "RenderState.h"
  10. #include "Scene.h"
  11. #include "Technique.h"
  12. #include "lua_RenderStateAutoBinding.h"
  13. #include "lua_RenderStateBlend.h"
  14. #include "lua_RenderStateCullFaceSide.h"
  15. #include "lua_RenderStateDepthFunction.h"
  16. #include "lua_RenderStateStencilFunction.h"
  17. #include "lua_RenderStateStencilOperation.h"
  18. namespace gameplay
  19. {
  20. void luaRegister_RenderStateStateBlock()
  21. {
  22. const luaL_Reg lua_members[] =
  23. {
  24. {"addRef", lua_RenderStateStateBlock_addRef},
  25. {"bind", lua_RenderStateStateBlock_bind},
  26. {"getRefCount", lua_RenderStateStateBlock_getRefCount},
  27. {"release", lua_RenderStateStateBlock_release},
  28. {"setBlend", lua_RenderStateStateBlock_setBlend},
  29. {"setBlendDst", lua_RenderStateStateBlock_setBlendDst},
  30. {"setBlendSrc", lua_RenderStateStateBlock_setBlendSrc},
  31. {"setCullFace", lua_RenderStateStateBlock_setCullFace},
  32. {"setCullFaceSide", lua_RenderStateStateBlock_setCullFaceSide},
  33. {"setDepthFunction", lua_RenderStateStateBlock_setDepthFunction},
  34. {"setDepthTest", lua_RenderStateStateBlock_setDepthTest},
  35. {"setDepthWrite", lua_RenderStateStateBlock_setDepthWrite},
  36. {"setState", lua_RenderStateStateBlock_setState},
  37. {"setStencilFunction", lua_RenderStateStateBlock_setStencilFunction},
  38. {"setStencilOperation", lua_RenderStateStateBlock_setStencilOperation},
  39. {"setStencilTest", lua_RenderStateStateBlock_setStencilTest},
  40. {"setStencilWrite", lua_RenderStateStateBlock_setStencilWrite},
  41. {NULL, NULL}
  42. };
  43. const luaL_Reg lua_statics[] =
  44. {
  45. {"create", lua_RenderStateStateBlock_static_create},
  46. {NULL, NULL}
  47. };
  48. std::vector<std::string> scopePath;
  49. scopePath.push_back("RenderState");
  50. gameplay::ScriptUtil::registerClass("RenderStateStateBlock", lua_members, NULL, lua_RenderStateStateBlock__gc, lua_statics, scopePath);
  51. }
  52. static RenderState::StateBlock* getInstance(lua_State* state)
  53. {
  54. void* userdata = luaL_checkudata(state, 1, "RenderStateStateBlock");
  55. luaL_argcheck(state, userdata != NULL, 1, "'RenderStateStateBlock' expected.");
  56. return (RenderState::StateBlock*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  57. }
  58. int lua_RenderStateStateBlock__gc(lua_State* state)
  59. {
  60. // Get the number of parameters.
  61. int paramCount = lua_gettop(state);
  62. // Attempt to match the parameters to a valid binding.
  63. switch (paramCount)
  64. {
  65. case 1:
  66. {
  67. if ((lua_type(state, 1) == LUA_TUSERDATA))
  68. {
  69. void* userdata = luaL_checkudata(state, 1, "RenderStateStateBlock");
  70. luaL_argcheck(state, userdata != NULL, 1, "'RenderStateStateBlock' expected.");
  71. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  72. if (object->owns)
  73. {
  74. RenderState::StateBlock* instance = (RenderState::StateBlock*)object->instance;
  75. SAFE_RELEASE(instance);
  76. }
  77. return 0;
  78. }
  79. lua_pushstring(state, "lua_RenderStateStateBlock__gc - Failed to match the given parameters to a valid function signature.");
  80. lua_error(state);
  81. break;
  82. }
  83. default:
  84. {
  85. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  86. lua_error(state);
  87. break;
  88. }
  89. }
  90. return 0;
  91. }
  92. int lua_RenderStateStateBlock_addRef(lua_State* state)
  93. {
  94. // Get the number of parameters.
  95. int paramCount = lua_gettop(state);
  96. // Attempt to match the parameters to a valid binding.
  97. switch (paramCount)
  98. {
  99. case 1:
  100. {
  101. if ((lua_type(state, 1) == LUA_TUSERDATA))
  102. {
  103. RenderState::StateBlock* instance = getInstance(state);
  104. instance->addRef();
  105. return 0;
  106. }
  107. lua_pushstring(state, "lua_RenderStateStateBlock_addRef - Failed to match the given parameters to a valid function signature.");
  108. lua_error(state);
  109. break;
  110. }
  111. default:
  112. {
  113. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  114. lua_error(state);
  115. break;
  116. }
  117. }
  118. return 0;
  119. }
  120. int lua_RenderStateStateBlock_bind(lua_State* state)
  121. {
  122. // Get the number of parameters.
  123. int paramCount = lua_gettop(state);
  124. // Attempt to match the parameters to a valid binding.
  125. switch (paramCount)
  126. {
  127. case 1:
  128. {
  129. if ((lua_type(state, 1) == LUA_TUSERDATA))
  130. {
  131. RenderState::StateBlock* instance = getInstance(state);
  132. instance->bind();
  133. return 0;
  134. }
  135. lua_pushstring(state, "lua_RenderStateStateBlock_bind - Failed to match the given parameters to a valid function signature.");
  136. lua_error(state);
  137. break;
  138. }
  139. default:
  140. {
  141. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  142. lua_error(state);
  143. break;
  144. }
  145. }
  146. return 0;
  147. }
  148. int lua_RenderStateStateBlock_getRefCount(lua_State* state)
  149. {
  150. // Get the number of parameters.
  151. int paramCount = lua_gettop(state);
  152. // Attempt to match the parameters to a valid binding.
  153. switch (paramCount)
  154. {
  155. case 1:
  156. {
  157. if ((lua_type(state, 1) == LUA_TUSERDATA))
  158. {
  159. RenderState::StateBlock* instance = getInstance(state);
  160. unsigned int result = instance->getRefCount();
  161. // Push the return value onto the stack.
  162. lua_pushunsigned(state, result);
  163. return 1;
  164. }
  165. lua_pushstring(state, "lua_RenderStateStateBlock_getRefCount - Failed to match the given parameters to a valid function signature.");
  166. lua_error(state);
  167. break;
  168. }
  169. default:
  170. {
  171. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  172. lua_error(state);
  173. break;
  174. }
  175. }
  176. return 0;
  177. }
  178. int lua_RenderStateStateBlock_release(lua_State* state)
  179. {
  180. // Get the number of parameters.
  181. int paramCount = lua_gettop(state);
  182. // Attempt to match the parameters to a valid binding.
  183. switch (paramCount)
  184. {
  185. case 1:
  186. {
  187. if ((lua_type(state, 1) == LUA_TUSERDATA))
  188. {
  189. RenderState::StateBlock* instance = getInstance(state);
  190. instance->release();
  191. return 0;
  192. }
  193. lua_pushstring(state, "lua_RenderStateStateBlock_release - Failed to match the given parameters to a valid function signature.");
  194. lua_error(state);
  195. break;
  196. }
  197. default:
  198. {
  199. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  200. lua_error(state);
  201. break;
  202. }
  203. }
  204. return 0;
  205. }
  206. int lua_RenderStateStateBlock_setBlend(lua_State* state)
  207. {
  208. // Get the number of parameters.
  209. int paramCount = lua_gettop(state);
  210. // Attempt to match the parameters to a valid binding.
  211. switch (paramCount)
  212. {
  213. case 2:
  214. {
  215. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  216. lua_type(state, 2) == LUA_TBOOLEAN)
  217. {
  218. // Get parameter 1 off the stack.
  219. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  220. RenderState::StateBlock* instance = getInstance(state);
  221. instance->setBlend(param1);
  222. return 0;
  223. }
  224. lua_pushstring(state, "lua_RenderStateStateBlock_setBlend - Failed to match the given parameters to a valid function signature.");
  225. lua_error(state);
  226. break;
  227. }
  228. default:
  229. {
  230. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  231. lua_error(state);
  232. break;
  233. }
  234. }
  235. return 0;
  236. }
  237. int lua_RenderStateStateBlock_setBlendDst(lua_State* state)
  238. {
  239. // Get the number of parameters.
  240. int paramCount = lua_gettop(state);
  241. // Attempt to match the parameters to a valid binding.
  242. switch (paramCount)
  243. {
  244. case 2:
  245. {
  246. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  247. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  248. {
  249. // Get parameter 1 off the stack.
  250. RenderState::Blend param1 = (RenderState::Blend)lua_enumFromString_RenderStateBlend(luaL_checkstring(state, 2));
  251. RenderState::StateBlock* instance = getInstance(state);
  252. instance->setBlendDst(param1);
  253. return 0;
  254. }
  255. lua_pushstring(state, "lua_RenderStateStateBlock_setBlendDst - Failed to match the given parameters to a valid function signature.");
  256. lua_error(state);
  257. break;
  258. }
  259. default:
  260. {
  261. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  262. lua_error(state);
  263. break;
  264. }
  265. }
  266. return 0;
  267. }
  268. int lua_RenderStateStateBlock_setBlendSrc(lua_State* state)
  269. {
  270. // Get the number of parameters.
  271. int paramCount = lua_gettop(state);
  272. // Attempt to match the parameters to a valid binding.
  273. switch (paramCount)
  274. {
  275. case 2:
  276. {
  277. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  278. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  279. {
  280. // Get parameter 1 off the stack.
  281. RenderState::Blend param1 = (RenderState::Blend)lua_enumFromString_RenderStateBlend(luaL_checkstring(state, 2));
  282. RenderState::StateBlock* instance = getInstance(state);
  283. instance->setBlendSrc(param1);
  284. return 0;
  285. }
  286. lua_pushstring(state, "lua_RenderStateStateBlock_setBlendSrc - Failed to match the given parameters to a valid function signature.");
  287. lua_error(state);
  288. break;
  289. }
  290. default:
  291. {
  292. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  293. lua_error(state);
  294. break;
  295. }
  296. }
  297. return 0;
  298. }
  299. int lua_RenderStateStateBlock_setCullFace(lua_State* state)
  300. {
  301. // Get the number of parameters.
  302. int paramCount = lua_gettop(state);
  303. // Attempt to match the parameters to a valid binding.
  304. switch (paramCount)
  305. {
  306. case 2:
  307. {
  308. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  309. lua_type(state, 2) == LUA_TBOOLEAN)
  310. {
  311. // Get parameter 1 off the stack.
  312. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  313. RenderState::StateBlock* instance = getInstance(state);
  314. instance->setCullFace(param1);
  315. return 0;
  316. }
  317. lua_pushstring(state, "lua_RenderStateStateBlock_setCullFace - Failed to match the given parameters to a valid function signature.");
  318. lua_error(state);
  319. break;
  320. }
  321. default:
  322. {
  323. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  324. lua_error(state);
  325. break;
  326. }
  327. }
  328. return 0;
  329. }
  330. int lua_RenderStateStateBlock_setCullFaceSide(lua_State* state)
  331. {
  332. // Get the number of parameters.
  333. int paramCount = lua_gettop(state);
  334. // Attempt to match the parameters to a valid binding.
  335. switch (paramCount)
  336. {
  337. case 2:
  338. {
  339. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  340. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  341. {
  342. // Get parameter 1 off the stack.
  343. RenderState::CullFaceSide param1 = (RenderState::CullFaceSide)lua_enumFromString_RenderStateCullFaceSide(luaL_checkstring(state, 2));
  344. RenderState::StateBlock* instance = getInstance(state);
  345. instance->setCullFaceSide(param1);
  346. return 0;
  347. }
  348. lua_pushstring(state, "lua_RenderStateStateBlock_setCullFaceSide - Failed to match the given parameters to a valid function signature.");
  349. lua_error(state);
  350. break;
  351. }
  352. default:
  353. {
  354. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  355. lua_error(state);
  356. break;
  357. }
  358. }
  359. return 0;
  360. }
  361. int lua_RenderStateStateBlock_setDepthFunction(lua_State* state)
  362. {
  363. // Get the number of parameters.
  364. int paramCount = lua_gettop(state);
  365. // Attempt to match the parameters to a valid binding.
  366. switch (paramCount)
  367. {
  368. case 2:
  369. {
  370. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  371. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  372. {
  373. // Get parameter 1 off the stack.
  374. RenderState::DepthFunction param1 = (RenderState::DepthFunction)lua_enumFromString_RenderStateDepthFunction(luaL_checkstring(state, 2));
  375. RenderState::StateBlock* instance = getInstance(state);
  376. instance->setDepthFunction(param1);
  377. return 0;
  378. }
  379. lua_pushstring(state, "lua_RenderStateStateBlock_setDepthFunction - Failed to match the given parameters to a valid function signature.");
  380. lua_error(state);
  381. break;
  382. }
  383. default:
  384. {
  385. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  386. lua_error(state);
  387. break;
  388. }
  389. }
  390. return 0;
  391. }
  392. int lua_RenderStateStateBlock_setDepthTest(lua_State* state)
  393. {
  394. // Get the number of parameters.
  395. int paramCount = lua_gettop(state);
  396. // Attempt to match the parameters to a valid binding.
  397. switch (paramCount)
  398. {
  399. case 2:
  400. {
  401. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  402. lua_type(state, 2) == LUA_TBOOLEAN)
  403. {
  404. // Get parameter 1 off the stack.
  405. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  406. RenderState::StateBlock* instance = getInstance(state);
  407. instance->setDepthTest(param1);
  408. return 0;
  409. }
  410. lua_pushstring(state, "lua_RenderStateStateBlock_setDepthTest - Failed to match the given parameters to a valid function signature.");
  411. lua_error(state);
  412. break;
  413. }
  414. default:
  415. {
  416. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  417. lua_error(state);
  418. break;
  419. }
  420. }
  421. return 0;
  422. }
  423. int lua_RenderStateStateBlock_setDepthWrite(lua_State* state)
  424. {
  425. // Get the number of parameters.
  426. int paramCount = lua_gettop(state);
  427. // Attempt to match the parameters to a valid binding.
  428. switch (paramCount)
  429. {
  430. case 2:
  431. {
  432. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  433. lua_type(state, 2) == LUA_TBOOLEAN)
  434. {
  435. // Get parameter 1 off the stack.
  436. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  437. RenderState::StateBlock* instance = getInstance(state);
  438. instance->setDepthWrite(param1);
  439. return 0;
  440. }
  441. lua_pushstring(state, "lua_RenderStateStateBlock_setDepthWrite - Failed to match the given parameters to a valid function signature.");
  442. lua_error(state);
  443. break;
  444. }
  445. default:
  446. {
  447. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  448. lua_error(state);
  449. break;
  450. }
  451. }
  452. return 0;
  453. }
  454. int lua_RenderStateStateBlock_setState(lua_State* state)
  455. {
  456. // Get the number of parameters.
  457. int paramCount = lua_gettop(state);
  458. // Attempt to match the parameters to a valid binding.
  459. switch (paramCount)
  460. {
  461. case 3:
  462. {
  463. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  464. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  465. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  466. {
  467. // Get parameter 1 off the stack.
  468. const char* param1 = gameplay::ScriptUtil::getString(2, false);
  469. // Get parameter 2 off the stack.
  470. const char* param2 = gameplay::ScriptUtil::getString(3, false);
  471. RenderState::StateBlock* instance = getInstance(state);
  472. instance->setState(param1, param2);
  473. return 0;
  474. }
  475. lua_pushstring(state, "lua_RenderStateStateBlock_setState - Failed to match the given parameters to a valid function signature.");
  476. lua_error(state);
  477. break;
  478. }
  479. default:
  480. {
  481. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  482. lua_error(state);
  483. break;
  484. }
  485. }
  486. return 0;
  487. }
  488. int lua_RenderStateStateBlock_setStencilFunction(lua_State* state)
  489. {
  490. // Get the number of parameters.
  491. int paramCount = lua_gettop(state);
  492. // Attempt to match the parameters to a valid binding.
  493. switch (paramCount)
  494. {
  495. case 4:
  496. {
  497. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  498. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  499. lua_type(state, 3) == LUA_TNUMBER &&
  500. lua_type(state, 4) == LUA_TNUMBER)
  501. {
  502. // Get parameter 1 off the stack.
  503. RenderState::StencilFunction param1 = (RenderState::StencilFunction)lua_enumFromString_RenderStateStencilFunction(luaL_checkstring(state, 2));
  504. // Get parameter 2 off the stack.
  505. int param2 = (int)luaL_checkint(state, 3);
  506. // Get parameter 3 off the stack.
  507. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  508. RenderState::StateBlock* instance = getInstance(state);
  509. instance->setStencilFunction(param1, param2, param3);
  510. return 0;
  511. }
  512. lua_pushstring(state, "lua_RenderStateStateBlock_setStencilFunction - Failed to match the given parameters to a valid function signature.");
  513. lua_error(state);
  514. break;
  515. }
  516. default:
  517. {
  518. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  519. lua_error(state);
  520. break;
  521. }
  522. }
  523. return 0;
  524. }
  525. int lua_RenderStateStateBlock_setStencilOperation(lua_State* state)
  526. {
  527. // Get the number of parameters.
  528. int paramCount = lua_gettop(state);
  529. // Attempt to match the parameters to a valid binding.
  530. switch (paramCount)
  531. {
  532. case 4:
  533. {
  534. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  535. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  536. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
  537. (lua_type(state, 4) == LUA_TSTRING || lua_type(state, 4) == LUA_TNIL))
  538. {
  539. // Get parameter 1 off the stack.
  540. RenderState::StencilOperation param1 = (RenderState::StencilOperation)lua_enumFromString_RenderStateStencilOperation(luaL_checkstring(state, 2));
  541. // Get parameter 2 off the stack.
  542. RenderState::StencilOperation param2 = (RenderState::StencilOperation)lua_enumFromString_RenderStateStencilOperation(luaL_checkstring(state, 3));
  543. // Get parameter 3 off the stack.
  544. RenderState::StencilOperation param3 = (RenderState::StencilOperation)lua_enumFromString_RenderStateStencilOperation(luaL_checkstring(state, 4));
  545. RenderState::StateBlock* instance = getInstance(state);
  546. instance->setStencilOperation(param1, param2, param3);
  547. return 0;
  548. }
  549. lua_pushstring(state, "lua_RenderStateStateBlock_setStencilOperation - Failed to match the given parameters to a valid function signature.");
  550. lua_error(state);
  551. break;
  552. }
  553. default:
  554. {
  555. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  556. lua_error(state);
  557. break;
  558. }
  559. }
  560. return 0;
  561. }
  562. int lua_RenderStateStateBlock_setStencilTest(lua_State* state)
  563. {
  564. // Get the number of parameters.
  565. int paramCount = lua_gettop(state);
  566. // Attempt to match the parameters to a valid binding.
  567. switch (paramCount)
  568. {
  569. case 2:
  570. {
  571. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  572. lua_type(state, 2) == LUA_TBOOLEAN)
  573. {
  574. // Get parameter 1 off the stack.
  575. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  576. RenderState::StateBlock* instance = getInstance(state);
  577. instance->setStencilTest(param1);
  578. return 0;
  579. }
  580. lua_pushstring(state, "lua_RenderStateStateBlock_setStencilTest - Failed to match the given parameters to a valid function signature.");
  581. lua_error(state);
  582. break;
  583. }
  584. default:
  585. {
  586. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  587. lua_error(state);
  588. break;
  589. }
  590. }
  591. return 0;
  592. }
  593. int lua_RenderStateStateBlock_setStencilWrite(lua_State* state)
  594. {
  595. // Get the number of parameters.
  596. int paramCount = lua_gettop(state);
  597. // Attempt to match the parameters to a valid binding.
  598. switch (paramCount)
  599. {
  600. case 2:
  601. {
  602. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  603. lua_type(state, 2) == LUA_TNUMBER)
  604. {
  605. // Get parameter 1 off the stack.
  606. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  607. RenderState::StateBlock* instance = getInstance(state);
  608. instance->setStencilWrite(param1);
  609. return 0;
  610. }
  611. lua_pushstring(state, "lua_RenderStateStateBlock_setStencilWrite - Failed to match the given parameters to a valid function signature.");
  612. lua_error(state);
  613. break;
  614. }
  615. default:
  616. {
  617. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  618. lua_error(state);
  619. break;
  620. }
  621. }
  622. return 0;
  623. }
  624. int lua_RenderStateStateBlock_static_create(lua_State* state)
  625. {
  626. // Get the number of parameters.
  627. int paramCount = lua_gettop(state);
  628. // Attempt to match the parameters to a valid binding.
  629. switch (paramCount)
  630. {
  631. case 0:
  632. {
  633. void* returnPtr = (void*)RenderState::StateBlock::create();
  634. if (returnPtr)
  635. {
  636. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  637. object->instance = returnPtr;
  638. object->owns = true;
  639. luaL_getmetatable(state, "RenderStateStateBlock");
  640. lua_setmetatable(state, -2);
  641. }
  642. else
  643. {
  644. lua_pushnil(state);
  645. }
  646. return 1;
  647. break;
  648. }
  649. default:
  650. {
  651. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  652. lua_error(state);
  653. break;
  654. }
  655. }
  656. return 0;
  657. }
  658. }