lua_FrameBuffer.cpp 29 KB

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