lua_FrameBuffer.cpp 33 KB

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