Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: cg_to_glsl/convert.py

Issue 1745002: Incremental progress toward archive loading in o3d-webgl. Implemented... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/o3d/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | samples/o3d-webgl-samples/helloworld.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 import optparse 2 import optparse
3 import os 3 import os
4 import re 4 import re
5 import subprocess 5 import subprocess
6 import sys 6 import sys
7 7
8 # This script takes an o3d cg shader from standard input and does the following: 8 # This script takes an o3d cg shader from standard input and does the following:
9 # 9 #
10 # * it extracts entry points to vertex and fragment shaders as specified by 10 # * it extracts entry points to vertex and fragment shaders as specified by
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 # If there is more than one gl_Position mentioned in the shader, the 93 # If there is more than one gl_Position mentioned in the shader, the
94 # converter fails. 94 # converter fails.
95 assert len(re.findall('gl_Position', body)) == 1 95 assert len(re.findall('gl_Position', body)) == 1
96 attributes.append('vec4 _glPositionTemp;') 96 attributes.append('vec4 _glPositionTemp;')
97 attributes.append('uniform vec4 dx_clipping;') 97 attributes.append('uniform vec4 dx_clipping;')
98 body = re.sub(r'\bgl_Position\b([^;]*);', 98 body = re.sub(r'\bgl_Position\b([^;]*);',
99 r'_glPositionTemp\1; gl_Position = vec4(' + 99 r'_glPositionTemp\1; gl_Position = vec4(' +
100 r'_glPositionTemp.x + _glPositionTemp.w * dx_clipping.x, ' + 100 r'_glPositionTemp.x + _glPositionTemp.w * dx_clipping.x, ' +
101 r'dx_clipping.w * ' + 101 r'dx_clipping.w * ' +
102 r'(_glPositionTemp.y + _glPositionTemp.w * dx_clipping.y), ' + 102 r'(_glPositionTemp.y + _glPositionTemp.w * dx_clipping.y), ' +
103 r'_glPositionTemp.z * 2 - _glPositionTemp.w, ' + 103 r'_glPositionTemp.z * 2.0 - _glPositionTemp.w, ' +
104 r'_glPositionTemp.w);', body) 104 r'_glPositionTemp.w);', body)
105 105
106 return '\n'.join(attributes) + '\n\n' + body 106 return '\n'.join(attributes) + '\n\n' + body
107 107
108 108
109 def fix_glsl(glsl_shader): 109 def fix_glsl(glsl_shader):
110 header, body = re.split(r'\n\n', glsl_shader, 1) 110 header, body = re.split(r'\n\n', glsl_shader, 1)
111 assert all(l.startswith('//') for l in header.splitlines()) 111 assert all(l.startswith('//') for l in header.splitlines())
112 input_mapping = get_input_mapping(header) 112 input_mapping = get_input_mapping(header)
113 return header + '\n\n' + fix_glsl_body(body, input_mapping) 113 return header + '\n\n' + fix_glsl_body(body, input_mapping)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 try: 182 try:
183 input = sys.stdin.read() 183 input = sys.stdin.read()
184 except KeyboardInterrupt: 184 except KeyboardInterrupt:
185 input = None 185 input = None
186 186
187 if not input: 187 if not input:
188 cmdline_parser.print_help() 188 cmdline_parser.print_help()
189 else: 189 else:
190 main(input) 190 main(input)
OLDNEW
« no previous file with comments | « no previous file | samples/o3d-webgl-samples/helloworld.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698