lua_Texture.cpp 30 KB

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