visual_server_wrap_mt.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. /*************************************************************************/
  2. /* visual_server_wrap_mt.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef VISUAL_SERVER_WRAP_MT_H
  30. #define VISUAL_SERVER_WRAP_MT_H
  31. #include "servers/visual_server.h"
  32. #include "command_queue_mt.h"
  33. #include "os/thread.h"
  34. /**
  35. @author Juan Linietsky <reduzio@gmail.com>
  36. */
  37. class VisualServerWrapMT : public VisualServer {
  38. // the real visual server
  39. mutable VisualServer *visual_server;
  40. mutable CommandQueueMT command_queue;
  41. static void _thread_callback(void *_instance);
  42. void thread_loop();
  43. Thread::ID server_thread;
  44. volatile bool exit;
  45. Thread *thread;
  46. volatile bool draw_thread_up;
  47. bool create_thread;
  48. Mutex *draw_mutex;
  49. int draw_pending;
  50. void thread_draw();
  51. void thread_flush();
  52. void thread_exit();
  53. Mutex*alloc_mutex;
  54. int texture_pool_max_size;
  55. List<RID> texture_id_pool;
  56. int mesh_pool_max_size;
  57. List<RID> mesh_id_pool;
  58. //#define DEBUG_SYNC
  59. #ifdef DEBUG_SYNC
  60. #define SYNC_DEBUG print_line("sync on: "+String(__FUNCTION__));
  61. #else
  62. #define SYNC_DEBUG
  63. #endif
  64. public:
  65. #define FUNC0R(m_r,m_type)\
  66. virtual m_r m_type() { \
  67. if (Thread::get_caller_ID()!=server_thread) {\
  68. m_r ret;\
  69. command_queue.push_and_ret( visual_server, &VisualServer::m_type,&ret);\
  70. SYNC_DEBUG\
  71. return ret;\
  72. } else {\
  73. return visual_server->m_type();\
  74. }\
  75. }
  76. #define FUNCRID(m_type)\
  77. int m_type##allocn() {\
  78. for(int i=0;i<m_type##_pool_max_size;i++) {\
  79. m_type##_id_pool.push_back( visual_server->m_type##_create() );\
  80. }\
  81. return 0;\
  82. }\
  83. void m_type##_free_cached_ids() {\
  84. while (m_type##_id_pool.size()) {\
  85. free(m_type##_id_pool.front()->get());\
  86. m_type##_id_pool.pop_front();\
  87. }\
  88. }\
  89. virtual RID m_type##_create() { \
  90. if (Thread::get_caller_ID()!=server_thread) {\
  91. RID rid;\
  92. alloc_mutex->lock();\
  93. if (m_type##_id_pool.size()==0) {\
  94. int ret;\
  95. command_queue.push_and_ret( this, &VisualServerWrapMT::m_type##allocn,&ret);\
  96. }\
  97. rid=m_type##_id_pool.front()->get();\
  98. m_type##_id_pool.pop_front();\
  99. alloc_mutex->unlock();\
  100. return rid;\
  101. } else {\
  102. return visual_server->m_type##_create();\
  103. }\
  104. }
  105. #define FUNC0RC(m_r,m_type)\
  106. virtual m_r m_type() const { \
  107. if (Thread::get_caller_ID()!=server_thread) {\
  108. m_r ret;\
  109. command_queue.push_and_ret( visual_server, &VisualServer::m_type,&ret);\
  110. SYNC_DEBUG\
  111. return ret;\
  112. } else {\
  113. return visual_server->m_type();\
  114. }\
  115. }
  116. #define FUNC0(m_type)\
  117. virtual void m_type() { \
  118. if (Thread::get_caller_ID()!=server_thread) {\
  119. command_queue.push( visual_server, &VisualServer::m_type);\
  120. } else {\
  121. visual_server->m_type();\
  122. }\
  123. }
  124. #define FUNC0C(m_type)\
  125. virtual void m_type() const { \
  126. if (Thread::get_caller_ID()!=server_thread) {\
  127. command_queue.push( visual_server, &VisualServer::m_type);\
  128. } else {\
  129. visual_server->m_type();\
  130. }\
  131. }
  132. #define FUNC0S(m_type)\
  133. virtual void m_type() { \
  134. if (Thread::get_caller_ID()!=server_thread) {\
  135. command_queue.push_and_sync( visual_server, &VisualServer::m_type);\
  136. } else {\
  137. visual_server->m_type();\
  138. }\
  139. }
  140. #define FUNC0SC(m_type)\
  141. virtual void m_type() const { \
  142. if (Thread::get_caller_ID()!=server_thread) {\
  143. command_queue.push_and_sync( visual_server, &VisualServer::m_type);\
  144. } else {\
  145. visual_server->m_type();\
  146. }\
  147. }
  148. ///////////////////////////////////////////////
  149. #define FUNC1R(m_r,m_type,m_arg1)\
  150. virtual m_r m_type(m_arg1 p1) { \
  151. if (Thread::get_caller_ID()!=server_thread) {\
  152. m_r ret;\
  153. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1,&ret);\
  154. SYNC_DEBUG\
  155. return ret;\
  156. } else {\
  157. return visual_server->m_type(p1);\
  158. }\
  159. }
  160. #define FUNC1RC(m_r,m_type,m_arg1)\
  161. virtual m_r m_type(m_arg1 p1) const { \
  162. if (Thread::get_caller_ID()!=server_thread) {\
  163. m_r ret;\
  164. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1,&ret);\
  165. SYNC_DEBUG\
  166. return ret;\
  167. } else {\
  168. return visual_server->m_type(p1);\
  169. }\
  170. }
  171. #define FUNC1S(m_type,m_arg1)\
  172. virtual void m_type(m_arg1 p1) { \
  173. if (Thread::get_caller_ID()!=server_thread) {\
  174. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1);\
  175. } else {\
  176. visual_server->m_type(p1);\
  177. }\
  178. }
  179. #define FUNC1SC(m_type,m_arg1)\
  180. virtual void m_type(m_arg1 p1) const { \
  181. if (Thread::get_caller_ID()!=server_thread) {\
  182. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1);\
  183. } else {\
  184. visual_server->m_type(p1);\
  185. }\
  186. }
  187. #define FUNC1(m_type,m_arg1)\
  188. virtual void m_type(m_arg1 p1) { \
  189. if (Thread::get_caller_ID()!=server_thread) {\
  190. command_queue.push( visual_server, &VisualServer::m_type,p1);\
  191. } else {\
  192. visual_server->m_type(p1);\
  193. }\
  194. }
  195. #define FUNC1C(m_type,m_arg1)\
  196. virtual void m_type(m_arg1 p1) const { \
  197. if (Thread::get_caller_ID()!=server_thread) {\
  198. command_queue.push( visual_server, &VisualServer::m_type,p1);\
  199. } else {\
  200. visual_server->m_type(p1);\
  201. }\
  202. }
  203. #define FUNC2R(m_r,m_type,m_arg1, m_arg2)\
  204. virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
  205. if (Thread::get_caller_ID()!=server_thread) {\
  206. m_r ret;\
  207. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2,&ret);\
  208. SYNC_DEBUG\
  209. return ret;\
  210. } else {\
  211. return visual_server->m_type(p1, p2);\
  212. }\
  213. }
  214. #define FUNC2RC(m_r,m_type,m_arg1, m_arg2)\
  215. virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
  216. if (Thread::get_caller_ID()!=server_thread) {\
  217. m_r ret;\
  218. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2,&ret);\
  219. SYNC_DEBUG\
  220. return ret;\
  221. } else {\
  222. return visual_server->m_type(p1, p2);\
  223. }\
  224. }
  225. #define FUNC2S(m_type,m_arg1, m_arg2)\
  226. virtual void m_type(m_arg1 p1, m_arg2 p2) { \
  227. if (Thread::get_caller_ID()!=server_thread) {\
  228. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2);\
  229. } else {\
  230. visual_server->m_type(p1, p2);\
  231. }\
  232. }
  233. #define FUNC2SC(m_type,m_arg1, m_arg2)\
  234. virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
  235. if (Thread::get_caller_ID()!=server_thread) {\
  236. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2);\
  237. } else {\
  238. visual_server->m_type(p1, p2);\
  239. }\
  240. }
  241. #define FUNC2(m_type,m_arg1, m_arg2)\
  242. virtual void m_type(m_arg1 p1, m_arg2 p2) { \
  243. if (Thread::get_caller_ID()!=server_thread) {\
  244. command_queue.push( visual_server, &VisualServer::m_type,p1, p2);\
  245. } else {\
  246. visual_server->m_type(p1, p2);\
  247. }\
  248. }
  249. #define FUNC2C(m_type,m_arg1, m_arg2)\
  250. virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
  251. if (Thread::get_caller_ID()!=server_thread) {\
  252. command_queue.push( visual_server, &VisualServer::m_type,p1, p2);\
  253. } else {\
  254. visual_server->m_type(p1, p2);\
  255. }\
  256. }
  257. #define FUNC3R(m_r,m_type,m_arg1, m_arg2, m_arg3)\
  258. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  259. if (Thread::get_caller_ID()!=server_thread) {\
  260. m_r ret;\
  261. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3,&ret);\
  262. SYNC_DEBUG\
  263. return ret;\
  264. } else {\
  265. return visual_server->m_type(p1, p2, p3);\
  266. }\
  267. }
  268. #define FUNC3RC(m_r,m_type,m_arg1, m_arg2, m_arg3)\
  269. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  270. if (Thread::get_caller_ID()!=server_thread) {\
  271. m_r ret;\
  272. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3,&ret);\
  273. return ret;\
  274. } else {\
  275. return visual_server->m_type(p1, p2, p3);\
  276. }\
  277. }
  278. #define FUNC3S(m_type,m_arg1, m_arg2, m_arg3)\
  279. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  280. if (Thread::get_caller_ID()!=server_thread) {\
  281. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3);\
  282. } else {\
  283. visual_server->m_type(p1, p2, p3);\
  284. }\
  285. }
  286. #define FUNC3SC(m_type,m_arg1, m_arg2, m_arg3)\
  287. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  288. if (Thread::get_caller_ID()!=server_thread) {\
  289. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3);\
  290. } else {\
  291. visual_server->m_type(p1, p2, p3);\
  292. }\
  293. }
  294. #define FUNC3(m_type,m_arg1, m_arg2, m_arg3)\
  295. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
  296. if (Thread::get_caller_ID()!=server_thread) {\
  297. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3);\
  298. } else {\
  299. visual_server->m_type(p1, p2, p3);\
  300. }\
  301. }
  302. #define FUNC3C(m_type,m_arg1, m_arg2, m_arg3)\
  303. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
  304. if (Thread::get_caller_ID()!=server_thread) {\
  305. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3);\
  306. } else {\
  307. visual_server->m_type(p1, p2, p3);\
  308. }\
  309. }
  310. #define FUNC4R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
  311. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  312. if (Thread::get_caller_ID()!=server_thread) {\
  313. m_r ret;\
  314. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4,&ret);\
  315. SYNC_DEBUG\
  316. return ret;\
  317. } else {\
  318. return visual_server->m_type(p1, p2, p3, p4);\
  319. }\
  320. }
  321. #define FUNC4RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
  322. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  323. if (Thread::get_caller_ID()!=server_thread) {\
  324. m_r ret;\
  325. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4,&ret);\
  326. SYNC_DEBUG\
  327. return ret;\
  328. } else {\
  329. return visual_server->m_type(p1, p2, p3, p4);\
  330. }\
  331. }
  332. #define FUNC4S(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
  333. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  334. if (Thread::get_caller_ID()!=server_thread) {\
  335. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
  336. } else {\
  337. visual_server->m_type(p1, p2, p3, p4);\
  338. }\
  339. }
  340. #define FUNC4SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
  341. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  342. if (Thread::get_caller_ID()!=server_thread) {\
  343. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
  344. } else {\
  345. visual_server->m_type(p1, p2, p3, p4);\
  346. }\
  347. }
  348. #define FUNC4(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
  349. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
  350. if (Thread::get_caller_ID()!=server_thread) {\
  351. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
  352. } else {\
  353. visual_server->m_type(p1, p2, p3, p4);\
  354. }\
  355. }
  356. #define FUNC4C(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
  357. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
  358. if (Thread::get_caller_ID()!=server_thread) {\
  359. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
  360. } else {\
  361. visual_server->m_type(p1, p2, p3, p4);\
  362. }\
  363. }
  364. #define FUNC5R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
  365. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  366. if (Thread::get_caller_ID()!=server_thread) {\
  367. m_r ret;\
  368. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5,&ret);\
  369. SYNC_DEBUG\
  370. return ret;\
  371. } else {\
  372. return visual_server->m_type(p1, p2, p3, p4, p5);\
  373. }\
  374. }
  375. #define FUNC5RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
  376. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  377. if (Thread::get_caller_ID()!=server_thread) {\
  378. m_r ret;\
  379. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5,&ret);\
  380. SYNC_DEBUG\
  381. return ret;\
  382. } else {\
  383. return visual_server->m_type(p1, p2, p3, p4, p5);\
  384. }\
  385. }
  386. #define FUNC5S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
  387. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  388. if (Thread::get_caller_ID()!=server_thread) {\
  389. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
  390. } else {\
  391. visual_server->m_type(p1, p2, p3, p4, p5);\
  392. }\
  393. }
  394. #define FUNC5SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
  395. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  396. if (Thread::get_caller_ID()!=server_thread) {\
  397. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
  398. } else {\
  399. visual_server->m_type(p1, p2, p3, p4, p5);\
  400. }\
  401. }
  402. #define FUNC5(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
  403. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
  404. if (Thread::get_caller_ID()!=server_thread) {\
  405. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
  406. } else {\
  407. visual_server->m_type(p1, p2, p3, p4, p5);\
  408. }\
  409. }
  410. #define FUNC5C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
  411. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
  412. if (Thread::get_caller_ID()!=server_thread) {\
  413. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
  414. } else {\
  415. visual_server->m_type(p1, p2, p3, p4, p5);\
  416. }\
  417. }
  418. #define FUNC6R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
  419. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  420. if (Thread::get_caller_ID()!=server_thread) {\
  421. m_r ret;\
  422. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6,&ret);\
  423. SYNC_DEBUG\
  424. return ret;\
  425. } else {\
  426. return visual_server->m_type(p1, p2, p3, p4, p5, p6);\
  427. }\
  428. }
  429. #define FUNC6RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
  430. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  431. if (Thread::get_caller_ID()!=server_thread) {\
  432. m_r ret;\
  433. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6,&ret);\
  434. return ret;\
  435. } else {\
  436. return visual_server->m_type(p1, p2, p3, p4, p5, p6);\
  437. }\
  438. }
  439. #define FUNC6S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
  440. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  441. if (Thread::get_caller_ID()!=server_thread) {\
  442. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
  443. } else {\
  444. visual_server->m_type(p1, p2, p3, p4, p5, p6);\
  445. }\
  446. }
  447. #define FUNC6SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
  448. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  449. if (Thread::get_caller_ID()!=server_thread) {\
  450. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
  451. } else {\
  452. visual_server->m_type(p1, p2, p3, p4, p5, p6);\
  453. }\
  454. }
  455. #define FUNC6(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
  456. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
  457. if (Thread::get_caller_ID()!=server_thread) {\
  458. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
  459. } else {\
  460. visual_server->m_type(p1, p2, p3, p4, p5, p6);\
  461. }\
  462. }
  463. #define FUNC6C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
  464. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
  465. if (Thread::get_caller_ID()!=server_thread) {\
  466. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
  467. } else {\
  468. visual_server->m_type(p1, p2, p3, p4, p5, p6);\
  469. }\
  470. }
  471. #define FUNC7R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
  472. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
  473. if (Thread::get_caller_ID()!=server_thread) {\
  474. m_r ret;\
  475. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
  476. SYNC_DEBUG\
  477. return ret;\
  478. } else {\
  479. return visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
  480. }\
  481. }
  482. #define FUNC7RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
  483. virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
  484. if (Thread::get_caller_ID()!=server_thread) {\
  485. m_r ret;\
  486. command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
  487. SYNC_DEBUG\
  488. return ret;\
  489. } else {\
  490. return visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
  491. }\
  492. }
  493. #define FUNC7S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
  494. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
  495. if (Thread::get_caller_ID()!=server_thread) {\
  496. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
  497. } else {\
  498. visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
  499. }\
  500. }
  501. #define FUNC7SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
  502. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
  503. if (Thread::get_caller_ID()!=server_thread) {\
  504. command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
  505. } else {\
  506. visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
  507. }\
  508. }
  509. #define FUNC7(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
  510. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
  511. if (Thread::get_caller_ID()!=server_thread) {\
  512. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
  513. } else {\
  514. visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
  515. }\
  516. }
  517. #define FUNC7C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
  518. virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
  519. if (Thread::get_caller_ID()!=server_thread) {\
  520. command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
  521. } else {\
  522. visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
  523. }\
  524. }
  525. //FUNC0R(RID,texture_create);
  526. FUNCRID(texture);
  527. FUNC5(texture_allocate,RID,int,int,Image::Format,uint32_t);
  528. FUNC3(texture_set_data,RID,const Image&,CubeMapSide);
  529. FUNC2RC(Image,texture_get_data,RID,CubeMapSide);
  530. FUNC2(texture_set_flags,RID,uint32_t);
  531. FUNC1RC(Image::Format,texture_get_format,RID);
  532. FUNC1RC(uint32_t,texture_get_flags,RID);
  533. FUNC1RC(uint32_t,texture_get_width,RID);
  534. FUNC1RC(uint32_t,texture_get_height,RID);
  535. FUNC3(texture_set_size_override,RID,int,int);
  536. FUNC1RC(bool,texture_can_stream,RID);
  537. FUNC3C(texture_set_reload_hook,RID,ObjectID,const StringName&);
  538. /* SHADER API */
  539. FUNC1R(RID,shader_create,ShaderMode);
  540. FUNC2(shader_set_mode,RID,ShaderMode);
  541. FUNC1RC(ShaderMode,shader_get_mode,RID);
  542. FUNC7(shader_set_code,RID,const String&,const String&,const String&,int,int,int);
  543. FUNC1RC(String,shader_get_vertex_code,RID);
  544. FUNC1RC(String,shader_get_fragment_code,RID);
  545. FUNC1RC(String,shader_get_light_code,RID);
  546. FUNC2SC(shader_get_param_list,RID,List<PropertyInfo>*);
  547. FUNC3(shader_set_default_texture_param,RID,const StringName&,RID);
  548. FUNC2RC(RID,shader_get_default_texture_param,RID,const StringName&);
  549. /*virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) {
  550. if (Thread::get_caller_ID()!=server_thread) {
  551. command_queue.push_and_sync( visual_server, &VisualServer::shader_get_param_list,p_shader,p_param_list);
  552. } else {
  553. visual_server->m_type(p1, p2, p3, p4, p5);
  554. }
  555. }*/
  556. // virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list);
  557. /* COMMON MATERIAL API */
  558. FUNC0R(RID,material_create);
  559. FUNC2(material_set_shader,RID,RID);
  560. FUNC1RC(RID,material_get_shader,RID);
  561. FUNC3(material_set_param,RID,const StringName&,const Variant&);
  562. FUNC2RC(Variant,material_get_param,RID,const StringName&);
  563. FUNC3(material_set_flag,RID,MaterialFlag,bool);
  564. FUNC2RC(bool,material_get_flag,RID,MaterialFlag);
  565. FUNC2(material_set_depth_draw_mode,RID,MaterialDepthDrawMode);
  566. FUNC1RC(MaterialDepthDrawMode,material_get_depth_draw_mode,RID);
  567. FUNC2(material_set_blend_mode,RID,MaterialBlendMode);
  568. FUNC1RC(MaterialBlendMode,material_get_blend_mode,RID);
  569. FUNC2(material_set_line_width,RID,float);
  570. FUNC1RC(float,material_get_line_width,RID);
  571. /* FIXED MATERIAL */
  572. FUNC0R(RID,fixed_material_create);
  573. FUNC3(fixed_material_set_flag,RID, FixedMaterialFlags , bool );
  574. FUNC2RC(bool, fixed_material_get_flag,RID, FixedMaterialFlags);
  575. FUNC3(fixed_material_set_param,RID, FixedMaterialParam, const Variant& );
  576. FUNC2RC(Variant, fixed_material_get_param,RID ,FixedMaterialParam);
  577. FUNC3(fixed_material_set_texture,RID ,FixedMaterialParam, RID );
  578. FUNC2RC(RID, fixed_material_get_texture,RID,FixedMaterialParam);
  579. FUNC3(fixed_material_set_texcoord_mode,RID,FixedMaterialParam, FixedMaterialTexCoordMode );
  580. FUNC2RC(FixedMaterialTexCoordMode, fixed_material_get_texcoord_mode,RID,FixedMaterialParam);
  581. FUNC2(fixed_material_set_light_shader,RID,FixedMaterialLightShader);
  582. FUNC1RC(FixedMaterialLightShader, fixed_material_get_light_shader,RID);
  583. FUNC2(fixed_material_set_uv_transform,RID,const Transform&);
  584. FUNC1RC(Transform, fixed_material_get_uv_transform,RID);
  585. FUNC2(fixed_material_set_point_size,RID ,float);
  586. FUNC1RC(float,fixed_material_get_point_size,RID);
  587. /* SURFACE API */
  588. FUNCRID(mesh);
  589. FUNC2(mesh_set_morph_target_count,RID,int);
  590. FUNC1RC(int,mesh_get_morph_target_count,RID);
  591. FUNC2(mesh_set_morph_target_mode,RID,MorphTargetMode);
  592. FUNC1RC(MorphTargetMode,mesh_get_morph_target_mode,RID);
  593. FUNC2(mesh_add_custom_surface,RID,const Variant&); //this is used by each platform in a different way
  594. FUNC5(mesh_add_surface,RID,PrimitiveType,const Array&,const Array&,bool);
  595. FUNC2RC(Array,mesh_get_surface_arrays,RID,int);
  596. FUNC2RC(Array,mesh_get_surface_morph_arrays,RID,int);
  597. FUNC4(mesh_surface_set_material,RID, int, RID,bool);
  598. FUNC2RC(RID,mesh_surface_get_material,RID, int);
  599. FUNC2RC(int,mesh_surface_get_array_len,RID, int);
  600. FUNC2RC(int,mesh_surface_get_array_index_len,RID, int);
  601. FUNC2RC(uint32_t,mesh_surface_get_format,RID, int);
  602. FUNC2RC(PrimitiveType,mesh_surface_get_primitive_type,RID, int);
  603. FUNC2(mesh_remove_surface,RID,int);
  604. FUNC1RC(int,mesh_get_surface_count,RID);
  605. FUNC2(mesh_set_custom_aabb,RID,const AABB&);
  606. FUNC1RC(AABB,mesh_get_custom_aabb,RID);
  607. /* MULTIMESH API */
  608. FUNC0R(RID,multimesh_create);
  609. FUNC2(multimesh_set_instance_count,RID,int);
  610. FUNC1RC(int,multimesh_get_instance_count,RID);
  611. FUNC2(multimesh_set_mesh,RID,RID);
  612. FUNC2(multimesh_set_aabb,RID,const AABB&);
  613. FUNC3(multimesh_instance_set_transform,RID,int,const Transform&);
  614. FUNC3(multimesh_instance_set_color,RID,int,const Color&);
  615. FUNC1RC(RID,multimesh_get_mesh,RID);
  616. FUNC2RC(AABB,multimesh_get_aabb,RID,const AABB&);
  617. FUNC2RC(Transform,multimesh_instance_get_transform,RID,int);
  618. FUNC2RC(Color,multimesh_instance_get_color,RID,int);
  619. FUNC2(multimesh_set_visible_instances,RID,int);
  620. FUNC1RC(int,multimesh_get_visible_instances,RID);
  621. /* IMMEDIATE API */
  622. FUNC0R(RID,immediate_create);
  623. FUNC3(immediate_begin,RID,PrimitiveType,RID);
  624. FUNC2(immediate_vertex,RID,const Vector3&);
  625. FUNC2(immediate_normal,RID,const Vector3&);
  626. FUNC2(immediate_tangent,RID,const Plane&);
  627. FUNC2(immediate_color,RID,const Color&);
  628. FUNC2(immediate_uv,RID,const Vector2&);
  629. FUNC2(immediate_uv2,RID,const Vector2&);
  630. FUNC1(immediate_end,RID);
  631. FUNC1(immediate_clear,RID);
  632. FUNC2(immediate_set_material,RID,RID);
  633. FUNC1RC(RID,immediate_get_material,RID);
  634. /* PARTICLES API */
  635. FUNC0R(RID,particles_create);
  636. FUNC2(particles_set_amount,RID, int );
  637. FUNC1RC(int,particles_get_amount,RID);
  638. FUNC2(particles_set_emitting,RID, bool );
  639. FUNC1RC(bool,particles_is_emitting,RID);
  640. FUNC2(particles_set_visibility_aabb,RID, const AABB&);
  641. FUNC1RC(AABB,particles_get_visibility_aabb,RID);
  642. FUNC2(particles_set_emission_half_extents,RID, const Vector3&);
  643. FUNC1RC(Vector3,particles_get_emission_half_extents,RID);
  644. FUNC2(particles_set_emission_base_velocity,RID, const Vector3&);
  645. FUNC1RC(Vector3,particles_get_emission_base_velocity,RID);
  646. FUNC2(particles_set_emission_points,RID, const DVector<Vector3>& );
  647. FUNC1RC(DVector<Vector3>,particles_get_emission_points,RID);
  648. FUNC2(particles_set_gravity_normal,RID, const Vector3& );
  649. FUNC1RC(Vector3,particles_get_gravity_normal,RID);
  650. FUNC3(particles_set_variable,RID, ParticleVariable ,float);
  651. FUNC2RC(float,particles_get_variable,RID, ParticleVariable );
  652. FUNC3(particles_set_randomness,RID, ParticleVariable ,float);
  653. FUNC2RC(float,particles_get_randomness,RID, ParticleVariable );
  654. FUNC3(particles_set_color_phase_pos,RID, int , float);
  655. FUNC2RC(float,particles_get_color_phase_pos,RID, int );
  656. FUNC2(particles_set_color_phases,RID, int );
  657. FUNC1RC(int,particles_get_color_phases,RID);
  658. FUNC3(particles_set_color_phase_color,RID, int , const Color& );
  659. FUNC2RC(Color,particles_get_color_phase_color,RID, int );
  660. FUNC2(particles_set_attractors,RID, int);
  661. FUNC1RC(int,particles_get_attractors,RID);
  662. FUNC3(particles_set_attractor_pos,RID, int, const Vector3&);
  663. FUNC2RC(Vector3,particles_get_attractor_pos,RID,int);
  664. FUNC3(particles_set_attractor_strength,RID, int, float);
  665. FUNC2RC(float,particles_get_attractor_strength,RID,int);
  666. FUNC3(particles_set_material,RID, RID,bool);
  667. FUNC1RC(RID,particles_get_material,RID);
  668. FUNC2(particles_set_height_from_velocity,RID, bool);
  669. FUNC1RC(bool,particles_has_height_from_velocity,RID);
  670. FUNC2(particles_set_use_local_coordinates,RID, bool);
  671. FUNC1RC(bool,particles_is_using_local_coordinates,RID);
  672. /* Light API */
  673. FUNC1R(RID,light_create,LightType);
  674. FUNC1RC(LightType,light_get_type,RID);
  675. FUNC3(light_set_color,RID,LightColor , const Color& );
  676. FUNC2RC(Color,light_get_color,RID,LightColor );
  677. FUNC2(light_set_shadow,RID,bool );
  678. FUNC1RC(bool,light_has_shadow,RID);
  679. FUNC2(light_set_volumetric,RID,bool );
  680. FUNC1RC(bool,light_is_volumetric,RID);
  681. FUNC2(light_set_projector,RID,RID );
  682. FUNC1RC(RID,light_get_projector,RID);
  683. FUNC3(light_set_param,RID, LightParam , float );
  684. FUNC2RC(float,light_get_param,RID, LightParam );
  685. FUNC2(light_set_operator,RID,LightOp);
  686. FUNC1RC(LightOp,light_get_operator,RID);
  687. FUNC2(light_omni_set_shadow_mode,RID,LightOmniShadowMode);
  688. FUNC1RC(LightOmniShadowMode,light_omni_get_shadow_mode,RID);
  689. FUNC2(light_directional_set_shadow_mode,RID,LightDirectionalShadowMode);
  690. FUNC1RC(LightDirectionalShadowMode,light_directional_get_shadow_mode,RID);
  691. FUNC3(light_directional_set_shadow_param,RID,LightDirectionalShadowParam, float );
  692. FUNC2RC(float,light_directional_get_shadow_param,RID,LightDirectionalShadowParam );
  693. /* SKELETON API */
  694. FUNC0R(RID,skeleton_create);
  695. FUNC2(skeleton_resize,RID,int );
  696. FUNC1RC(int,skeleton_get_bone_count,RID) ;
  697. FUNC3(skeleton_bone_set_transform,RID,int, const Transform&);
  698. FUNC2R(Transform,skeleton_bone_get_transform,RID,int );
  699. /* ROOM API */
  700. FUNC0R(RID,room_create);
  701. FUNC2(room_set_bounds,RID, const BSP_Tree&);
  702. FUNC1RC(BSP_Tree,room_get_bounds,RID);
  703. /* PORTAL API */
  704. FUNC0R(RID,portal_create);
  705. FUNC2(portal_set_shape,RID,const Vector<Point2>&);
  706. FUNC1RC(Vector<Point2>,portal_get_shape,RID);
  707. FUNC2(portal_set_enabled,RID, bool);
  708. FUNC1RC(bool,portal_is_enabled,RID);
  709. FUNC2(portal_set_disable_distance,RID, float);
  710. FUNC1RC(float,portal_get_disable_distance,RID);
  711. FUNC2(portal_set_disabled_color,RID, const Color&);
  712. FUNC1RC(Color,portal_get_disabled_color,RID);
  713. FUNC2(portal_set_connect_range,RID, float);
  714. FUNC1RC(float,portal_get_connect_range,RID);
  715. FUNC0R(RID,baked_light_create);
  716. FUNC2(baked_light_set_mode,RID,BakedLightMode);
  717. FUNC1RC(BakedLightMode,baked_light_get_mode,RID);
  718. FUNC2(baked_light_set_octree,RID,DVector<uint8_t>);
  719. FUNC1RC(DVector<uint8_t>,baked_light_get_octree,RID);
  720. FUNC2(baked_light_set_light,RID,DVector<uint8_t>);
  721. FUNC1RC(DVector<uint8_t>,baked_light_get_light,RID);
  722. FUNC2(baked_light_set_sampler_octree,RID,const DVector<int>&);
  723. FUNC1RC(DVector<int>,baked_light_get_sampler_octree,RID);
  724. FUNC2(baked_light_set_lightmap_multiplier,RID,float);
  725. FUNC1RC(float,baked_light_get_lightmap_multiplier,RID);
  726. FUNC3(baked_light_add_lightmap,RID,RID,int);
  727. FUNC1(baked_light_clear_lightmaps,RID);
  728. FUNC0R(RID,baked_light_sampler_create);
  729. FUNC3(baked_light_sampler_set_param,RID, BakedLightSamplerParam , float );
  730. FUNC2RC(float,baked_light_sampler_get_param,RID, BakedLightSamplerParam );
  731. FUNC2(baked_light_sampler_set_resolution,RID,int);
  732. FUNC1RC(int,baked_light_sampler_get_resolution,RID);
  733. /* CAMERA API */
  734. FUNC0R(RID,camera_create);
  735. FUNC4(camera_set_perspective,RID,float , float , float );
  736. FUNC4(camera_set_orthogonal,RID,float, float , float );
  737. FUNC2(camera_set_transform,RID,const Transform& );
  738. FUNC2(camera_set_visible_layers,RID,uint32_t);
  739. FUNC1RC(uint32_t,camera_get_visible_layers,RID);
  740. FUNC2(camera_set_environment,RID,RID);
  741. FUNC1RC(RID,camera_get_environment,RID);
  742. FUNC2(camera_set_use_vertical_aspect,RID,bool);
  743. FUNC2RC(bool,camera_is_using_vertical_aspect,RID,bool);
  744. /* VIEWPORT API */
  745. FUNC0R(RID,viewport_create);
  746. FUNC2(viewport_attach_to_screen,RID,int );
  747. FUNC1(viewport_detach,RID);
  748. FUNC2(viewport_set_as_render_target,RID,bool);
  749. FUNC2(viewport_set_render_target_update_mode,RID,RenderTargetUpdateMode);
  750. FUNC1RC(RenderTargetUpdateMode,viewport_get_render_target_update_mode,RID);
  751. FUNC1RC(RID,viewport_get_render_target_texture,RID);
  752. FUNC2(viewport_set_render_target_vflip,RID,bool);
  753. FUNC1RC(bool,viewport_get_render_target_vflip,RID);
  754. FUNC2(viewport_set_render_target_to_screen_rect,RID,const Rect2&);
  755. FUNC2(viewport_set_render_target_clear_on_new_frame,RID,bool);
  756. FUNC1RC(bool,viewport_get_render_target_clear_on_new_frame,RID);
  757. FUNC1(viewport_render_target_clear,RID);
  758. FUNC1(viewport_queue_screen_capture,RID);
  759. FUNC1RC(Image,viewport_get_screen_capture,RID);
  760. FUNC2(viewport_set_rect,RID,const ViewportRect&);
  761. FUNC1RC(ViewportRect,viewport_get_rect,RID);
  762. FUNC2(viewport_set_hide_scenario,RID,bool );
  763. FUNC2(viewport_set_hide_canvas,RID,bool );
  764. FUNC2(viewport_attach_camera,RID,RID );
  765. FUNC2(viewport_set_scenario,RID,RID );
  766. FUNC2(viewport_set_disable_environment,RID,bool );
  767. FUNC1RC(RID,viewport_get_attached_camera,RID);
  768. FUNC1RC(RID,viewport_get_scenario,RID );
  769. FUNC2(viewport_attach_canvas,RID,RID);
  770. FUNC2(viewport_remove_canvas,RID,RID);
  771. FUNC3(viewport_set_canvas_transform,RID,RID,const Matrix32&);
  772. FUNC2RC(Matrix32,viewport_get_canvas_transform,RID,RID);
  773. FUNC2(viewport_set_global_canvas_transform,RID,const Matrix32&);
  774. FUNC1RC(Matrix32,viewport_get_global_canvas_transform,RID);
  775. FUNC3(viewport_set_canvas_layer,RID,RID ,int);
  776. FUNC2(viewport_set_transparent_background,RID,bool);
  777. FUNC1RC(bool,viewport_has_transparent_background,RID);
  778. /* ENVIRONMENT API */
  779. FUNC0R(RID,environment_create);
  780. FUNC2(environment_set_background,RID,EnvironmentBG);
  781. FUNC1RC(EnvironmentBG,environment_get_background,RID);
  782. FUNC3(environment_set_background_param,RID,EnvironmentBGParam, const Variant&);
  783. FUNC2RC(Variant,environment_get_background_param,RID,EnvironmentBGParam );
  784. FUNC3(environment_set_enable_fx,RID,EnvironmentFx,bool);
  785. FUNC2RC(bool,environment_is_fx_enabled,RID,EnvironmentFx);
  786. FUNC3(environment_fx_set_param,RID,EnvironmentFxParam,const Variant&);
  787. FUNC2RC(Variant,environment_fx_get_param,RID,EnvironmentFxParam);
  788. /* SCENARIO API */
  789. FUNC0R(RID,scenario_create);
  790. FUNC2(scenario_set_debug,RID,ScenarioDebugMode);
  791. FUNC2(scenario_set_environment,RID, RID);
  792. FUNC2RC(RID,scenario_get_environment,RID, RID);
  793. FUNC2(scenario_set_fallback_environment,RID, RID);
  794. /* INSTANCING API */
  795. FUNC0R(RID,instance_create);
  796. FUNC2(instance_set_base,RID, RID);
  797. FUNC1RC(RID,instance_get_base,RID);
  798. FUNC2(instance_set_scenario,RID, RID);
  799. FUNC1RC(RID,instance_get_scenario,RID);
  800. FUNC2(instance_set_layer_mask,RID, uint32_t);
  801. FUNC1RC(uint32_t,instance_get_layer_mask,RID);
  802. FUNC1RC(AABB,instance_get_base_aabb,RID);
  803. FUNC2(instance_attach_object_instance_ID,RID,uint32_t);
  804. FUNC1RC(uint32_t,instance_get_object_instance_ID,RID);
  805. FUNC2(instance_attach_skeleton,RID,RID);
  806. FUNC1RC(RID,instance_get_skeleton,RID);
  807. FUNC3(instance_set_morph_target_weight,RID,int, float);
  808. FUNC2RC(float,instance_get_morph_target_weight,RID,int);
  809. FUNC2(instance_set_transform,RID, const Transform&);
  810. FUNC1RC(Transform,instance_get_transform,RID);
  811. FUNC2(instance_set_exterior,RID, bool );
  812. FUNC1RC(bool,instance_is_exterior,RID);
  813. FUNC2(instance_set_room,RID, RID );
  814. FUNC1RC(RID,instance_get_room,RID ) ;
  815. FUNC2(instance_set_extra_visibility_margin,RID, real_t );
  816. FUNC1RC(real_t,instance_get_extra_visibility_margin,RID );
  817. FUNC2RC(Vector<RID>,instances_cull_aabb,const AABB& , RID );
  818. FUNC3RC(Vector<RID>,instances_cull_ray,const Vector3& ,const Vector3&, RID );
  819. FUNC2RC(Vector<RID>,instances_cull_convex,const Vector<Plane>& , RID );
  820. FUNC3(instance_geometry_set_flag,RID,InstanceFlags ,bool );
  821. FUNC2RC(bool,instance_geometry_get_flag,RID,InstanceFlags );
  822. FUNC2(instance_geometry_set_material_override,RID, RID );
  823. FUNC1RC(RID,instance_geometry_get_material_override,RID);
  824. FUNC3(instance_geometry_set_draw_range,RID,float ,float);
  825. FUNC1RC(float,instance_geometry_get_draw_range_max,RID);
  826. FUNC1RC(float,instance_geometry_get_draw_range_min,RID);
  827. FUNC2(instance_geometry_set_baked_light,RID, RID );
  828. FUNC1RC(RID,instance_geometry_get_baked_light,RID);
  829. FUNC2(instance_geometry_set_baked_light_sampler,RID, RID );
  830. FUNC1RC(RID,instance_geometry_get_baked_light_sampler,RID);
  831. FUNC2(instance_geometry_set_baked_light_texture_index,RID, int);
  832. FUNC1RC(int,instance_geometry_get_baked_light_texture_index,RID);
  833. FUNC2(instance_light_set_enabled,RID,bool);
  834. FUNC1RC(bool,instance_light_is_enabled,RID);
  835. /* CANVAS (2D) */
  836. FUNC0R(RID,canvas_create);
  837. FUNC3(canvas_set_item_mirroring,RID,RID,const Point2&);
  838. FUNC2RC(Point2,canvas_get_item_mirroring,RID,RID);
  839. FUNC2(canvas_set_modulate,RID,const Color&);
  840. FUNC0R(RID,canvas_item_create);
  841. FUNC2(canvas_item_set_parent,RID,RID );
  842. FUNC1RC(RID,canvas_item_get_parent,RID);
  843. FUNC2(canvas_item_set_visible,RID,bool );
  844. FUNC1RC(bool,canvas_item_is_visible,RID);
  845. FUNC2(canvas_item_set_blend_mode,RID,MaterialBlendMode );
  846. FUNC2(canvas_item_set_light_mask,RID,int );
  847. //FUNC(canvas_item_set_rect,RID, const Rect2& p_rect);
  848. FUNC2(canvas_item_set_transform,RID, const Matrix32& );
  849. FUNC2(canvas_item_set_clip,RID, bool );
  850. FUNC2(canvas_item_set_distance_field_mode,RID, bool );
  851. FUNC3(canvas_item_set_custom_rect,RID, bool ,const Rect2&);
  852. FUNC2(canvas_item_set_opacity,RID, float );
  853. FUNC2RC(float,canvas_item_get_opacity,RID, float );
  854. FUNC2(canvas_item_set_on_top,RID, bool );
  855. FUNC1RC(bool,canvas_item_is_on_top,RID);
  856. FUNC2(canvas_item_set_self_opacity,RID, float );
  857. FUNC2RC(float,canvas_item_get_self_opacity,RID, float );
  858. FUNC2(canvas_item_attach_viewport,RID, RID );
  859. FUNC5(canvas_item_add_line,RID, const Point2& , const Point2& ,const Color& ,float );
  860. FUNC3(canvas_item_add_rect,RID, const Rect2& , const Color& );
  861. FUNC4(canvas_item_add_circle,RID, const Point2& , float ,const Color& );
  862. FUNC6(canvas_item_add_texture_rect,RID, const Rect2& , RID ,bool ,const Color&,bool );
  863. FUNC6(canvas_item_add_texture_rect_region,RID, const Rect2& , RID ,const Rect2& ,const Color&,bool );
  864. FUNC7(canvas_item_add_style_box,RID, const Rect2& , RID ,const Vector2& ,const Vector2&, bool ,const Color& );
  865. FUNC6(canvas_item_add_primitive,RID, const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID ,float );
  866. FUNC5(canvas_item_add_polygon,RID, const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID );
  867. FUNC7(canvas_item_add_triangle_array,RID, const Vector<int>& , const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID , int );
  868. FUNC7(canvas_item_add_triangle_array_ptr,RID, int , const int* , const Point2* , const Color* ,const Point2* , RID );
  869. FUNC2(canvas_item_add_set_transform,RID,const Matrix32& );
  870. FUNC2(canvas_item_add_set_blend_mode,RID, MaterialBlendMode );
  871. FUNC2(canvas_item_add_clip_ignore,RID, bool );
  872. FUNC2(canvas_item_set_sort_children_by_y,RID,bool);
  873. FUNC2(canvas_item_set_z,RID,int);
  874. FUNC2(canvas_item_set_z_as_relative_to_parent,RID,bool);
  875. FUNC3(canvas_item_set_copy_to_backbuffer,RID,bool,const Rect2&);
  876. FUNC2(canvas_item_set_material,RID, RID );
  877. FUNC2(canvas_item_set_use_parent_material,RID, bool );
  878. FUNC1(canvas_item_clear,RID);
  879. FUNC1(canvas_item_raise,RID);
  880. /* CANVAS LIGHT */
  881. FUNC0R(RID,canvas_light_create);
  882. FUNC2(canvas_light_attach_to_canvas,RID,RID);
  883. FUNC2(canvas_light_set_enabled,RID,bool);
  884. FUNC2(canvas_light_set_transform,RID,const Matrix32&);
  885. FUNC2(canvas_light_set_scale,RID,float);
  886. FUNC2(canvas_light_set_texture,RID,RID);
  887. FUNC2(canvas_light_set_texture_offset,RID,const Vector2&);
  888. FUNC2(canvas_light_set_color,RID,const Color&);
  889. FUNC2(canvas_light_set_height,RID,float);
  890. FUNC2(canvas_light_set_energy,RID,float);
  891. FUNC3(canvas_light_set_layer_range,RID,int,int);
  892. FUNC3(canvas_light_set_z_range,RID,int,int);
  893. FUNC2(canvas_light_set_item_mask,RID,int);
  894. FUNC2(canvas_light_set_item_shadow_mask,RID,int);
  895. FUNC2(canvas_light_set_mode,RID,CanvasLightMode);
  896. FUNC2(canvas_light_set_shadow_enabled,RID,bool);
  897. FUNC2(canvas_light_set_shadow_buffer_size,RID,int);
  898. FUNC2(canvas_light_set_shadow_esm_multiplier,RID,float);
  899. /* CANVAS OCCLUDER */
  900. FUNC0R(RID,canvas_light_occluder_create);
  901. FUNC2(canvas_light_occluder_attach_to_canvas,RID,RID);
  902. FUNC2(canvas_light_occluder_set_enabled,RID,bool);
  903. FUNC2(canvas_light_occluder_set_polygon,RID,RID);
  904. FUNC2(canvas_light_occluder_set_transform,RID,const Matrix32&);
  905. FUNC2(canvas_light_occluder_set_light_mask,RID,int);
  906. FUNC0R(RID,canvas_occluder_polygon_create);
  907. FUNC3(canvas_occluder_polygon_set_shape,RID,const DVector<Vector2>&,bool);
  908. FUNC2(canvas_occluder_polygon_set_shape_as_lines,RID,const DVector<Vector2>&);
  909. FUNC2(canvas_occluder_polygon_set_cull_mode,RID,CanvasOccluderPolygonCullMode);
  910. /* CANVAS MATERIAL */
  911. FUNC0R(RID,canvas_item_material_create);
  912. FUNC2(canvas_item_material_set_shader,RID,RID);
  913. FUNC3(canvas_item_material_set_shader_param,RID,const StringName&,const Variant&);
  914. FUNC2RC(Variant,canvas_item_material_get_shader_param,RID,const StringName&);
  915. FUNC2(canvas_item_material_set_shading_mode,RID,CanvasItemShadingMode);
  916. /* CURSOR */
  917. FUNC2(cursor_set_rotation,float , int ); // radians
  918. FUNC3(cursor_set_texture,RID , const Point2 &, int );
  919. FUNC2(cursor_set_visible,bool , int );
  920. FUNC2(cursor_set_pos,const Point2& , int );
  921. /* BLACK BARS */
  922. FUNC4(black_bars_set_margins,int , int , int , int );
  923. FUNC4(black_bars_set_images,RID , RID , RID , RID );
  924. /* FREE */
  925. FUNC1(free,RID);
  926. /* CUSTOM SHADE MODEL */
  927. FUNC2(custom_shade_model_set_shader,int , RID );
  928. FUNC1RC(RID,custom_shade_model_get_shader,int );
  929. FUNC2(custom_shade_model_set_name,int , const String& );
  930. FUNC1RC(String,custom_shade_model_get_name,int );
  931. FUNC2(custom_shade_model_set_param_info,int , const List<PropertyInfo>& );
  932. FUNC2SC(custom_shade_model_get_param_info,int , List<PropertyInfo>* );
  933. /* EVENT QUEUING */
  934. virtual void init();
  935. virtual void finish();
  936. virtual void draw();
  937. virtual void flush();
  938. FUNC0RC(bool,has_changed);
  939. /* RENDER INFO */
  940. FUNC1R(int,get_render_info,RenderInfo );
  941. virtual bool has_feature(Features p_feature) const { return visual_server->has_feature(p_feature); }
  942. FUNC3(set_boot_image,const Image& , const Color&,bool );
  943. FUNC1(set_default_clear_color,const Color& );
  944. FUNC0R(RID,get_test_cube );
  945. VisualServerWrapMT(VisualServer* p_contained,bool p_create_thread);
  946. ~VisualServerWrapMT();
  947. };
  948. #endif