lua_SpriteBatch.cpp 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "SpriteBatch.h"
  4. #include "lua_SpriteBatch.h"
  5. #include "lua_Global.h"
  6. namespace gameplay
  7. {
  8. void luaRegister_SpriteBatch()
  9. {
  10. ScriptController* sc = ScriptController::getInstance();
  11. const luaL_Reg lua_members[] =
  12. {
  13. {"begin", lua_SpriteBatch_begin},
  14. {"draw", lua_SpriteBatch_draw},
  15. {"finish", lua_SpriteBatch_finish},
  16. {"getMaterial", lua_SpriteBatch_getMaterial},
  17. {"getProjectionMatrix", lua_SpriteBatch_getProjectionMatrix},
  18. {"getStateBlock", lua_SpriteBatch_getStateBlock},
  19. {"setProjectionMatrix", lua_SpriteBatch_setProjectionMatrix},
  20. {NULL, NULL}
  21. };
  22. const luaL_Reg lua_statics[] =
  23. {
  24. {"create", lua_SpriteBatch_static_create},
  25. {NULL, NULL}
  26. };
  27. std::vector<std::string> scopePath;
  28. sc->registerClass("SpriteBatch", lua_members, NULL, lua_SpriteBatch__gc, lua_statics, scopePath);
  29. }
  30. static SpriteBatch* getInstance(lua_State* state)
  31. {
  32. void* userdata = luaL_checkudata(state, 1, "SpriteBatch");
  33. luaL_argcheck(state, userdata != NULL, 1, "'SpriteBatch' expected.");
  34. return (SpriteBatch*)((ScriptController::LuaObject*)userdata)->instance;
  35. }
  36. int lua_SpriteBatch__gc(lua_State* state)
  37. {
  38. // Get the number of parameters.
  39. int paramCount = lua_gettop(state);
  40. // Attempt to match the parameters to a valid binding.
  41. switch (paramCount)
  42. {
  43. case 1:
  44. {
  45. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  46. {
  47. void* userdata = luaL_checkudata(state, 1, "SpriteBatch");
  48. luaL_argcheck(state, userdata != NULL, 1, "'SpriteBatch' expected.");
  49. ScriptController::LuaObject* object = (ScriptController::LuaObject*)userdata;
  50. if (object->owns)
  51. {
  52. SpriteBatch* instance = (SpriteBatch*)object->instance;
  53. SAFE_DELETE(instance);
  54. }
  55. return 0;
  56. }
  57. else
  58. {
  59. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  60. lua_error(state);
  61. }
  62. break;
  63. }
  64. default:
  65. {
  66. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  67. lua_error(state);
  68. break;
  69. }
  70. }
  71. return 0;
  72. }
  73. int lua_SpriteBatch_begin(lua_State* state)
  74. {
  75. // Get the number of parameters.
  76. int paramCount = lua_gettop(state);
  77. // Attempt to match the parameters to a valid binding.
  78. switch (paramCount)
  79. {
  80. case 1:
  81. {
  82. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  83. {
  84. SpriteBatch* instance = getInstance(state);
  85. instance->begin();
  86. return 0;
  87. }
  88. else
  89. {
  90. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  91. lua_error(state);
  92. }
  93. break;
  94. }
  95. default:
  96. {
  97. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  98. lua_error(state);
  99. break;
  100. }
  101. }
  102. return 0;
  103. }
  104. int lua_SpriteBatch_draw(lua_State* state)
  105. {
  106. // Get the number of parameters.
  107. int paramCount = lua_gettop(state);
  108. // Attempt to match the parameters to a valid binding.
  109. switch (paramCount)
  110. {
  111. case 3:
  112. {
  113. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  114. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  115. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
  116. {
  117. // Get parameter 1 off the stack.
  118. Rectangle* param1 = ScriptController::getInstance()->getObjectPointer<Rectangle>(2, "Rectangle", true);
  119. // Get parameter 2 off the stack.
  120. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  121. SpriteBatch* instance = getInstance(state);
  122. instance->draw(*param1, *param2);
  123. return 0;
  124. }
  125. else
  126. {
  127. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  128. lua_error(state);
  129. }
  130. break;
  131. }
  132. case 4:
  133. {
  134. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  135. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  136. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  137. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
  138. {
  139. // Get parameter 1 off the stack.
  140. Rectangle* param1 = ScriptController::getInstance()->getObjectPointer<Rectangle>(2, "Rectangle", true);
  141. // Get parameter 2 off the stack.
  142. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  143. // Get parameter 3 off the stack.
  144. Vector4* param3 = ScriptController::getInstance()->getObjectPointer<Vector4>(4, "Vector4", true);
  145. SpriteBatch* instance = getInstance(state);
  146. instance->draw(*param1, *param2, *param3);
  147. return 0;
  148. }
  149. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  150. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  151. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  152. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
  153. {
  154. // Get parameter 1 off the stack.
  155. Vector3* param1 = ScriptController::getInstance()->getObjectPointer<Vector3>(2, "Vector3", true);
  156. // Get parameter 2 off the stack.
  157. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  158. // Get parameter 3 off the stack.
  159. Vector2* param3 = ScriptController::getInstance()->getObjectPointer<Vector2>(4, "Vector2", true);
  160. SpriteBatch* instance = getInstance(state);
  161. instance->draw(*param1, *param2, *param3);
  162. return 0;
  163. }
  164. else
  165. {
  166. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  167. lua_error(state);
  168. }
  169. break;
  170. }
  171. case 5:
  172. {
  173. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  174. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  175. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  176. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  177. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL))
  178. {
  179. // Get parameter 1 off the stack.
  180. Vector3* param1 = ScriptController::getInstance()->getObjectPointer<Vector3>(2, "Vector3", true);
  181. // Get parameter 2 off the stack.
  182. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  183. // Get parameter 3 off the stack.
  184. Vector2* param3 = ScriptController::getInstance()->getObjectPointer<Vector2>(4, "Vector2", true);
  185. // Get parameter 4 off the stack.
  186. Vector4* param4 = ScriptController::getInstance()->getObjectPointer<Vector4>(5, "Vector4", true);
  187. SpriteBatch* instance = getInstance(state);
  188. instance->draw(*param1, *param2, *param3, *param4);
  189. return 0;
  190. }
  191. else
  192. {
  193. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  194. lua_error(state);
  195. }
  196. break;
  197. }
  198. case 7:
  199. {
  200. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  201. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  202. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  203. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  204. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL) &&
  205. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL) &&
  206. lua_type(state, 7) == LUA_TNUMBER)
  207. {
  208. // Get parameter 1 off the stack.
  209. Vector3* param1 = ScriptController::getInstance()->getObjectPointer<Vector3>(2, "Vector3", true);
  210. // Get parameter 2 off the stack.
  211. Rectangle* param2 = ScriptController::getInstance()->getObjectPointer<Rectangle>(3, "Rectangle", true);
  212. // Get parameter 3 off the stack.
  213. Vector2* param3 = ScriptController::getInstance()->getObjectPointer<Vector2>(4, "Vector2", true);
  214. // Get parameter 4 off the stack.
  215. Vector4* param4 = ScriptController::getInstance()->getObjectPointer<Vector4>(5, "Vector4", true);
  216. // Get parameter 5 off the stack.
  217. Vector2* param5 = ScriptController::getInstance()->getObjectPointer<Vector2>(6, "Vector2", true);
  218. // Get parameter 6 off the stack.
  219. float param6 = (float)luaL_checknumber(state, 7);
  220. SpriteBatch* instance = getInstance(state);
  221. instance->draw(*param1, *param2, *param3, *param4, *param5, param6);
  222. return 0;
  223. }
  224. else
  225. {
  226. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  227. lua_error(state);
  228. }
  229. break;
  230. }
  231. case 10:
  232. {
  233. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  234. lua_type(state, 2) == LUA_TNUMBER &&
  235. lua_type(state, 3) == LUA_TNUMBER &&
  236. lua_type(state, 4) == LUA_TNUMBER &&
  237. lua_type(state, 5) == LUA_TNUMBER &&
  238. lua_type(state, 6) == LUA_TNUMBER &&
  239. lua_type(state, 7) == LUA_TNUMBER &&
  240. lua_type(state, 8) == LUA_TNUMBER &&
  241. lua_type(state, 9) == LUA_TNUMBER &&
  242. (lua_type(state, 10) == LUA_TUSERDATA || lua_type(state, 10) == LUA_TNIL))
  243. {
  244. // Get parameter 1 off the stack.
  245. float param1 = (float)luaL_checknumber(state, 2);
  246. // Get parameter 2 off the stack.
  247. float param2 = (float)luaL_checknumber(state, 3);
  248. // Get parameter 3 off the stack.
  249. float param3 = (float)luaL_checknumber(state, 4);
  250. // Get parameter 4 off the stack.
  251. float param4 = (float)luaL_checknumber(state, 5);
  252. // Get parameter 5 off the stack.
  253. float param5 = (float)luaL_checknumber(state, 6);
  254. // Get parameter 6 off the stack.
  255. float param6 = (float)luaL_checknumber(state, 7);
  256. // Get parameter 7 off the stack.
  257. float param7 = (float)luaL_checknumber(state, 8);
  258. // Get parameter 8 off the stack.
  259. float param8 = (float)luaL_checknumber(state, 9);
  260. // Get parameter 9 off the stack.
  261. Vector4* param9 = ScriptController::getInstance()->getObjectPointer<Vector4>(10, "Vector4", true);
  262. SpriteBatch* instance = getInstance(state);
  263. instance->draw(param1, param2, param3, param4, param5, param6, param7, param8, *param9);
  264. return 0;
  265. }
  266. else
  267. {
  268. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  269. lua_error(state);
  270. }
  271. break;
  272. }
  273. case 11:
  274. {
  275. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  276. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  277. lua_type(state, 3) == LUA_TNUMBER &&
  278. lua_type(state, 4) == LUA_TNUMBER &&
  279. lua_type(state, 5) == LUA_TNUMBER &&
  280. lua_type(state, 6) == LUA_TNUMBER &&
  281. lua_type(state, 7) == LUA_TNUMBER &&
  282. lua_type(state, 8) == LUA_TNUMBER &&
  283. (lua_type(state, 9) == LUA_TUSERDATA || lua_type(state, 9) == LUA_TNIL) &&
  284. (lua_type(state, 10) == LUA_TUSERDATA || lua_type(state, 10) == LUA_TNIL) &&
  285. lua_type(state, 11) == LUA_TNUMBER)
  286. {
  287. // Get parameter 1 off the stack.
  288. Vector3* param1 = ScriptController::getInstance()->getObjectPointer<Vector3>(2, "Vector3", true);
  289. // Get parameter 2 off the stack.
  290. float param2 = (float)luaL_checknumber(state, 3);
  291. // Get parameter 3 off the stack.
  292. float param3 = (float)luaL_checknumber(state, 4);
  293. // Get parameter 4 off the stack.
  294. float param4 = (float)luaL_checknumber(state, 5);
  295. // Get parameter 5 off the stack.
  296. float param5 = (float)luaL_checknumber(state, 6);
  297. // Get parameter 6 off the stack.
  298. float param6 = (float)luaL_checknumber(state, 7);
  299. // Get parameter 7 off the stack.
  300. float param7 = (float)luaL_checknumber(state, 8);
  301. // Get parameter 8 off the stack.
  302. Vector4* param8 = ScriptController::getInstance()->getObjectPointer<Vector4>(9, "Vector4", true);
  303. // Get parameter 9 off the stack.
  304. Vector2* param9 = ScriptController::getInstance()->getObjectPointer<Vector2>(10, "Vector2", true);
  305. // Get parameter 10 off the stack.
  306. float param10 = (float)luaL_checknumber(state, 11);
  307. SpriteBatch* instance = getInstance(state);
  308. instance->draw(*param1, param2, param3, param4, param5, param6, param7, *param8, *param9, param10);
  309. return 0;
  310. }
  311. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  312. lua_type(state, 2) == LUA_TNUMBER &&
  313. lua_type(state, 3) == LUA_TNUMBER &&
  314. lua_type(state, 4) == LUA_TNUMBER &&
  315. lua_type(state, 5) == LUA_TNUMBER &&
  316. lua_type(state, 6) == LUA_TNUMBER &&
  317. lua_type(state, 7) == LUA_TNUMBER &&
  318. lua_type(state, 8) == LUA_TNUMBER &&
  319. lua_type(state, 9) == LUA_TNUMBER &&
  320. (lua_type(state, 10) == LUA_TUSERDATA || lua_type(state, 10) == LUA_TNIL) &&
  321. (lua_type(state, 11) == LUA_TUSERDATA || lua_type(state, 11) == LUA_TNIL))
  322. {
  323. // Get parameter 1 off the stack.
  324. float param1 = (float)luaL_checknumber(state, 2);
  325. // Get parameter 2 off the stack.
  326. float param2 = (float)luaL_checknumber(state, 3);
  327. // Get parameter 3 off the stack.
  328. float param3 = (float)luaL_checknumber(state, 4);
  329. // Get parameter 4 off the stack.
  330. float param4 = (float)luaL_checknumber(state, 5);
  331. // Get parameter 5 off the stack.
  332. float param5 = (float)luaL_checknumber(state, 6);
  333. // Get parameter 6 off the stack.
  334. float param6 = (float)luaL_checknumber(state, 7);
  335. // Get parameter 7 off the stack.
  336. float param7 = (float)luaL_checknumber(state, 8);
  337. // Get parameter 8 off the stack.
  338. float param8 = (float)luaL_checknumber(state, 9);
  339. // Get parameter 9 off the stack.
  340. Vector4* param9 = ScriptController::getInstance()->getObjectPointer<Vector4>(10, "Vector4", true);
  341. // Get parameter 10 off the stack.
  342. Rectangle* param10 = ScriptController::getInstance()->getObjectPointer<Rectangle>(11, "Rectangle", true);
  343. SpriteBatch* instance = getInstance(state);
  344. instance->draw(param1, param2, param3, param4, param5, param6, param7, param8, *param9, *param10);
  345. return 0;
  346. }
  347. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  348. lua_type(state, 2) == LUA_TNUMBER &&
  349. lua_type(state, 3) == LUA_TNUMBER &&
  350. lua_type(state, 4) == LUA_TNUMBER &&
  351. lua_type(state, 5) == LUA_TNUMBER &&
  352. lua_type(state, 6) == LUA_TNUMBER &&
  353. lua_type(state, 7) == LUA_TNUMBER &&
  354. lua_type(state, 8) == LUA_TNUMBER &&
  355. lua_type(state, 9) == LUA_TNUMBER &&
  356. lua_type(state, 10) == LUA_TNUMBER &&
  357. (lua_type(state, 11) == LUA_TUSERDATA || lua_type(state, 11) == LUA_TNIL))
  358. {
  359. // Get parameter 1 off the stack.
  360. float param1 = (float)luaL_checknumber(state, 2);
  361. // Get parameter 2 off the stack.
  362. float param2 = (float)luaL_checknumber(state, 3);
  363. // Get parameter 3 off the stack.
  364. float param3 = (float)luaL_checknumber(state, 4);
  365. // Get parameter 4 off the stack.
  366. float param4 = (float)luaL_checknumber(state, 5);
  367. // Get parameter 5 off the stack.
  368. float param5 = (float)luaL_checknumber(state, 6);
  369. // Get parameter 6 off the stack.
  370. float param6 = (float)luaL_checknumber(state, 7);
  371. // Get parameter 7 off the stack.
  372. float param7 = (float)luaL_checknumber(state, 8);
  373. // Get parameter 8 off the stack.
  374. float param8 = (float)luaL_checknumber(state, 9);
  375. // Get parameter 9 off the stack.
  376. float param9 = (float)luaL_checknumber(state, 10);
  377. // Get parameter 10 off the stack.
  378. Vector4* param10 = ScriptController::getInstance()->getObjectPointer<Vector4>(11, "Vector4", true);
  379. SpriteBatch* instance = getInstance(state);
  380. instance->draw(param1, param2, param3, param4, param5, param6, param7, param8, param9, *param10);
  381. return 0;
  382. }
  383. else
  384. {
  385. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  386. lua_error(state);
  387. }
  388. break;
  389. }
  390. case 12:
  391. {
  392. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  393. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  394. lua_type(state, 3) == LUA_TNUMBER &&
  395. lua_type(state, 4) == LUA_TNUMBER &&
  396. lua_type(state, 5) == LUA_TNUMBER &&
  397. lua_type(state, 6) == LUA_TNUMBER &&
  398. lua_type(state, 7) == LUA_TNUMBER &&
  399. lua_type(state, 8) == LUA_TNUMBER &&
  400. (lua_type(state, 9) == LUA_TUSERDATA || lua_type(state, 9) == LUA_TNIL) &&
  401. (lua_type(state, 10) == LUA_TUSERDATA || lua_type(state, 10) == LUA_TNIL) &&
  402. lua_type(state, 11) == LUA_TNUMBER &&
  403. lua_type(state, 12) == LUA_TBOOLEAN)
  404. {
  405. // Get parameter 1 off the stack.
  406. Vector3* param1 = ScriptController::getInstance()->getObjectPointer<Vector3>(2, "Vector3", true);
  407. // Get parameter 2 off the stack.
  408. float param2 = (float)luaL_checknumber(state, 3);
  409. // Get parameter 3 off the stack.
  410. float param3 = (float)luaL_checknumber(state, 4);
  411. // Get parameter 4 off the stack.
  412. float param4 = (float)luaL_checknumber(state, 5);
  413. // Get parameter 5 off the stack.
  414. float param5 = (float)luaL_checknumber(state, 6);
  415. // Get parameter 6 off the stack.
  416. float param6 = (float)luaL_checknumber(state, 7);
  417. // Get parameter 7 off the stack.
  418. float param7 = (float)luaL_checknumber(state, 8);
  419. // Get parameter 8 off the stack.
  420. Vector4* param8 = ScriptController::getInstance()->getObjectPointer<Vector4>(9, "Vector4", true);
  421. // Get parameter 9 off the stack.
  422. Vector2* param9 = ScriptController::getInstance()->getObjectPointer<Vector2>(10, "Vector2", true);
  423. // Get parameter 10 off the stack.
  424. float param10 = (float)luaL_checknumber(state, 11);
  425. // Get parameter 11 off the stack.
  426. bool param11 = ScriptController::luaCheckBool(state, 12);
  427. SpriteBatch* instance = getInstance(state);
  428. instance->draw(*param1, param2, param3, param4, param5, param6, param7, *param8, *param9, param10, param11);
  429. return 0;
  430. }
  431. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  432. lua_type(state, 2) == LUA_TNUMBER &&
  433. lua_type(state, 3) == LUA_TNUMBER &&
  434. lua_type(state, 4) == LUA_TNUMBER &&
  435. lua_type(state, 5) == LUA_TNUMBER &&
  436. lua_type(state, 6) == LUA_TNUMBER &&
  437. lua_type(state, 7) == LUA_TNUMBER &&
  438. lua_type(state, 8) == LUA_TNUMBER &&
  439. lua_type(state, 9) == LUA_TNUMBER &&
  440. lua_type(state, 10) == LUA_TNUMBER &&
  441. (lua_type(state, 11) == LUA_TUSERDATA || lua_type(state, 11) == LUA_TNIL) &&
  442. lua_type(state, 12) == LUA_TBOOLEAN)
  443. {
  444. // Get parameter 1 off the stack.
  445. float param1 = (float)luaL_checknumber(state, 2);
  446. // Get parameter 2 off the stack.
  447. float param2 = (float)luaL_checknumber(state, 3);
  448. // Get parameter 3 off the stack.
  449. float param3 = (float)luaL_checknumber(state, 4);
  450. // Get parameter 4 off the stack.
  451. float param4 = (float)luaL_checknumber(state, 5);
  452. // Get parameter 5 off the stack.
  453. float param5 = (float)luaL_checknumber(state, 6);
  454. // Get parameter 6 off the stack.
  455. float param6 = (float)luaL_checknumber(state, 7);
  456. // Get parameter 7 off the stack.
  457. float param7 = (float)luaL_checknumber(state, 8);
  458. // Get parameter 8 off the stack.
  459. float param8 = (float)luaL_checknumber(state, 9);
  460. // Get parameter 9 off the stack.
  461. float param9 = (float)luaL_checknumber(state, 10);
  462. // Get parameter 10 off the stack.
  463. Vector4* param10 = ScriptController::getInstance()->getObjectPointer<Vector4>(11, "Vector4", true);
  464. // Get parameter 11 off the stack.
  465. bool param11 = ScriptController::luaCheckBool(state, 12);
  466. SpriteBatch* instance = getInstance(state);
  467. instance->draw(param1, param2, param3, param4, param5, param6, param7, param8, param9, *param10, param11);
  468. return 0;
  469. }
  470. else
  471. {
  472. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  473. lua_error(state);
  474. }
  475. break;
  476. }
  477. case 13:
  478. {
  479. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  480. lua_type(state, 2) == LUA_TNUMBER &&
  481. lua_type(state, 3) == LUA_TNUMBER &&
  482. lua_type(state, 4) == LUA_TNUMBER &&
  483. lua_type(state, 5) == LUA_TNUMBER &&
  484. lua_type(state, 6) == LUA_TNUMBER &&
  485. lua_type(state, 7) == LUA_TNUMBER &&
  486. lua_type(state, 8) == LUA_TNUMBER &&
  487. lua_type(state, 9) == LUA_TNUMBER &&
  488. lua_type(state, 10) == LUA_TNUMBER &&
  489. (lua_type(state, 11) == LUA_TUSERDATA || lua_type(state, 11) == LUA_TNIL) &&
  490. (lua_type(state, 12) == LUA_TUSERDATA || lua_type(state, 12) == LUA_TNIL) &&
  491. lua_type(state, 13) == LUA_TNUMBER)
  492. {
  493. // Get parameter 1 off the stack.
  494. float param1 = (float)luaL_checknumber(state, 2);
  495. // Get parameter 2 off the stack.
  496. float param2 = (float)luaL_checknumber(state, 3);
  497. // Get parameter 3 off the stack.
  498. float param3 = (float)luaL_checknumber(state, 4);
  499. // Get parameter 4 off the stack.
  500. float param4 = (float)luaL_checknumber(state, 5);
  501. // Get parameter 5 off the stack.
  502. float param5 = (float)luaL_checknumber(state, 6);
  503. // Get parameter 6 off the stack.
  504. float param6 = (float)luaL_checknumber(state, 7);
  505. // Get parameter 7 off the stack.
  506. float param7 = (float)luaL_checknumber(state, 8);
  507. // Get parameter 8 off the stack.
  508. float param8 = (float)luaL_checknumber(state, 9);
  509. // Get parameter 9 off the stack.
  510. float param9 = (float)luaL_checknumber(state, 10);
  511. // Get parameter 10 off the stack.
  512. Vector4* param10 = ScriptController::getInstance()->getObjectPointer<Vector4>(11, "Vector4", true);
  513. // Get parameter 11 off the stack.
  514. Vector2* param11 = ScriptController::getInstance()->getObjectPointer<Vector2>(12, "Vector2", true);
  515. // Get parameter 12 off the stack.
  516. float param12 = (float)luaL_checknumber(state, 13);
  517. SpriteBatch* instance = getInstance(state);
  518. instance->draw(param1, param2, param3, param4, param5, param6, param7, param8, param9, *param10, *param11, param12);
  519. return 0;
  520. }
  521. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  522. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  523. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  524. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  525. lua_type(state, 5) == LUA_TNUMBER &&
  526. lua_type(state, 6) == LUA_TNUMBER &&
  527. lua_type(state, 7) == LUA_TNUMBER &&
  528. lua_type(state, 8) == LUA_TNUMBER &&
  529. lua_type(state, 9) == LUA_TNUMBER &&
  530. lua_type(state, 10) == LUA_TNUMBER &&
  531. (lua_type(state, 11) == LUA_TUSERDATA || lua_type(state, 11) == LUA_TNIL) &&
  532. (lua_type(state, 12) == LUA_TUSERDATA || lua_type(state, 12) == LUA_TNIL) &&
  533. lua_type(state, 13) == LUA_TNUMBER)
  534. {
  535. // Get parameter 1 off the stack.
  536. Vector3* param1 = ScriptController::getInstance()->getObjectPointer<Vector3>(2, "Vector3", true);
  537. // Get parameter 2 off the stack.
  538. Vector3* param2 = ScriptController::getInstance()->getObjectPointer<Vector3>(3, "Vector3", true);
  539. // Get parameter 3 off the stack.
  540. Vector3* param3 = ScriptController::getInstance()->getObjectPointer<Vector3>(4, "Vector3", true);
  541. // Get parameter 4 off the stack.
  542. float param4 = (float)luaL_checknumber(state, 5);
  543. // Get parameter 5 off the stack.
  544. float param5 = (float)luaL_checknumber(state, 6);
  545. // Get parameter 6 off the stack.
  546. float param6 = (float)luaL_checknumber(state, 7);
  547. // Get parameter 7 off the stack.
  548. float param7 = (float)luaL_checknumber(state, 8);
  549. // Get parameter 8 off the stack.
  550. float param8 = (float)luaL_checknumber(state, 9);
  551. // Get parameter 9 off the stack.
  552. float param9 = (float)luaL_checknumber(state, 10);
  553. // Get parameter 10 off the stack.
  554. Vector4* param10 = ScriptController::getInstance()->getObjectPointer<Vector4>(11, "Vector4", true);
  555. // Get parameter 11 off the stack.
  556. Vector2* param11 = ScriptController::getInstance()->getObjectPointer<Vector2>(12, "Vector2", true);
  557. // Get parameter 12 off the stack.
  558. float param12 = (float)luaL_checknumber(state, 13);
  559. SpriteBatch* instance = getInstance(state);
  560. instance->draw(*param1, *param2, *param3, param4, param5, param6, param7, param8, param9, *param10, *param11, param12);
  561. return 0;
  562. }
  563. else
  564. {
  565. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  566. lua_error(state);
  567. }
  568. break;
  569. }
  570. case 14:
  571. {
  572. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  573. lua_type(state, 2) == LUA_TNUMBER &&
  574. lua_type(state, 3) == LUA_TNUMBER &&
  575. lua_type(state, 4) == LUA_TNUMBER &&
  576. lua_type(state, 5) == LUA_TNUMBER &&
  577. lua_type(state, 6) == LUA_TNUMBER &&
  578. lua_type(state, 7) == LUA_TNUMBER &&
  579. lua_type(state, 8) == LUA_TNUMBER &&
  580. lua_type(state, 9) == LUA_TNUMBER &&
  581. lua_type(state, 10) == LUA_TNUMBER &&
  582. (lua_type(state, 11) == LUA_TUSERDATA || lua_type(state, 11) == LUA_TNIL) &&
  583. (lua_type(state, 12) == LUA_TUSERDATA || lua_type(state, 12) == LUA_TNIL) &&
  584. lua_type(state, 13) == LUA_TNUMBER &&
  585. lua_type(state, 14) == LUA_TBOOLEAN)
  586. {
  587. // Get parameter 1 off the stack.
  588. float param1 = (float)luaL_checknumber(state, 2);
  589. // Get parameter 2 off the stack.
  590. float param2 = (float)luaL_checknumber(state, 3);
  591. // Get parameter 3 off the stack.
  592. float param3 = (float)luaL_checknumber(state, 4);
  593. // Get parameter 4 off the stack.
  594. float param4 = (float)luaL_checknumber(state, 5);
  595. // Get parameter 5 off the stack.
  596. float param5 = (float)luaL_checknumber(state, 6);
  597. // Get parameter 6 off the stack.
  598. float param6 = (float)luaL_checknumber(state, 7);
  599. // Get parameter 7 off the stack.
  600. float param7 = (float)luaL_checknumber(state, 8);
  601. // Get parameter 8 off the stack.
  602. float param8 = (float)luaL_checknumber(state, 9);
  603. // Get parameter 9 off the stack.
  604. float param9 = (float)luaL_checknumber(state, 10);
  605. // Get parameter 10 off the stack.
  606. Vector4* param10 = ScriptController::getInstance()->getObjectPointer<Vector4>(11, "Vector4", true);
  607. // Get parameter 11 off the stack.
  608. Vector2* param11 = ScriptController::getInstance()->getObjectPointer<Vector2>(12, "Vector2", true);
  609. // Get parameter 12 off the stack.
  610. float param12 = (float)luaL_checknumber(state, 13);
  611. // Get parameter 13 off the stack.
  612. bool param13 = ScriptController::luaCheckBool(state, 14);
  613. SpriteBatch* instance = getInstance(state);
  614. instance->draw(param1, param2, param3, param4, param5, param6, param7, param8, param9, *param10, *param11, param12, param13);
  615. return 0;
  616. }
  617. else
  618. {
  619. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  620. lua_error(state);
  621. }
  622. break;
  623. }
  624. default:
  625. {
  626. lua_pushstring(state, "Invalid number of parameters (expected 3, 4, 5, 7, 10, 11, 12, 13 or 14).");
  627. lua_error(state);
  628. break;
  629. }
  630. }
  631. return 0;
  632. }
  633. int lua_SpriteBatch_finish(lua_State* state)
  634. {
  635. // Get the number of parameters.
  636. int paramCount = lua_gettop(state);
  637. // Attempt to match the parameters to a valid binding.
  638. switch (paramCount)
  639. {
  640. case 1:
  641. {
  642. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  643. {
  644. SpriteBatch* instance = getInstance(state);
  645. instance->finish();
  646. return 0;
  647. }
  648. else
  649. {
  650. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  651. lua_error(state);
  652. }
  653. break;
  654. }
  655. default:
  656. {
  657. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  658. lua_error(state);
  659. break;
  660. }
  661. }
  662. return 0;
  663. }
  664. int lua_SpriteBatch_getMaterial(lua_State* state)
  665. {
  666. // Get the number of parameters.
  667. int paramCount = lua_gettop(state);
  668. // Attempt to match the parameters to a valid binding.
  669. switch (paramCount)
  670. {
  671. case 1:
  672. {
  673. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  674. {
  675. SpriteBatch* instance = getInstance(state);
  676. void* returnPtr = (void*)instance->getMaterial();
  677. if (returnPtr)
  678. {
  679. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  680. object->instance = returnPtr;
  681. object->owns = false;
  682. luaL_getmetatable(state, "Material");
  683. lua_setmetatable(state, -2);
  684. }
  685. else
  686. {
  687. lua_pushnil(state);
  688. }
  689. return 1;
  690. }
  691. else
  692. {
  693. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  694. lua_error(state);
  695. }
  696. break;
  697. }
  698. default:
  699. {
  700. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  701. lua_error(state);
  702. break;
  703. }
  704. }
  705. return 0;
  706. }
  707. int lua_SpriteBatch_getProjectionMatrix(lua_State* state)
  708. {
  709. // Get the number of parameters.
  710. int paramCount = lua_gettop(state);
  711. // Attempt to match the parameters to a valid binding.
  712. switch (paramCount)
  713. {
  714. case 1:
  715. {
  716. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  717. {
  718. SpriteBatch* instance = getInstance(state);
  719. void* returnPtr = (void*)&(instance->getProjectionMatrix());
  720. if (returnPtr)
  721. {
  722. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  723. object->instance = returnPtr;
  724. object->owns = false;
  725. luaL_getmetatable(state, "Matrix");
  726. lua_setmetatable(state, -2);
  727. }
  728. else
  729. {
  730. lua_pushnil(state);
  731. }
  732. return 1;
  733. }
  734. else
  735. {
  736. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  737. lua_error(state);
  738. }
  739. break;
  740. }
  741. default:
  742. {
  743. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  744. lua_error(state);
  745. break;
  746. }
  747. }
  748. return 0;
  749. }
  750. int lua_SpriteBatch_getStateBlock(lua_State* state)
  751. {
  752. // Get the number of parameters.
  753. int paramCount = lua_gettop(state);
  754. // Attempt to match the parameters to a valid binding.
  755. switch (paramCount)
  756. {
  757. case 1:
  758. {
  759. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  760. {
  761. SpriteBatch* instance = getInstance(state);
  762. void* returnPtr = (void*)instance->getStateBlock();
  763. if (returnPtr)
  764. {
  765. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  766. object->instance = returnPtr;
  767. object->owns = false;
  768. luaL_getmetatable(state, "RenderStateStateBlock");
  769. lua_setmetatable(state, -2);
  770. }
  771. else
  772. {
  773. lua_pushnil(state);
  774. }
  775. return 1;
  776. }
  777. else
  778. {
  779. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  780. lua_error(state);
  781. }
  782. break;
  783. }
  784. default:
  785. {
  786. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  787. lua_error(state);
  788. break;
  789. }
  790. }
  791. return 0;
  792. }
  793. int lua_SpriteBatch_setProjectionMatrix(lua_State* state)
  794. {
  795. // Get the number of parameters.
  796. int paramCount = lua_gettop(state);
  797. // Attempt to match the parameters to a valid binding.
  798. switch (paramCount)
  799. {
  800. case 2:
  801. {
  802. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  803. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  804. {
  805. // Get parameter 1 off the stack.
  806. Matrix* param1 = ScriptController::getInstance()->getObjectPointer<Matrix>(2, "Matrix", true);
  807. SpriteBatch* instance = getInstance(state);
  808. instance->setProjectionMatrix(*param1);
  809. return 0;
  810. }
  811. else
  812. {
  813. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  814. lua_error(state);
  815. }
  816. break;
  817. }
  818. default:
  819. {
  820. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  821. lua_error(state);
  822. break;
  823. }
  824. }
  825. return 0;
  826. }
  827. int lua_SpriteBatch_static_create(lua_State* state)
  828. {
  829. // Get the number of parameters.
  830. int paramCount = lua_gettop(state);
  831. // Attempt to match the parameters to a valid binding.
  832. switch (paramCount)
  833. {
  834. case 1:
  835. {
  836. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  837. {
  838. // Get parameter 1 off the stack.
  839. const char* param1 = ScriptController::getInstance()->getString(1, false);
  840. void* returnPtr = (void*)SpriteBatch::create(param1);
  841. if (returnPtr)
  842. {
  843. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  844. object->instance = returnPtr;
  845. object->owns = false;
  846. luaL_getmetatable(state, "SpriteBatch");
  847. lua_setmetatable(state, -2);
  848. }
  849. else
  850. {
  851. lua_pushnil(state);
  852. }
  853. return 1;
  854. }
  855. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  856. {
  857. // Get parameter 1 off the stack.
  858. Texture* param1 = ScriptController::getInstance()->getObjectPointer<Texture>(1, "Texture", false);
  859. void* returnPtr = (void*)SpriteBatch::create(param1);
  860. if (returnPtr)
  861. {
  862. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  863. object->instance = returnPtr;
  864. object->owns = false;
  865. luaL_getmetatable(state, "SpriteBatch");
  866. lua_setmetatable(state, -2);
  867. }
  868. else
  869. {
  870. lua_pushnil(state);
  871. }
  872. return 1;
  873. }
  874. else
  875. {
  876. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  877. lua_error(state);
  878. }
  879. break;
  880. }
  881. case 2:
  882. {
  883. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
  884. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  885. {
  886. // Get parameter 1 off the stack.
  887. const char* param1 = ScriptController::getInstance()->getString(1, false);
  888. // Get parameter 2 off the stack.
  889. Effect* param2 = ScriptController::getInstance()->getObjectPointer<Effect>(2, "Effect", false);
  890. void* returnPtr = (void*)SpriteBatch::create(param1, param2);
  891. if (returnPtr)
  892. {
  893. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  894. object->instance = returnPtr;
  895. object->owns = false;
  896. luaL_getmetatable(state, "SpriteBatch");
  897. lua_setmetatable(state, -2);
  898. }
  899. else
  900. {
  901. lua_pushnil(state);
  902. }
  903. return 1;
  904. }
  905. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  906. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  907. {
  908. // Get parameter 1 off the stack.
  909. Texture* param1 = ScriptController::getInstance()->getObjectPointer<Texture>(1, "Texture", false);
  910. // Get parameter 2 off the stack.
  911. Effect* param2 = ScriptController::getInstance()->getObjectPointer<Effect>(2, "Effect", false);
  912. void* returnPtr = (void*)SpriteBatch::create(param1, param2);
  913. if (returnPtr)
  914. {
  915. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  916. object->instance = returnPtr;
  917. object->owns = false;
  918. luaL_getmetatable(state, "SpriteBatch");
  919. lua_setmetatable(state, -2);
  920. }
  921. else
  922. {
  923. lua_pushnil(state);
  924. }
  925. return 1;
  926. }
  927. else
  928. {
  929. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  930. lua_error(state);
  931. }
  932. break;
  933. }
  934. case 3:
  935. {
  936. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
  937. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  938. lua_type(state, 3) == LUA_TNUMBER)
  939. {
  940. // Get parameter 1 off the stack.
  941. const char* param1 = ScriptController::getInstance()->getString(1, false);
  942. // Get parameter 2 off the stack.
  943. Effect* param2 = ScriptController::getInstance()->getObjectPointer<Effect>(2, "Effect", false);
  944. // Get parameter 3 off the stack.
  945. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  946. void* returnPtr = (void*)SpriteBatch::create(param1, param2, param3);
  947. if (returnPtr)
  948. {
  949. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  950. object->instance = returnPtr;
  951. object->owns = false;
  952. luaL_getmetatable(state, "SpriteBatch");
  953. lua_setmetatable(state, -2);
  954. }
  955. else
  956. {
  957. lua_pushnil(state);
  958. }
  959. return 1;
  960. }
  961. else if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  962. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  963. lua_type(state, 3) == LUA_TNUMBER)
  964. {
  965. // Get parameter 1 off the stack.
  966. Texture* param1 = ScriptController::getInstance()->getObjectPointer<Texture>(1, "Texture", false);
  967. // Get parameter 2 off the stack.
  968. Effect* param2 = ScriptController::getInstance()->getObjectPointer<Effect>(2, "Effect", false);
  969. // Get parameter 3 off the stack.
  970. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  971. void* returnPtr = (void*)SpriteBatch::create(param1, param2, param3);
  972. if (returnPtr)
  973. {
  974. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  975. object->instance = returnPtr;
  976. object->owns = false;
  977. luaL_getmetatable(state, "SpriteBatch");
  978. lua_setmetatable(state, -2);
  979. }
  980. else
  981. {
  982. lua_pushnil(state);
  983. }
  984. return 1;
  985. }
  986. else
  987. {
  988. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  989. lua_error(state);
  990. }
  991. break;
  992. }
  993. default:
  994. {
  995. lua_pushstring(state, "Invalid number of parameters (expected 1, 2 or 3).");
  996. lua_error(state);
  997. break;
  998. }
  999. }
  1000. return 0;
  1001. }
  1002. }