Skip to content

Commit d635609

Browse files
committed
shader preprocessing fixes
1 parent d854dbc commit d635609

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

core/src/processing/opengl/PGL.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Part of the Processing project - http://processing.org
55
6-
Copyright (c) 2012-16 The Processing Foundation
6+
Copyright (c) 2012-17 The Processing Foundation
77
Copyright (c) 2004-12 Ben Fry and Casey Reas
88
Copyright (c) 2001-04 Massachusetts Institute of Technology
99
@@ -1991,8 +1991,9 @@ protected static String[] preprocessShaderSource(String[] src0,
19911991
String[] src = new String[src0.length+offset];
19921992
for (int i = 0; i < src0.length; i++) {
19931993
String line = src0[i];
1994-
if (line.contains("#version")) {
1995-
line = "";
1994+
int versionIndex = line.indexOf("#version");
1995+
if (versionIndex >= 0) {
1996+
line = line.substring(0, versionIndex);
19961997
}
19971998
for (int j = 0; j < search.length; j++) {
19981999
line = search[j].matcher(line).replaceAll(replace[j]);
@@ -2005,8 +2006,12 @@ protected static String[] preprocessShaderSource(String[] src0,
20052006
protected static boolean containsVersionDirective(String[] shSrc) {
20062007
for (int i = 0; i < shSrc.length; i++) {
20072008
String line = shSrc[i];
2008-
if (line.contains("#version")) {
2009-
return true;
2009+
int versionIndex = line.indexOf("#version");
2010+
if (versionIndex >= 0) {
2011+
int commentIndex = line.indexOf("//");
2012+
if (commentIndex < 0 || versionIndex < commentIndex) {
2013+
return true;
2014+
}
20102015
}
20112016
}
20122017
return false;

0 commit comments

Comments
 (0)