(String[] fragSrc0,
int version,
String versionSuffix)
| 1902 | |
| 1903 | |
| 1904 | protected static String[] preprocessFragmentSource(String[] fragSrc0, |
| 1905 | int version, |
| 1906 | String versionSuffix) { |
| 1907 | if (containsVersionDirective(fragSrc0)) { |
| 1908 | // The user knows what she or he is doing |
| 1909 | return fragSrc0; |
| 1910 | } |
| 1911 | |
| 1912 | String[] fragSrc; |
| 1913 | |
| 1914 | if (version < 130) { |
| 1915 | Pattern[] search = { }; |
| 1916 | String[] replace = { }; |
| 1917 | int offset = 1; |
| 1918 | |
| 1919 | fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset); |
| 1920 | fragSrc[0] = "#version " + version + versionSuffix; |
| 1921 | } else { |
| 1922 | // We need to replace 'texture' uniform by 'texMap' uniform and |
| 1923 | // 'textureXXX()' functions by 'texture()' functions. Order of these |
| 1924 | // replacements is important to prevent collisions between these two. |
| 1925 | Pattern[] search = new Pattern[] { |
| 1926 | Pattern.compile(String.format(GLSL_ID_REGEX, "varying|attribute")), |
| 1927 | Pattern.compile(String.format(GLSL_ID_REGEX, "texture")), |
| 1928 | Pattern.compile(String.format(GLSL_FN_REGEX, "texture2DRect|texture2D|texture3D|textureCube")), |
| 1929 | Pattern.compile(String.format(GLSL_ID_REGEX, "gl_FragColor")) |
| 1930 | }; |
| 1931 | String[] replace = new String[] { |
| 1932 | "in", "texMap", "texture", "_fragColor" |
| 1933 | }; |
| 1934 | int offset = 2; |
| 1935 | |
| 1936 | fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset); |
| 1937 | fragSrc[0] = "#version " + version + versionSuffix; |
| 1938 | if (" es".equals(versionSuffix)) { |
| 1939 | fragSrc[1] = "out mediump vec4 _fragColor;"; |
| 1940 | } else { |
| 1941 | fragSrc[1] = "out vec4 _fragColor;"; |
| 1942 | } |
| 1943 | } |
| 1944 | |
| 1945 | return fragSrc; |
| 1946 | } |
| 1947 | |
| 1948 | protected static String[] preprocessVertexSource(String[] vertSrc0, |
| 1949 | int version, |
no test coverage detected