gles_builders.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. """Functions used to generate source files during build time
  2. All such functions are invoked in a subprocess on Windows to prevent build flakiness.
  3. """
  4. from platform_methods import subprocess_main
  5. import re
  6. class LegacyGLHeaderStruct:
  7. def __init__(self):
  8. self.vertex_lines = []
  9. self.fragment_lines = []
  10. self.uniforms = []
  11. self.attributes = []
  12. self.feedbacks = []
  13. self.fbos = []
  14. self.conditionals = []
  15. self.enums = {}
  16. self.texunits = []
  17. self.texunit_names = []
  18. self.ubos = []
  19. self.ubo_names = []
  20. self.vertex_included_files = []
  21. self.fragment_included_files = []
  22. self.reading = ""
  23. self.line_offset = 0
  24. self.vertex_offset = 0
  25. self.fragment_offset = 0
  26. def include_file_in_legacygl_header(filename, header_data, depth):
  27. fs = open(filename, "r")
  28. line = fs.readline()
  29. while line:
  30. if line.find("[vertex]") != -1:
  31. header_data.reading = "vertex"
  32. line = fs.readline()
  33. header_data.line_offset += 1
  34. header_data.vertex_offset = header_data.line_offset
  35. continue
  36. if line.find("[fragment]") != -1:
  37. header_data.reading = "fragment"
  38. line = fs.readline()
  39. header_data.line_offset += 1
  40. header_data.fragment_offset = header_data.line_offset
  41. continue
  42. while line.find("#include ") != -1:
  43. includeline = line.replace("#include ", "").strip()[1:-1]
  44. import os.path
  45. included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline)
  46. if not included_file in header_data.vertex_included_files and header_data.reading == "vertex":
  47. header_data.vertex_included_files += [included_file]
  48. if include_file_in_legacygl_header(included_file, header_data, depth + 1) is None:
  49. print("Error in file '" + filename + "': #include " + includeline + "could not be found!")
  50. elif not included_file in header_data.fragment_included_files and header_data.reading == "fragment":
  51. header_data.fragment_included_files += [included_file]
  52. if include_file_in_legacygl_header(included_file, header_data, depth + 1) is None:
  53. print("Error in file '" + filename + "': #include " + includeline + "could not be found!")
  54. line = fs.readline()
  55. if line.find("#ifdef ") != -1:
  56. if line.find("#ifdef ") != -1:
  57. ifdefline = re.sub(r".*#ifdef (\S+).*\n", "\\1", line)
  58. if line.find("_EN_") != -1:
  59. enumbase = ifdefline[: ifdefline.find("_EN_")]
  60. ifdefline = ifdefline.replace("_EN_", "_")
  61. line = line.replace("_EN_", "_")
  62. if enumbase not in header_data.enums:
  63. header_data.enums[enumbase] = []
  64. if ifdefline not in header_data.enums[enumbase]:
  65. header_data.enums[enumbase].append(ifdefline)
  66. elif not ifdefline in header_data.conditionals:
  67. header_data.conditionals += [ifdefline]
  68. if line.find("uniform") != -1 and line.lower().find("texunit:") != -1:
  69. # texture unit
  70. texunitstr = line[line.find(":") + 1 :].strip()
  71. if texunitstr == "auto":
  72. texunit = "-1"
  73. else:
  74. texunit = str(int(texunitstr))
  75. uline = line[: line.lower().find("//")]
  76. uline = uline.replace("uniform", "")
  77. uline = uline.replace("highp", "")
  78. uline = uline.replace(";", "")
  79. lines = uline.split(",")
  80. for x in lines:
  81. x = x.strip()
  82. x = x[x.rfind(" ") + 1 :]
  83. if x.find("[") != -1:
  84. # unfiorm array
  85. x = x[: x.find("[")]
  86. if not x in header_data.texunit_names:
  87. header_data.texunits += [(x, texunit)]
  88. header_data.texunit_names += [x]
  89. elif line.find("uniform") != -1 and line.lower().find("ubo:") != -1:
  90. # uniform buffer object
  91. ubostr = line[line.find(":") + 1 :].strip()
  92. ubo = str(int(ubostr))
  93. uline = line[: line.lower().find("//")]
  94. uline = uline[uline.find("uniform") + len("uniform") :]
  95. uline = uline.replace("highp", "")
  96. uline = uline.replace(";", "")
  97. uline = uline.replace("{", "").strip()
  98. lines = uline.split(",")
  99. for x in lines:
  100. x = x.strip()
  101. x = x[x.rfind(" ") + 1 :]
  102. if x.find("[") != -1:
  103. # unfiorm array
  104. x = x[: x.find("[")]
  105. if not x in header_data.ubo_names:
  106. header_data.ubos += [(x, ubo)]
  107. header_data.ubo_names += [x]
  108. elif line.find("uniform") != -1 and line.find("{") == -1 and line.find(";") != -1:
  109. uline = line.replace("uniform", "")
  110. uline = uline.replace(";", "")
  111. lines = uline.split(",")
  112. for x in lines:
  113. x = x.strip()
  114. x = x[x.rfind(" ") + 1 :]
  115. if x.find("[") != -1:
  116. # unfiorm array
  117. x = x[: x.find("[")]
  118. if not x in header_data.uniforms:
  119. header_data.uniforms += [x]
  120. if line.strip().find("attribute ") == 0 and line.find("attrib:") != -1:
  121. uline = line.replace("in ", "")
  122. uline = uline.replace("attribute ", "")
  123. uline = uline.replace("highp ", "")
  124. uline = uline.replace(";", "")
  125. uline = uline[uline.find(" ") :].strip()
  126. if uline.find("//") != -1:
  127. name, bind = uline.split("//")
  128. if bind.find("attrib:") != -1:
  129. name = name.strip()
  130. bind = bind.replace("attrib:", "").strip()
  131. header_data.attributes += [(name, bind)]
  132. if line.strip().find("out ") == 0 and line.find("tfb:") != -1:
  133. uline = line.replace("out ", "")
  134. uline = uline.replace("highp ", "")
  135. uline = uline.replace(";", "")
  136. uline = uline[uline.find(" ") :].strip()
  137. if uline.find("//") != -1:
  138. name, bind = uline.split("//")
  139. if bind.find("tfb:") != -1:
  140. name = name.strip()
  141. bind = bind.replace("tfb:", "").strip()
  142. header_data.feedbacks += [(name, bind)]
  143. line = line.replace("\r", "")
  144. line = line.replace("\n", "")
  145. if header_data.reading == "vertex":
  146. header_data.vertex_lines += [line]
  147. if header_data.reading == "fragment":
  148. header_data.fragment_lines += [line]
  149. line = fs.readline()
  150. header_data.line_offset += 1
  151. fs.close()
  152. return header_data
  153. def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2=False):
  154. header_data = LegacyGLHeaderStruct()
  155. include_file_in_legacygl_header(filename, header_data, 0)
  156. out_file = filename + ".gen.h"
  157. fd = open(out_file, "w")
  158. enum_constants = []
  159. fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n")
  160. out_file_base = out_file
  161. out_file_base = out_file_base[out_file_base.rfind("/") + 1 :]
  162. out_file_base = out_file_base[out_file_base.rfind("\\") + 1 :]
  163. out_file_ifdef = out_file_base.replace(".", "_").upper()
  164. fd.write("#ifndef " + out_file_ifdef + class_suffix + "_120\n")
  165. fd.write("#define " + out_file_ifdef + class_suffix + "_120\n")
  166. out_file_class = (
  167. out_file_base.replace(".glsl.gen.h", "").title().replace("_", "").replace(".", "") + "Shader" + class_suffix
  168. )
  169. fd.write("\n\n")
  170. fd.write('#include "' + include + '"\n\n\n')
  171. fd.write("class " + out_file_class + " : public Shader" + class_suffix + " {\n\n")
  172. fd.write('\t virtual String get_shader_name() const { return "' + out_file_class + '"; }\n')
  173. fd.write("public:\n\n")
  174. if header_data.conditionals:
  175. fd.write("\tenum Conditionals {\n")
  176. for x in header_data.conditionals:
  177. fd.write("\t\t" + x.upper() + ",\n")
  178. fd.write("\t};\n\n")
  179. if header_data.uniforms:
  180. fd.write("\tenum Uniforms {\n")
  181. for x in header_data.uniforms:
  182. fd.write("\t\t" + x.upper() + ",\n")
  183. fd.write("\t};\n\n")
  184. supports_ubershader = not gles2 and "ubershader_flags" in header_data.uniforms
  185. if supports_ubershader:
  186. fd.write("\tint get_ubershader_flags_uniform() const { return Uniforms::UBERSHADER_FLAGS; }\n\n")
  187. fd.write("\t_FORCE_INLINE_ int get_uniform(Uniforms p_uniform) const { return _get_uniform(p_uniform); }\n\n")
  188. if header_data.conditionals:
  189. fd.write(
  190. "\t_FORCE_INLINE_ void set_conditional(Conditionals p_conditional,bool p_enable) { _set_conditional(p_conditional,p_enable); }\n\n"
  191. )
  192. fd.write("\t#ifdef DEBUG_ENABLED\n ")
  193. fd.write(
  194. "\t#define _FU if (get_uniform(p_uniform)<0) return; if (!is_version_valid()) return; ERR_FAIL_COND( get_active()!=this ); \n\n "
  195. )
  196. fd.write("\t#else\n ")
  197. fd.write("\t#define _FU if (get_uniform(p_uniform)<0) return; \n\n ")
  198. fd.write("\t#endif\n")
  199. fd.write(
  200. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"
  201. )
  202. fd.write(
  203. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, double p_value) { _FU glUniform1f(get_uniform(p_uniform),p_value); }\n\n"
  204. )
  205. fd.write(
  206. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"
  207. )
  208. fd.write(
  209. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int8_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"
  210. )
  211. fd.write(
  212. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"
  213. )
  214. fd.write(
  215. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int16_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"
  216. )
  217. fd.write(
  218. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, uint32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"
  219. )
  220. fd.write(
  221. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, int32_t p_value) { _FU glUniform1i(get_uniform(p_uniform),p_value); }\n\n"
  222. )
  223. fd.write(
  224. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Color& p_color) { _FU GLfloat col[4]={p_color.r,p_color.g,p_color.b,p_color.a}; glUniform4fv(get_uniform(p_uniform),1,col); }\n\n"
  225. )
  226. fd.write(
  227. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector2& p_vec2) { _FU GLfloat vec2[2]={p_vec2.x,p_vec2.y}; glUniform2fv(get_uniform(p_uniform),1,vec2); }\n\n"
  228. )
  229. fd.write(
  230. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Size2i& p_vec2) { _FU GLint vec2[2]={p_vec2.x,p_vec2.y}; glUniform2iv(get_uniform(p_uniform),1,vec2); }\n\n"
  231. )
  232. fd.write(
  233. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Vector3& p_vec3) { _FU GLfloat vec3[3]={p_vec3.x,p_vec3.y,p_vec3.z}; glUniform3fv(get_uniform(p_uniform),1,vec3); }\n\n"
  234. )
  235. fd.write(
  236. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b) { _FU glUniform2f(get_uniform(p_uniform),p_a,p_b); }\n\n"
  237. )
  238. fd.write(
  239. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c) { _FU glUniform3f(get_uniform(p_uniform),p_a,p_b,p_c); }\n\n"
  240. )
  241. fd.write(
  242. "\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, float p_a, float p_b, float p_c, float p_d) { _FU glUniform4f(get_uniform(p_uniform),p_a,p_b,p_c,p_d); }\n\n"
  243. )
  244. fd.write(
  245. """\t_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform& p_transform) { _FU
  246. const Transform &tr = p_transform;
  247. GLfloat matrix[16]={ /* build a 16x16 matrix */
  248. tr.basis.elements[0][0],
  249. tr.basis.elements[1][0],
  250. tr.basis.elements[2][0],
  251. 0,
  252. tr.basis.elements[0][1],
  253. tr.basis.elements[1][1],
  254. tr.basis.elements[2][1],
  255. 0,
  256. tr.basis.elements[0][2],
  257. tr.basis.elements[1][2],
  258. tr.basis.elements[2][2],
  259. 0,
  260. tr.origin.x,
  261. tr.origin.y,
  262. tr.origin.z,
  263. 1
  264. };
  265. glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
  266. }
  267. """
  268. )
  269. fd.write(
  270. """_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const Transform2D& p_transform) { _FU
  271. const Transform2D &tr = p_transform;
  272. GLfloat matrix[16]={ /* build a 16x16 matrix */
  273. tr.elements[0][0],
  274. tr.elements[0][1],
  275. 0,
  276. 0,
  277. tr.elements[1][0],
  278. tr.elements[1][1],
  279. 0,
  280. 0,
  281. 0,
  282. 0,
  283. 1,
  284. 0,
  285. tr.elements[2][0],
  286. tr.elements[2][1],
  287. 0,
  288. 1
  289. };
  290. glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
  291. }
  292. """
  293. )
  294. fd.write(
  295. """_FORCE_INLINE_ void set_uniform(Uniforms p_uniform, const CameraMatrix& p_matrix) { _FU
  296. GLfloat matrix[16];
  297. for (int i=0;i<4;i++) {
  298. for (int j=0;j<4;j++) {
  299. matrix[i*4+j]=p_matrix.matrix[i][j];
  300. }
  301. }
  302. glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
  303. }"""
  304. )
  305. fd.write("\n\n#undef _FU\n\n\n")
  306. fd.write("\tvirtual void init() {\n\n")
  307. enum_value_count = 0
  308. if header_data.enums:
  309. fd.write("\t\t//Written using math, given nonstandarity of 64 bits integer constants..\n")
  310. fd.write("\t\tstatic const Enum _enums[]={\n")
  311. bitofs = len(header_data.conditionals)
  312. enum_vals = []
  313. for xv in header_data.enums:
  314. x = header_data.enums[xv]
  315. bits = 1
  316. amt = len(x)
  317. while 2**bits < amt:
  318. bits += 1
  319. strs = "{"
  320. for i in range(amt):
  321. strs += '"#define ' + x[i] + '\\n",'
  322. c = {}
  323. c["set_mask"] = "uint64_t(" + str(i) + ")<<" + str(bitofs)
  324. c["clear_mask"] = (
  325. "((uint64_t(1)<<40)-1) ^ (((uint64_t(1)<<" + str(bits) + ") - 1)<<" + str(bitofs) + ")"
  326. )
  327. enum_vals.append(c)
  328. enum_constants.append(x[i])
  329. strs += "NULL}"
  330. fd.write(
  331. "\t\t\t{(uint64_t(1<<" + str(bits) + ")-1)<<" + str(bitofs) + "," + str(bitofs) + "," + strs + "},\n"
  332. )
  333. bitofs += bits
  334. fd.write("\t\t};\n\n")
  335. fd.write("\t\tstatic const EnumValue _enum_values[]={\n")
  336. enum_value_count = len(enum_vals)
  337. for x in enum_vals:
  338. fd.write("\t\t\t{" + x["set_mask"] + "," + x["clear_mask"] + "},\n")
  339. fd.write("\t\t};\n\n")
  340. conditionals_found = []
  341. if header_data.conditionals:
  342. fd.write("\t\tstatic const char* _conditional_strings[]={\n")
  343. if header_data.conditionals:
  344. for x in header_data.conditionals:
  345. fd.write('\t\t\t"#define ' + x + '\\n",\n')
  346. conditionals_found.append(x)
  347. fd.write("\t\t};\n\n")
  348. else:
  349. fd.write("\t\tstatic const char **_conditional_strings=NULL;\n")
  350. if header_data.uniforms:
  351. fd.write("\t\tstatic const char* _uniform_strings[]={\n")
  352. if header_data.uniforms:
  353. for x in header_data.uniforms:
  354. fd.write('\t\t\t"' + x + '",\n')
  355. fd.write("\t\t};\n\n")
  356. else:
  357. fd.write("\t\tstatic const char **_uniform_strings=NULL;\n")
  358. if output_attribs:
  359. if header_data.attributes:
  360. fd.write("\t\tstatic AttributePair _attribute_pairs[]={\n")
  361. for x in header_data.attributes:
  362. fd.write('\t\t\t{"' + x[0] + '",' + x[1] + "},\n")
  363. fd.write("\t\t};\n\n")
  364. else:
  365. fd.write("\t\tstatic AttributePair *_attribute_pairs=NULL;\n")
  366. feedback_count = 0
  367. if not gles2 and len(header_data.feedbacks):
  368. fd.write("\t\tstatic const Feedback _feedbacks[]={\n")
  369. for x in header_data.feedbacks:
  370. name = x[0]
  371. cond = x[1]
  372. if cond in conditionals_found:
  373. fd.write('\t\t\t{"' + name + '",' + str(conditionals_found.index(cond)) + "},\n")
  374. else:
  375. fd.write('\t\t\t{"' + name + '",-1},\n')
  376. feedback_count += 1
  377. fd.write("\t\t};\n\n")
  378. else:
  379. if gles2:
  380. pass
  381. else:
  382. fd.write("\t\tstatic const Feedback* _feedbacks=NULL;\n")
  383. if header_data.texunits:
  384. fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")
  385. for x in header_data.texunits:
  386. fd.write('\t\t\t{"' + x[0] + '",' + x[1] + "},\n")
  387. fd.write("\t\t};\n\n")
  388. else:
  389. fd.write("\t\tstatic TexUnitPair *_texunit_pairs=NULL;\n")
  390. if not gles2 and header_data.ubos:
  391. fd.write("\t\tstatic UBOPair _ubo_pairs[]={\n")
  392. for x in header_data.ubos:
  393. fd.write('\t\t\t{"' + x[0] + '",' + x[1] + "},\n")
  394. fd.write("\t\t};\n\n")
  395. else:
  396. if gles2:
  397. pass
  398. else:
  399. fd.write("\t\tstatic UBOPair *_ubo_pairs=NULL;\n")
  400. fd.write("\t\tstatic const char _vertex_code[]={\n")
  401. for x in header_data.vertex_lines:
  402. for c in x:
  403. fd.write(str(ord(c)) + ",")
  404. fd.write(str(ord("\n")) + ",")
  405. fd.write("\t\t0};\n\n")
  406. fd.write("\t\tstatic const int _vertex_code_start=" + str(header_data.vertex_offset) + ";\n")
  407. fd.write("\t\tstatic const char _fragment_code[]={\n")
  408. for x in header_data.fragment_lines:
  409. for c in x:
  410. fd.write(str(ord(c)) + ",")
  411. fd.write(str(ord("\n")) + ",")
  412. fd.write("\t\t0};\n\n")
  413. fd.write("\t\tstatic const int _fragment_code_start=" + str(header_data.fragment_offset) + ";\n")
  414. if output_attribs:
  415. if gles2:
  416. fd.write(
  417. "\t\tsetup(_conditional_strings,"
  418. + str(len(header_data.conditionals))
  419. + ",_uniform_strings,"
  420. + str(len(header_data.uniforms))
  421. + ",_attribute_pairs,"
  422. + str(len(header_data.attributes))
  423. + ", _texunit_pairs,"
  424. + str(len(header_data.texunits))
  425. + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
  426. )
  427. else:
  428. fd.write(
  429. "\t\tsetup(_conditional_strings,"
  430. + str(len(header_data.conditionals))
  431. + ",_uniform_strings,"
  432. + str(len(header_data.uniforms))
  433. + ",_attribute_pairs,"
  434. + str(len(header_data.attributes))
  435. + ", _texunit_pairs,"
  436. + str(len(header_data.texunits))
  437. + ",_ubo_pairs,"
  438. + str(len(header_data.ubos))
  439. + ",_feedbacks,"
  440. + str(feedback_count)
  441. + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
  442. )
  443. else:
  444. if gles2:
  445. fd.write(
  446. "\t\tsetup(_conditional_strings,"
  447. + str(len(header_data.conditionals))
  448. + ",_uniform_strings,"
  449. + str(len(header_data.uniforms))
  450. + ",_texunit_pairs,"
  451. + str(len(header_data.texunits))
  452. + ",_enums,"
  453. + str(len(header_data.enums))
  454. + ",_enum_values,"
  455. + str(enum_value_count)
  456. + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
  457. )
  458. else:
  459. fd.write(
  460. "\t\tsetup(_conditional_strings,"
  461. + str(len(header_data.conditionals))
  462. + ",_uniform_strings,"
  463. + str(len(header_data.uniforms))
  464. + ",_texunit_pairs,"
  465. + str(len(header_data.texunits))
  466. + ",_enums,"
  467. + str(len(header_data.enums))
  468. + ",_enum_values,"
  469. + str(enum_value_count)
  470. + ",_ubo_pairs,"
  471. + str(len(header_data.ubos))
  472. + ",_feedbacks,"
  473. + str(feedback_count)
  474. + ",_vertex_code,_fragment_code,_vertex_code_start,_fragment_code_start);\n"
  475. )
  476. fd.write("\t}\n\n")
  477. if enum_constants:
  478. fd.write("\tenum EnumConditionals {\n")
  479. for x in enum_constants:
  480. fd.write("\t\t" + x.upper() + ",\n")
  481. fd.write("\t};\n\n")
  482. fd.write("\tvoid set_enum_conditional(EnumConditionals p_cond) { _set_enum_conditional(p_cond); }\n")
  483. fd.write("};\n\n")
  484. fd.write("#endif\n\n")
  485. fd.close()
  486. def build_gles3_headers(target, source, env):
  487. for x in source:
  488. build_legacygl_header(str(x), include="drivers/gles3/shader_gles3.h", class_suffix="GLES3", output_attribs=True)
  489. def build_gles2_headers(target, source, env):
  490. for x in source:
  491. build_legacygl_header(
  492. str(x), include="drivers/gles2/shader_gles2.h", class_suffix="GLES2", output_attribs=True, gles2=True
  493. )
  494. if __name__ == "__main__":
  495. subprocess_main(globals())