lua_Texture.cpp 24 KB

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