(String[] fragSrc0,
int version,
String versionSuffix)
| 1946 | |
| 1947 | |
| 1948 | protected static String[] preprocessFragmentSource(String[] fragSrc0, |
| 1949 | int version, |
| 1950 | String versionSuffix) { |
| 1951 | if (containsVersionDirective(fragSrc0)) { |
| 1952 | // The user knows what she or he is doing |
| 1953 | return fragSrc0; |
| 1954 | } |
| 1955 | |
| 1956 | String[] fragSrc; |
| 1957 | |
| 1958 | if (version < 130) { |
| 1959 | Pattern[] search = { }; |
| 1960 | String[] replace = { }; |
| 1961 | int offset = 1; |
| 1962 | |
| 1963 | fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset); |
| 1964 | fragSrc[0] = "#version " + version + versionSuffix; |
| 1965 | } else { |
| 1966 | // We need to replace 'texture' uniform by 'texMap' uniform and |
| 1967 | // 'textureXXX()' functions by 'texture()' functions. Order of these |
| 1968 | // replacements is important to prevent collisions between these two. |
| 1969 | Pattern[] search = new Pattern[] { |
| 1970 | Pattern.compile(String.format(GLSL_ID_REGEX, "varying|attribute")), |
| 1971 | Pattern.compile(String.format(GLSL_ID_REGEX, "texture")), |
| 1972 | Pattern.compile(String.format(GLSL_FN_REGEX, "texture2DRect|texture2D|texture3D|textureCube")), |
| 1973 | Pattern.compile(String.format(GLSL_ID_REGEX, "gl_FragColor")) |
| 1974 | }; |
| 1975 | String[] replace = new String[] { |
| 1976 | "in", "texMap", "texture", "_fragColor" |
| 1977 | }; |
| 1978 | int offset = 2; |
| 1979 | |
| 1980 | fragSrc = preprocessShaderSource(fragSrc0, search, replace, offset); |
| 1981 | fragSrc[0] = "#version " + version + versionSuffix; |
| 1982 | if (" es".equals(versionSuffix)) { |
| 1983 | fragSrc[1] = "out mediump vec4 _fragColor;"; |
| 1984 | } else { |
| 1985 | fragSrc[1] = "out vec4 _fragColor;"; |
| 1986 | } |
| 1987 | } |
| 1988 | |
| 1989 | return fragSrc; |
| 1990 | } |
| 1991 | |
| 1992 | protected static String[] preprocessVertexSource(String[] vertSrc0, |
| 1993 | int version, |
no test coverage detected