lua_FrameBuffer.cpp 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_FrameBuffer.h"
  4. #include "Base.h"
  5. #include "FrameBuffer.h"
  6. #include "Game.h"
  7. #include "Ref.h"
  8. namespace gameplay
  9. {
  10. void luaRegister_FrameBuffer()
  11. {
  12. const luaL_Reg lua_members[] =
  13. {
  14. {"addRef", lua_FrameBuffer_addRef},
  15. {"bind", lua_FrameBuffer_bind},
  16. {"getDepthStencilTarget", lua_FrameBuffer_getDepthStencilTarget},
  17. {"getHeight", lua_FrameBuffer_getHeight},
  18. {"getId", lua_FrameBuffer_getId},
  19. {"getRefCount", lua_FrameBuffer_getRefCount},
  20. {"getRenderTarget", lua_FrameBuffer_getRenderTarget},
  21. {"getRenderTargetCount", lua_FrameBuffer_getRenderTargetCount},
  22. {"getWidth", lua_FrameBuffer_getWidth},
  23. {"isDefault", lua_FrameBuffer_isDefault},
  24. {"release", lua_FrameBuffer_release},
  25. {"setDepthStencilTarget", lua_FrameBuffer_setDepthStencilTarget},
  26. {"setRenderTarget", lua_FrameBuffer_setRenderTarget},
  27. {NULL, NULL}
  28. };
  29. const luaL_Reg lua_statics[] =
  30. {
  31. {"bindDefault", lua_FrameBuffer_static_bindDefault},
  32. {"create", lua_FrameBuffer_static_create},
  33. {"createScreenshot", lua_FrameBuffer_static_createScreenshot},
  34. {"getCurrent", lua_FrameBuffer_static_getCurrent},
  35. {"getFrameBuffer", lua_FrameBuffer_static_getFrameBuffer},
  36. {"getMaxRenderTargets", lua_FrameBuffer_static_getMaxRenderTargets},
  37. {"getScreenshot", lua_FrameBuffer_static_getScreenshot},
  38. {NULL, NULL}
  39. };
  40. std::vector<std::string> scopePath;
  41. gameplay::ScriptUtil::registerClass("FrameBuffer", lua_members, NULL, lua_FrameBuffer__gc, lua_statics, scopePath);
  42. }
  43. static FrameBuffer* getInstance(lua_State* state)
  44. {
  45. void* userdata = luaL_checkudata(state, 1, "FrameBuffer");
  46. luaL_argcheck(state, userdata != NULL, 1, "'FrameBuffer' expected.");
  47. return (FrameBuffer*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  48. }
  49. int lua_FrameBuffer__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, "FrameBuffer");
  61. luaL_argcheck(state, userdata != NULL, 1, "'FrameBuffer' expected.");
  62. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  63. if (object->owns)
  64. {
  65. FrameBuffer* instance = (FrameBuffer*)object->instance;
  66. SAFE_RELEASE(instance);
  67. }
  68. return 0;
  69. }
  70. lua_pushstring(state, "lua_FrameBuffer__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_FrameBuffer_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. FrameBuffer* instance = getInstance(state);
  95. instance->addRef();
  96. return 0;
  97. }
  98. lua_pushstring(state, "lua_FrameBuffer_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_FrameBuffer_bind(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. FrameBuffer* instance = getInstance(state);
  123. void* returnPtr = (void*)instance->bind();
  124. if (returnPtr)
  125. {
  126. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  127. object->instance = returnPtr;
  128. object->owns = false;
  129. luaL_getmetatable(state, "FrameBuffer");
  130. lua_setmetatable(state, -2);
  131. }
  132. else
  133. {
  134. lua_pushnil(state);
  135. }
  136. return 1;
  137. }
  138. lua_pushstring(state, "lua_FrameBuffer_bind - Failed to match the given parameters to a valid function signature.");
  139. lua_error(state);
  140. break;
  141. }
  142. default:
  143. {
  144. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  145. lua_error(state);
  146. break;
  147. }
  148. }
  149. return 0;
  150. }
  151. int lua_FrameBuffer_getDepthStencilTarget(lua_State* state)
  152. {
  153. // Get the number of parameters.
  154. int paramCount = lua_gettop(state);
  155. // Attempt to match the parameters to a valid binding.
  156. switch (paramCount)
  157. {
  158. case 1:
  159. {
  160. if ((lua_type(state, 1) == LUA_TUSERDATA))
  161. {
  162. FrameBuffer* instance = getInstance(state);
  163. void* returnPtr = (void*)instance->getDepthStencilTarget();
  164. if (returnPtr)
  165. {
  166. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  167. object->instance = returnPtr;
  168. object->owns = false;
  169. luaL_getmetatable(state, "DepthStencilTarget");
  170. lua_setmetatable(state, -2);
  171. }
  172. else
  173. {
  174. lua_pushnil(state);
  175. }
  176. return 1;
  177. }
  178. lua_pushstring(state, "lua_FrameBuffer_getDepthStencilTarget - Failed to match the given parameters to a valid function signature.");
  179. lua_error(state);
  180. break;
  181. }
  182. default:
  183. {
  184. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  185. lua_error(state);
  186. break;
  187. }
  188. }
  189. return 0;
  190. }
  191. int lua_FrameBuffer_getHeight(lua_State* state)
  192. {
  193. // Get the number of parameters.
  194. int paramCount = lua_gettop(state);
  195. // Attempt to match the parameters to a valid binding.
  196. switch (paramCount)
  197. {
  198. case 1:
  199. {
  200. if ((lua_type(state, 1) == LUA_TUSERDATA))
  201. {
  202. FrameBuffer* instance = getInstance(state);
  203. unsigned int result = instance->getHeight();
  204. // Push the return value onto the stack.
  205. lua_pushunsigned(state, result);
  206. return 1;
  207. }
  208. lua_pushstring(state, "lua_FrameBuffer_getHeight - Failed to match the given parameters to a valid function signature.");
  209. lua_error(state);
  210. break;
  211. }
  212. default:
  213. {
  214. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  215. lua_error(state);
  216. break;
  217. }
  218. }
  219. return 0;
  220. }
  221. int lua_FrameBuffer_getId(lua_State* state)
  222. {
  223. // Get the number of parameters.
  224. int paramCount = lua_gettop(state);
  225. // Attempt to match the parameters to a valid binding.
  226. switch (paramCount)
  227. {
  228. case 1:
  229. {
  230. if ((lua_type(state, 1) == LUA_TUSERDATA))
  231. {
  232. FrameBuffer* instance = getInstance(state);
  233. const char* result = instance->getId();
  234. // Push the return value onto the stack.
  235. lua_pushstring(state, result);
  236. return 1;
  237. }
  238. lua_pushstring(state, "lua_FrameBuffer_getId - Failed to match the given parameters to a valid function signature.");
  239. lua_error(state);
  240. break;
  241. }
  242. default:
  243. {
  244. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  245. lua_error(state);
  246. break;
  247. }
  248. }
  249. return 0;
  250. }
  251. int lua_FrameBuffer_getRefCount(lua_State* state)
  252. {
  253. // Get the number of parameters.
  254. int paramCount = lua_gettop(state);
  255. // Attempt to match the parameters to a valid binding.
  256. switch (paramCount)
  257. {
  258. case 1:
  259. {
  260. if ((lua_type(state, 1) == LUA_TUSERDATA))
  261. {
  262. FrameBuffer* instance = getInstance(state);
  263. unsigned int result = instance->getRefCount();
  264. // Push the return value onto the stack.
  265. lua_pushunsigned(state, result);
  266. return 1;
  267. }
  268. lua_pushstring(state, "lua_FrameBuffer_getRefCount - Failed to match the given parameters to a valid function signature.");
  269. lua_error(state);
  270. break;
  271. }
  272. default:
  273. {
  274. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  275. lua_error(state);
  276. break;
  277. }
  278. }
  279. return 0;
  280. }
  281. int lua_FrameBuffer_getRenderTarget(lua_State* state)
  282. {
  283. // Get the number of parameters.
  284. int paramCount = lua_gettop(state);
  285. // Attempt to match the parameters to a valid binding.
  286. switch (paramCount)
  287. {
  288. case 1:
  289. {
  290. if ((lua_type(state, 1) == LUA_TUSERDATA))
  291. {
  292. FrameBuffer* instance = getInstance(state);
  293. void* returnPtr = (void*)instance->getRenderTarget();
  294. if (returnPtr)
  295. {
  296. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  297. object->instance = returnPtr;
  298. object->owns = false;
  299. luaL_getmetatable(state, "RenderTarget");
  300. lua_setmetatable(state, -2);
  301. }
  302. else
  303. {
  304. lua_pushnil(state);
  305. }
  306. return 1;
  307. }
  308. lua_pushstring(state, "lua_FrameBuffer_getRenderTarget - Failed to match the given parameters to a valid function signature.");
  309. lua_error(state);
  310. break;
  311. }
  312. case 2:
  313. {
  314. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  315. lua_type(state, 2) == LUA_TNUMBER)
  316. {
  317. // Get parameter 1 off the stack.
  318. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  319. FrameBuffer* instance = getInstance(state);
  320. void* returnPtr = (void*)instance->getRenderTarget(param1);
  321. if (returnPtr)
  322. {
  323. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  324. object->instance = returnPtr;
  325. object->owns = false;
  326. luaL_getmetatable(state, "RenderTarget");
  327. lua_setmetatable(state, -2);
  328. }
  329. else
  330. {
  331. lua_pushnil(state);
  332. }
  333. return 1;
  334. }
  335. lua_pushstring(state, "lua_FrameBuffer_getRenderTarget - Failed to match the given parameters to a valid function signature.");
  336. lua_error(state);
  337. break;
  338. }
  339. default:
  340. {
  341. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  342. lua_error(state);
  343. break;
  344. }
  345. }
  346. return 0;
  347. }
  348. int lua_FrameBuffer_getRenderTargetCount(lua_State* state)
  349. {
  350. // Get the number of parameters.
  351. int paramCount = lua_gettop(state);
  352. // Attempt to match the parameters to a valid binding.
  353. switch (paramCount)
  354. {
  355. case 1:
  356. {
  357. if ((lua_type(state, 1) == LUA_TUSERDATA))
  358. {
  359. FrameBuffer* instance = getInstance(state);
  360. unsigned int result = instance->getRenderTargetCount();
  361. // Push the return value onto the stack.
  362. lua_pushunsigned(state, result);
  363. return 1;
  364. }
  365. lua_pushstring(state, "lua_FrameBuffer_getRenderTargetCount - Failed to match the given parameters to a valid function signature.");
  366. lua_error(state);
  367. break;
  368. }
  369. default:
  370. {
  371. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  372. lua_error(state);
  373. break;
  374. }
  375. }
  376. return 0;
  377. }
  378. int lua_FrameBuffer_getWidth(lua_State* state)
  379. {
  380. // Get the number of parameters.
  381. int paramCount = lua_gettop(state);
  382. // Attempt to match the parameters to a valid binding.
  383. switch (paramCount)
  384. {
  385. case 1:
  386. {
  387. if ((lua_type(state, 1) == LUA_TUSERDATA))
  388. {
  389. FrameBuffer* instance = getInstance(state);
  390. unsigned int result = instance->getWidth();
  391. // Push the return value onto the stack.
  392. lua_pushunsigned(state, result);
  393. return 1;
  394. }
  395. lua_pushstring(state, "lua_FrameBuffer_getWidth - Failed to match the given parameters to a valid function signature.");
  396. lua_error(state);
  397. break;
  398. }
  399. default:
  400. {
  401. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  402. lua_error(state);
  403. break;
  404. }
  405. }
  406. return 0;
  407. }
  408. int lua_FrameBuffer_isDefault(lua_State* state)
  409. {
  410. // Get the number of parameters.
  411. int paramCount = lua_gettop(state);
  412. // Attempt to match the parameters to a valid binding.
  413. switch (paramCount)
  414. {
  415. case 1:
  416. {
  417. if ((lua_type(state, 1) == LUA_TUSERDATA))
  418. {
  419. FrameBuffer* instance = getInstance(state);
  420. bool result = instance->isDefault();
  421. // Push the return value onto the stack.
  422. lua_pushboolean(state, result);
  423. return 1;
  424. }
  425. lua_pushstring(state, "lua_FrameBuffer_isDefault - Failed to match the given parameters to a valid function signature.");
  426. lua_error(state);
  427. break;
  428. }
  429. default:
  430. {
  431. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  432. lua_error(state);
  433. break;
  434. }
  435. }
  436. return 0;
  437. }
  438. int lua_FrameBuffer_release(lua_State* state)
  439. {
  440. // Get the number of parameters.
  441. int paramCount = lua_gettop(state);
  442. // Attempt to match the parameters to a valid binding.
  443. switch (paramCount)
  444. {
  445. case 1:
  446. {
  447. if ((lua_type(state, 1) == LUA_TUSERDATA))
  448. {
  449. FrameBuffer* instance = getInstance(state);
  450. instance->release();
  451. return 0;
  452. }
  453. lua_pushstring(state, "lua_FrameBuffer_release - Failed to match the given parameters to a valid function signature.");
  454. lua_error(state);
  455. break;
  456. }
  457. default:
  458. {
  459. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  460. lua_error(state);
  461. break;
  462. }
  463. }
  464. return 0;
  465. }
  466. int lua_FrameBuffer_setDepthStencilTarget(lua_State* state)
  467. {
  468. // Get the number of parameters.
  469. int paramCount = lua_gettop(state);
  470. // Attempt to match the parameters to a valid binding.
  471. switch (paramCount)
  472. {
  473. case 2:
  474. {
  475. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  476. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  477. {
  478. // Get parameter 1 off the stack.
  479. bool param1Valid;
  480. gameplay::ScriptUtil::LuaArray<DepthStencilTarget> param1 = gameplay::ScriptUtil::getObjectPointer<DepthStencilTarget>(2, "DepthStencilTarget", false, &param1Valid);
  481. if (!param1Valid)
  482. {
  483. lua_pushstring(state, "Failed to convert parameter 1 to type 'DepthStencilTarget'.");
  484. lua_error(state);
  485. }
  486. FrameBuffer* instance = getInstance(state);
  487. instance->setDepthStencilTarget(param1);
  488. return 0;
  489. }
  490. lua_pushstring(state, "lua_FrameBuffer_setDepthStencilTarget - Failed to match the given parameters to a valid function signature.");
  491. lua_error(state);
  492. break;
  493. }
  494. default:
  495. {
  496. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  497. lua_error(state);
  498. break;
  499. }
  500. }
  501. return 0;
  502. }
  503. int lua_FrameBuffer_setRenderTarget(lua_State* state)
  504. {
  505. // Get the number of parameters.
  506. int paramCount = lua_gettop(state);
  507. // Attempt to match the parameters to a valid binding.
  508. switch (paramCount)
  509. {
  510. case 2:
  511. {
  512. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  513. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  514. {
  515. // Get parameter 1 off the stack.
  516. bool param1Valid;
  517. gameplay::ScriptUtil::LuaArray<RenderTarget> param1 = gameplay::ScriptUtil::getObjectPointer<RenderTarget>(2, "RenderTarget", false, &param1Valid);
  518. if (!param1Valid)
  519. {
  520. lua_pushstring(state, "Failed to convert parameter 1 to type 'RenderTarget'.");
  521. lua_error(state);
  522. }
  523. FrameBuffer* instance = getInstance(state);
  524. instance->setRenderTarget(param1);
  525. return 0;
  526. }
  527. lua_pushstring(state, "lua_FrameBuffer_setRenderTarget - Failed to match the given parameters to a valid function signature.");
  528. lua_error(state);
  529. break;
  530. }
  531. case 3:
  532. {
  533. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  534. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  535. lua_type(state, 3) == LUA_TNUMBER)
  536. {
  537. // Get parameter 1 off the stack.
  538. bool param1Valid;
  539. gameplay::ScriptUtil::LuaArray<RenderTarget> param1 = gameplay::ScriptUtil::getObjectPointer<RenderTarget>(2, "RenderTarget", false, &param1Valid);
  540. if (!param1Valid)
  541. {
  542. lua_pushstring(state, "Failed to convert parameter 1 to type 'RenderTarget'.");
  543. lua_error(state);
  544. }
  545. // Get parameter 2 off the stack.
  546. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
  547. FrameBuffer* instance = getInstance(state);
  548. instance->setRenderTarget(param1, param2);
  549. return 0;
  550. }
  551. lua_pushstring(state, "lua_FrameBuffer_setRenderTarget - Failed to match the given parameters to a valid function signature.");
  552. lua_error(state);
  553. break;
  554. }
  555. default:
  556. {
  557. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  558. lua_error(state);
  559. break;
  560. }
  561. }
  562. return 0;
  563. }
  564. int lua_FrameBuffer_static_bindDefault(lua_State* state)
  565. {
  566. // Get the number of parameters.
  567. int paramCount = lua_gettop(state);
  568. // Attempt to match the parameters to a valid binding.
  569. switch (paramCount)
  570. {
  571. case 0:
  572. {
  573. void* returnPtr = (void*)FrameBuffer::bindDefault();
  574. if (returnPtr)
  575. {
  576. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  577. object->instance = returnPtr;
  578. object->owns = false;
  579. luaL_getmetatable(state, "FrameBuffer");
  580. lua_setmetatable(state, -2);
  581. }
  582. else
  583. {
  584. lua_pushnil(state);
  585. }
  586. return 1;
  587. break;
  588. }
  589. default:
  590. {
  591. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  592. lua_error(state);
  593. break;
  594. }
  595. }
  596. return 0;
  597. }
  598. int lua_FrameBuffer_static_create(lua_State* state)
  599. {
  600. // Get the number of parameters.
  601. int paramCount = lua_gettop(state);
  602. // Attempt to match the parameters to a valid binding.
  603. switch (paramCount)
  604. {
  605. case 1:
  606. {
  607. do
  608. {
  609. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  610. {
  611. // Get parameter 1 off the stack.
  612. const char* param1 = gameplay::ScriptUtil::getString(1, false);
  613. void* returnPtr = (void*)FrameBuffer::create(param1);
  614. if (returnPtr)
  615. {
  616. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  617. object->instance = returnPtr;
  618. object->owns = true;
  619. luaL_getmetatable(state, "FrameBuffer");
  620. lua_setmetatable(state, -2);
  621. }
  622. else
  623. {
  624. lua_pushnil(state);
  625. }
  626. return 1;
  627. }
  628. } while (0);
  629. lua_pushstring(state, "lua_FrameBuffer_static_create - Failed to match the given parameters to a valid function signature.");
  630. lua_error(state);
  631. break;
  632. }
  633. case 3:
  634. {
  635. do
  636. {
  637. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
  638. lua_type(state, 2) == LUA_TNUMBER &&
  639. lua_type(state, 3) == LUA_TNUMBER)
  640. {
  641. // Get parameter 1 off the stack.
  642. const char* param1 = gameplay::ScriptUtil::getString(1, false);
  643. // Get parameter 2 off the stack.
  644. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
  645. // Get parameter 3 off the stack.
  646. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  647. void* returnPtr = (void*)FrameBuffer::create(param1, param2, param3);
  648. if (returnPtr)
  649. {
  650. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  651. object->instance = returnPtr;
  652. object->owns = true;
  653. luaL_getmetatable(state, "FrameBuffer");
  654. lua_setmetatable(state, -2);
  655. }
  656. else
  657. {
  658. lua_pushnil(state);
  659. }
  660. return 1;
  661. }
  662. } while (0);
  663. lua_pushstring(state, "lua_FrameBuffer_static_create - Failed to match the given parameters to a valid function signature.");
  664. lua_error(state);
  665. break;
  666. }
  667. default:
  668. {
  669. lua_pushstring(state, "Invalid number of parameters (expected 1 or 3).");
  670. lua_error(state);
  671. break;
  672. }
  673. }
  674. return 0;
  675. }
  676. int lua_FrameBuffer_static_createScreenshot(lua_State* state)
  677. {
  678. // Get the number of parameters.
  679. int paramCount = lua_gettop(state);
  680. // Attempt to match the parameters to a valid binding.
  681. switch (paramCount)
  682. {
  683. case 0:
  684. {
  685. void* returnPtr = (void*)FrameBuffer::createScreenshot();
  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 = false;
  691. luaL_getmetatable(state, "Image");
  692. lua_setmetatable(state, -2);
  693. }
  694. else
  695. {
  696. lua_pushnil(state);
  697. }
  698. return 1;
  699. break;
  700. }
  701. default:
  702. {
  703. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  704. lua_error(state);
  705. break;
  706. }
  707. }
  708. return 0;
  709. }
  710. int lua_FrameBuffer_static_getCurrent(lua_State* state)
  711. {
  712. // Get the number of parameters.
  713. int paramCount = lua_gettop(state);
  714. // Attempt to match the parameters to a valid binding.
  715. switch (paramCount)
  716. {
  717. case 0:
  718. {
  719. void* returnPtr = (void*)FrameBuffer::getCurrent();
  720. if (returnPtr)
  721. {
  722. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  723. object->instance = returnPtr;
  724. object->owns = false;
  725. luaL_getmetatable(state, "FrameBuffer");
  726. lua_setmetatable(state, -2);
  727. }
  728. else
  729. {
  730. lua_pushnil(state);
  731. }
  732. return 1;
  733. break;
  734. }
  735. default:
  736. {
  737. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  738. lua_error(state);
  739. break;
  740. }
  741. }
  742. return 0;
  743. }
  744. int lua_FrameBuffer_static_getFrameBuffer(lua_State* state)
  745. {
  746. // Get the number of parameters.
  747. int paramCount = lua_gettop(state);
  748. // Attempt to match the parameters to a valid binding.
  749. switch (paramCount)
  750. {
  751. case 1:
  752. {
  753. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  754. {
  755. // Get parameter 1 off the stack.
  756. const char* param1 = gameplay::ScriptUtil::getString(1, false);
  757. void* returnPtr = (void*)FrameBuffer::getFrameBuffer(param1);
  758. if (returnPtr)
  759. {
  760. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  761. object->instance = returnPtr;
  762. object->owns = false;
  763. luaL_getmetatable(state, "FrameBuffer");
  764. lua_setmetatable(state, -2);
  765. }
  766. else
  767. {
  768. lua_pushnil(state);
  769. }
  770. return 1;
  771. }
  772. lua_pushstring(state, "lua_FrameBuffer_static_getFrameBuffer - Failed to match the given parameters to a valid function signature.");
  773. lua_error(state);
  774. break;
  775. }
  776. default:
  777. {
  778. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  779. lua_error(state);
  780. break;
  781. }
  782. }
  783. return 0;
  784. }
  785. int lua_FrameBuffer_static_getMaxRenderTargets(lua_State* state)
  786. {
  787. // Get the number of parameters.
  788. int paramCount = lua_gettop(state);
  789. // Attempt to match the parameters to a valid binding.
  790. switch (paramCount)
  791. {
  792. case 0:
  793. {
  794. unsigned int result = FrameBuffer::getMaxRenderTargets();
  795. // Push the return value onto the stack.
  796. lua_pushunsigned(state, result);
  797. return 1;
  798. break;
  799. }
  800. default:
  801. {
  802. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  803. lua_error(state);
  804. break;
  805. }
  806. }
  807. return 0;
  808. }
  809. int lua_FrameBuffer_static_getScreenshot(lua_State* state)
  810. {
  811. // Get the number of parameters.
  812. int paramCount = lua_gettop(state);
  813. // Attempt to match the parameters to a valid binding.
  814. switch (paramCount)
  815. {
  816. case 1:
  817. {
  818. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  819. {
  820. // Get parameter 1 off the stack.
  821. bool param1Valid;
  822. gameplay::ScriptUtil::LuaArray<Image> param1 = gameplay::ScriptUtil::getObjectPointer<Image>(1, "Image", false, &param1Valid);
  823. if (!param1Valid)
  824. {
  825. lua_pushstring(state, "Failed to convert parameter 1 to type 'Image'.");
  826. lua_error(state);
  827. }
  828. FrameBuffer::getScreenshot(param1);
  829. return 0;
  830. }
  831. lua_pushstring(state, "lua_FrameBuffer_static_getScreenshot - Failed to match the given parameters to a valid function signature.");
  832. lua_error(state);
  833. break;
  834. }
  835. default:
  836. {
  837. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  838. lua_error(state);
  839. break;
  840. }
  841. }
  842. return 0;
  843. }
  844. }