mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-12 12:39:56 +00:00
Rename cg2xml to cg2glsl.
Outputs CGP/GLSL style shaders now.
This commit is contained in:
parent
7bb9f0d288
commit
d7c1957586
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Python 3 script which converts simple RetroArch Cg shaders to modern XML/GLSL format.
|
Python 3 script which converts simple RetroArch Cg shaders to modern GLSL (ES) format.
|
||||||
Author: Hans-Kristian Arntzen (Themaister)
|
Author: Hans-Kristian Arntzen (Themaister)
|
||||||
License: Public domain
|
License: Public domain
|
||||||
"""
|
"""
|
||||||
@ -279,29 +279,19 @@ def convert(source, dest):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
f.write('// GLSL shader autogenerated by cg2glsl.py.\n')
|
||||||
f.write('<!-- XML/GLSL shader autogenerated by cg2xml.py -->\n')
|
f.write('#if defined(VERTEX)\n')
|
||||||
f.write('<shader language="GLSL" style="GLES2">\n')
|
|
||||||
f.write(' <vertex><![CDATA[\n')
|
|
||||||
|
|
||||||
f.write(out_vertex)
|
f.write(out_vertex)
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
f.write('#elif defined(FRAGMENT)\n')
|
||||||
f.write(' ]]></vertex>\n')
|
|
||||||
|
|
||||||
f.write(' <fragment><![CDATA[\n')
|
|
||||||
|
|
||||||
f.write(out_fragment)
|
f.write(out_fragment)
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
|
f.write('#endif\n')
|
||||||
f.write(' ]]></fragment>\n')
|
|
||||||
f.write('</shader>\n')
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
print('Usage: {} prog.cg prog.shader'.format(sys.argv[0]))
|
print('Usage: {} prog.cg prog.glsl'.format(sys.argv[0]))
|
||||||
print('Batch mode usage: {} cg-dir out-xml-shader-dir'.format(sys.argv[0]))
|
print('Batch mode usage: {} cg-dir out-xml-shader-dir'.format(sys.argv[0]))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@ -320,7 +310,7 @@ def main():
|
|||||||
for dirname, _, filenames in os.walk(sys.argv[1]):
|
for dirname, _, filenames in os.walk(sys.argv[1]):
|
||||||
for source in filter(lambda path: 'cg' == path.split('.')[-1], [os.path.join(dirname, filename) for filename in filenames]):
|
for source in filter(lambda path: 'cg' == path.split('.')[-1], [os.path.join(dirname, filename) for filename in filenames]):
|
||||||
|
|
||||||
dest = os.path.join(sys.argv[2], source.replace(sys.argv[1], '')[1:]).replace('.cg', '.shader')
|
dest = os.path.join(sys.argv[2], source.replace(sys.argv[1], '')[1:]).replace('.cg', '.glsl')
|
||||||
dirpath = os.path.split(dest)[0]
|
dirpath = os.path.split(dest)[0]
|
||||||
print('Dirpath:', dirpath)
|
print('Dirpath:', dirpath)
|
||||||
if not os.path.isdir(dirpath):
|
if not os.path.isdir(dirpath):
|
Loading…
x
Reference in New Issue
Block a user