(String[] vertSrc0,
int version,
String versionSuffix)
| 1990 | } |
| 1991 | |
| 1992 | protected static String[] preprocessVertexSource(String[] vertSrc0, |
| 1993 | int version, |
| 1994 | String versionSuffix) { |
| 1995 | if (containsVersionDirective(vertSrc0)) { |
| 1996 | // The user knows what she or he is doing |
| 1997 | return vertSrc0; |
| 1998 | } |
| 1999 | |
| 2000 | String[] vertSrc; |
| 2001 | |
| 2002 | Pattern[] search; |
| 2003 | String[] replace; |
| 2004 | int offset = 1; |
| 2005 | if (version < 130) { |
| 2006 | search = new Pattern[] { }; |
| 2007 | replace = new String[] { }; |
| 2008 | |
| 2009 | } else { |
| 2010 | // We need to replace 'texture' uniform by 'texMap' uniform and |
| 2011 | // 'textureXXX()' functions by 'texture()' functions. Order of these |
| 2012 | // replacements is important to prevent collisions between these two. |
| 2013 | search = new Pattern[] { |
| 2014 | Pattern.compile(String.format(GLSL_ID_REGEX, "varying")), |
| 2015 | Pattern.compile(String.format(GLSL_ID_REGEX, "attribute")), |
| 2016 | Pattern.compile(String.format(GLSL_ID_REGEX, "texture")), |
| 2017 | Pattern.compile(String.format(GLSL_FN_REGEX, "texture2DRect|texture2D|texture3D|textureCube")) |
| 2018 | }; |
| 2019 | replace = new String[]{ |
| 2020 | "out", "in", "texMap", "texture", |
| 2021 | }; |
| 2022 | } |
| 2023 | vertSrc = preprocessShaderSource(vertSrc0, search, replace, offset); |
| 2024 | vertSrc[0] = "#version " + version + versionSuffix; |
| 2025 | |
| 2026 | return vertSrc; |
| 2027 | } |
| 2028 | |
| 2029 | |
| 2030 | protected static final String GLSL_ID_REGEX = "(?<![0-9A-Z_a-z])(%s)(?![0-9A-Z_a-z]|\\s*\\()"; |
no test coverage detected