@@ -1287,9 +1287,9 @@ protected PGL initTex2DShader() {
12871287 PGL ppgl = primaryPGL ? this : graphics .getPrimaryPGL ();
12881288
12891289 if (!ppgl .loadedTex2DShader || ppgl .tex2DShaderContext != ppgl .glContext ) {
1290- String [] preprocVertSrc = preprocessVertexSource (texVertShaderSource , getGLSLVersion ());
1290+ String [] preprocVertSrc = preprocessVertexSource (texVertShaderSource , getGLSLVersion (), getGLSLVersionSuffix () );
12911291 String vertSource = PApplet .join (preprocVertSrc , "\n " );
1292- String [] preprocFragSrc = preprocessFragmentSource (tex2DFragShaderSource , getGLSLVersion ());
1292+ String [] preprocFragSrc = preprocessFragmentSource (tex2DFragShaderSource , getGLSLVersion (), getGLSLVersionSuffix () );
12931293 String fragSource = PApplet .join (preprocFragSrc , "\n " );
12941294 ppgl .tex2DVertShader = createShader (VERTEX_SHADER , vertSource );
12951295 ppgl .tex2DFragShader = createShader (FRAGMENT_SHADER , fragSource );
@@ -1419,9 +1419,9 @@ protected PGL initTexRectShader() {
14191419 PGL ppgl = primaryPGL ? this : graphics .getPrimaryPGL ();
14201420
14211421 if (!ppgl .loadedTexRectShader || ppgl .texRectShaderContext != ppgl .glContext ) {
1422- String [] preprocVertSrc = preprocessVertexSource (texVertShaderSource , getGLSLVersion ());
1422+ String [] preprocVertSrc = preprocessVertexSource (texVertShaderSource , getGLSLVersion (), getGLSLVersionSuffix () );
14231423 String vertSource = PApplet .join (preprocVertSrc , "\n " );
1424- String [] preprocFragSrc = preprocessFragmentSource (texRectFragShaderSource , getGLSLVersion ());
1424+ String [] preprocFragSrc = preprocessFragmentSource (texRectFragShaderSource , getGLSLVersion (), getGLSLVersionSuffix () );
14251425 String fragSource = PApplet .join (preprocFragSrc , "\n " );
14261426 ppgl .texRectVertShader = createShader (VERTEX_SHADER , vertSource );
14271427 ppgl .texRectFragShader = createShader (FRAGMENT_SHADER , fragSource );
@@ -1848,6 +1848,7 @@ protected static int qualityToSamples(int quality) {
18481848
18491849
18501850 abstract protected int getGLSLVersion ();
1851+ abstract protected String getGLSLVersionSuffix ();
18511852
18521853
18531854 protected String [] loadVertexShader (String filename ) {
@@ -1880,28 +1881,29 @@ protected String[] loadVertexShader(URL url) {
18801881 }
18811882
18821883
1883- protected String [] loadVertexShader (String filename , int version ) {
1884+ protected String [] loadVertexShader (String filename , int version , String versionSuffix ) {
18841885 return loadVertexShader (filename );
18851886 }
18861887
18871888
1888- protected String [] loadFragmentShader (String filename , int version ) {
1889+ protected String [] loadFragmentShader (String filename , int version , String versionSuffix ) {
18891890 return loadFragmentShader (filename );
18901891 }
18911892
18921893
1893- protected String [] loadFragmentShader (URL url , int version ) {
1894+ protected String [] loadFragmentShader (URL url , int version , String versionSuffix ) {
18941895 return loadFragmentShader (url );
18951896 }
18961897
18971898
1898- protected String [] loadVertexShader (URL url , int version ) {
1899+ protected String [] loadVertexShader (URL url , int version , String versionSuffix ) {
18991900 return loadVertexShader (url );
19001901 }
19011902
19021903
19031904 protected static String [] preprocessFragmentSource (String [] fragSrc0 ,
1904- int version ) {
1905+ int version ,
1906+ String versionSuffix ) {
19051907 if (containsVersionDirective (fragSrc0 )) {
19061908 // The user knows what she or he is doing
19071909 return fragSrc0 ;
@@ -1915,7 +1917,7 @@ protected static String[] preprocessFragmentSource(String[] fragSrc0,
19151917 int offset = 1 ;
19161918
19171919 fragSrc = preprocessShaderSource (fragSrc0 , search , replace , offset );
1918- fragSrc [0 ] = "#version " + version ;
1920+ fragSrc [0 ] = "#version " + version + versionSuffix ;
19191921 } else {
19201922 // We need to replace 'texture' uniform by 'texMap' uniform and
19211923 // 'textureXXX()' functions by 'texture()' functions. Order of these
@@ -1932,15 +1934,16 @@ protected static String[] preprocessFragmentSource(String[] fragSrc0,
19321934 int offset = 2 ;
19331935
19341936 fragSrc = preprocessShaderSource (fragSrc0 , search , replace , offset );
1935- fragSrc [0 ] = "#version " + version ;
1937+ fragSrc [0 ] = "#version " + version + versionSuffix ;
19361938 fragSrc [1 ] = "out vec4 _fragColor;" ;
19371939 }
19381940
19391941 return fragSrc ;
19401942 }
19411943
19421944 protected static String [] preprocessVertexSource (String [] vertSrc0 ,
1943- int version ) {
1945+ int version ,
1946+ String versionSuffix ) {
19441947 if (containsVersionDirective (vertSrc0 )) {
19451948 // The user knows what she or he is doing
19461949 return vertSrc0 ;
@@ -1954,7 +1957,7 @@ protected static String[] preprocessVertexSource(String[] vertSrc0,
19541957 int offset = 1 ;
19551958
19561959 vertSrc = preprocessShaderSource (vertSrc0 , search , replace , offset );
1957- vertSrc [0 ] = "#version " + version ;
1960+ vertSrc [0 ] = "#version " + version + versionSuffix ;
19581961 } else {
19591962 // We need to replace 'texture' uniform by 'texMap' uniform and
19601963 // 'textureXXX()' functions by 'texture()' functions. Order of these
@@ -1971,7 +1974,7 @@ protected static String[] preprocessVertexSource(String[] vertSrc0,
19711974 int offset = 1 ;
19721975
19731976 vertSrc = preprocessShaderSource (vertSrc0 , search , replace , offset );
1974- vertSrc [0 ] = "#version " + version ;
1977+ vertSrc [0 ] = "#version " + version + versionSuffix ;
19751978 }
19761979
19771980 return vertSrc ;
0 commit comments