Fix compatibility with desktop GL in cg2xml.

This commit is contained in:
Themaister 2013-01-26 14:24:42 +01:00
parent 73e98ca78a
commit 3888b31c79

View File

@ -139,9 +139,16 @@ def hack_source_vertex(source):
for index, line in enumerate(source):
if 'void main()' in line:
source.insert(index + 2, ' mat4 rubyMVPMatrix_ = transpose_(rubyMVPMatrix);') # transpose() is GLSL 1.20+, doesn't exist in GLSL ES 1.0
source.insert(index, '#endif')
source.insert(index, 'uniform vec2 rubyInputSize;')
source.insert(index, 'uniform vec2 rubyTextureSize;')
source.insert(index, 'uniform vec2 rubyOutputSize;')
source.insert(index, '#else')
source.insert(index, 'uniform mediump vec2 rubyInputSize;')
source.insert(index, 'uniform mediump vec2 rubyTextureSize;')
source.insert(index, 'uniform mediump vec2 rubyOutputSize;')
source.insert(index, '#ifdef GL_ES')
source.insert(index, """
mat4 transpose_(mat4 matrix)
{
@ -175,9 +182,15 @@ def replace_global_fragment(source):
def hack_source_fragment(source):
for index, line in enumerate(source):
if 'void main()' in line:
source.insert(index, '#endif')
source.insert(index, 'uniform vec2 rubyInputSize;')
source.insert(index, 'uniform vec2 rubyTextureSize;')
source.insert(index, 'uniform vec2 rubyOutputSize;')
source.insert(index, '#else')
source.insert(index, 'uniform mediump vec2 rubyInputSize;')
source.insert(index, 'uniform mediump vec2 rubyTextureSize;')
source.insert(index, 'uniform mediump vec2 rubyOutputSize;')
source.insert(index, '#ifdef GL_ES')
break
for line in source: