lua_Texture.cpp 27 KB

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