lua_Texture.cpp 28 KB

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