Skip to content

Commit d848800

Browse files
committed
don't auto-convert shader code if PROFILE is 2
1 parent 41ef7cb commit d848800

File tree

1 file changed

+44
-37
lines changed

1 file changed

+44
-37
lines changed

core/src/processing/opengl/PJOGL.java

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
public class PJOGL extends PGL {
5757
// OpenGL profile to use (2, 3 or 4)
58-
public static int PROFILE = 3;
58+
public static int PROFILE = 2;
5959

6060
// The two windowing toolkits available to use in JOGL:
6161
public static final int AWT = 0; // http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing
@@ -988,7 +988,7 @@ public void keyTyped(com.jogamp.newt.event.KeyEvent e) {
988988

989989
@Override
990990
protected void enableTexturing(int target) {
991-
if (PROFILE == 2) enable(target);
991+
//if (PROFILE == 2) enable(target);
992992
if (target == TEXTURE_2D) {
993993
texturingTargets[0] = true;
994994
} else if (target == TEXTURE_RECTANGLE) {
@@ -999,7 +999,7 @@ protected void enableTexturing(int target) {
999999

10001000
@Override
10011001
protected void disableTexturing(int target) {
1002-
if (PROFILE == 2) disable(target);
1002+
//if (PROFILE == 2) disable(target);
10031003
if (target == TEXTURE_2D) {
10041004
texturingTargets[0] = false;
10051005
} else if (target == TEXTURE_RECTANGLE) {
@@ -1041,27 +1041,31 @@ protected Object getDerivedFont(Object font, float size) {
10411041
@Override
10421042
protected String[] loadFragmentShader(URL url) {
10431043
try {
1044-
String[] fragSrc0 = PApplet.loadStrings(url.openStream());
1045-
// PApplet.join(PApplet.loadStrings(url.openStream()), "\n");
1046-
String[] fragSrc = new String[fragSrc0.length + 2];
1047-
fragSrc[0] = "#version 150";
1048-
fragSrc[1] = "out vec4 fragColor;";
1049-
1050-
for (int i = 0; i < fragSrc0.length; i++) {
1051-
String line = fragSrc0[i];
1052-
System.out.print(line + " ---> ");
1053-
1054-
line = line.replace("varying", "in");
1055-
line = line.replace("attribute", "in");
1056-
line = line.replace("gl_FragColor", "fragColor");
1057-
line = line.replace("texture", "texSampler");
1058-
line = line.replace("texSampler2D(", "texture(");
1059-
1060-
fragSrc[i + 2] = line;
1061-
System.out.println(line);
1062-
}
1044+
if (2 < PROFILE) {
1045+
String[] fragSrc0 = PApplet.loadStrings(url.openStream());
1046+
// PApplet.join(PApplet.loadStrings(url.openStream()), "\n");
1047+
String[] fragSrc = new String[fragSrc0.length + 2];
1048+
fragSrc[0] = "#version 150";
1049+
fragSrc[1] = "out vec4 fragColor;";
1050+
1051+
for (int i = 0; i < fragSrc0.length; i++) {
1052+
String line = fragSrc0[i];
1053+
System.out.print(line + " ---> ");
1054+
1055+
line = line.replace("varying", "in");
1056+
line = line.replace("attribute", "in");
1057+
line = line.replace("gl_FragColor", "fragColor");
1058+
line = line.replace("texture", "texSampler");
1059+
line = line.replace("texSampler2D(", "texture(");
1060+
1061+
fragSrc[i + 2] = line;
1062+
System.out.println(line);
1063+
}
10631064

1064-
return fragSrc;
1065+
return fragSrc;
1066+
} else {
1067+
return PApplet.loadStrings(url.openStream());
1068+
}
10651069
} catch (IOException e) {
10661070
PGraphics.showException("Cannot load fragment shader " + url.getFile());
10671071
}
@@ -1071,21 +1075,24 @@ protected String[] loadFragmentShader(URL url) {
10711075
@Override
10721076
protected String[] loadVertexShader(URL url) {
10731077
try {
1074-
String[] vertSrc0 = PApplet.loadStrings(url.openStream());
1075-
String[] vertSrc = new String[vertSrc0.length + 1];
1076-
vertSrc[0] = "#version 150";
1077-
1078-
for (int i = 0; i < vertSrc0.length; i++) {
1079-
String line = vertSrc0[i];
1080-
System.out.print(line + " ---> ");
1081-
line = line.replace("attribute", "in");
1082-
line = line.replace("varying", "out");
1083-
vertSrc[i + 1] = line;
1084-
System.out.println(line);
1085-
}
1078+
if (2 < PROFILE) {
1079+
String[] vertSrc0 = PApplet.loadStrings(url.openStream());
1080+
String[] vertSrc = new String[vertSrc0.length + 1];
1081+
vertSrc[0] = "#version 150";
1082+
1083+
for (int i = 0; i < vertSrc0.length; i++) {
1084+
String line = vertSrc0[i];
1085+
System.out.print(line + " ---> ");
1086+
line = line.replace("attribute", "in");
1087+
line = line.replace("varying", "out");
1088+
vertSrc[i + 1] = line;
1089+
System.out.println(line);
1090+
}
10861091

1087-
return vertSrc;
1088-
//PApplet.join(PApplet.loadStrings(url.openStream()), "\n");
1092+
return vertSrc;
1093+
} else {
1094+
return PApplet.loadStrings(url.openStream());
1095+
}
10891096
} catch (IOException e) {
10901097
PGraphics.showException("Cannot load vertex shader " + url.getFile());
10911098
}

0 commit comments

Comments
 (0)