MCPcopy Index your code
hub / github.com/benfry/processing4 / preprocessVertexSource

Method preprocessVertexSource

core/src/processing/opengl/PGL.java:1992–2027  ·  view source on GitHub ↗
(String[] vertSrc0,
                                                   int version,
                                                   String versionSuffix)

Source from the content-addressed store, hash-verified

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*\\()";

Callers 3

initTex2DShaderMethod · 0.95
initTexRectShaderMethod · 0.95
loadVertexShaderMethod · 0.80

Calls 4

formatMethod · 0.65
compileMethod · 0.45

Tested by

no test coverage detected