Skip to content

Commit e9d0e43

Browse files
committed
fix point and line shader autodetection
1 parent a092931 commit e9d0e43

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

core/src/processing/opengl/PShader.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ public class PShader implements PConstants {
5151

5252
static protected String pointShaderAttrRegexp =
5353
"attribute *vec2 *offset";
54+
static protected String pointShaderInRegexp =
55+
"in *vec2 *offset;";
5456
static protected String lineShaderAttrRegexp =
5557
"attribute *vec4 *direction";
58+
static protected String lineShaderInRegexp =
59+
"in *vec4 *direction";
5660
static protected String pointShaderDefRegexp =
5761
"#define *PROCESSING_POINT_SHADER";
5862
static protected String lineShaderDefRegexp =
@@ -1016,15 +1020,8 @@ protected void dispose() {
10161020
static protected int getShaderType(String[] source, int defaultType) {
10171021
for (int i = 0; i < source.length; i++) {
10181022
String line = source[i].trim();
1019-
if (PApplet.match(line, pointShaderAttrRegexp) != null)
1020-
return PShader.POINT;
1021-
else if (PApplet.match(line, lineShaderAttrRegexp) != null)
1022-
return PShader.LINE;
1023-
else if (PApplet.match(line, pointShaderDefRegexp) != null)
1024-
return PShader.POINT;
1025-
else if (PApplet.match(line, lineShaderDefRegexp) != null)
1026-
return PShader.LINE;
1027-
else if (PApplet.match(line, colorShaderDefRegexp) != null)
1023+
1024+
if (PApplet.match(line, colorShaderDefRegexp) != null)
10281025
return PShader.COLOR;
10291026
else if (PApplet.match(line, lightShaderDefRegexp) != null)
10301027
return PShader.LIGHT;
@@ -1038,6 +1035,18 @@ else if (PApplet.match(line, triShaderAttrRegexp) != null)
10381035
return PShader.POLY;
10391036
else if (PApplet.match(line, quadShaderAttrRegexp) != null)
10401037
return PShader.POLY;
1038+
else if (PApplet.match(line, pointShaderDefRegexp) != null)
1039+
return PShader.POINT;
1040+
else if (PApplet.match(line, lineShaderDefRegexp) != null)
1041+
return PShader.LINE;
1042+
else if (PApplet.match(line, pointShaderAttrRegexp) != null)
1043+
return PShader.POINT;
1044+
else if (PApplet.match(line, pointShaderInRegexp) != null)
1045+
return PShader.POINT;
1046+
else if (PApplet.match(line, lineShaderAttrRegexp) != null)
1047+
return PShader.LINE;
1048+
else if (PApplet.match(line, lineShaderInRegexp) != null)
1049+
return PShader.LINE;
10411050
}
10421051
return defaultType;
10431052
}

0 commit comments

Comments
 (0)