lua_FrameBuffer.cpp 28 KB

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