| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
14 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,6 +98,8 @@ public class Base { | |||
| 98 | 98 | } | |
| 99 | 99 | } | |
| 100 | 100 | ||
| 101 | + static String nativeArch = System.getProperty("os.arch"); | ||
| 102 | + | ||
| 101 | 103 | static private boolean commandLine; | |
| 102 | 104 | ||
| 103 | 105 | // A single instance of the preferences window | |
@@ -1543,6 +1545,30 @@ static public int getNativeBits() { | |||
| 1543 | 1545 | return nativeBits; | |
| 1544 | 1546 | } | |
| 1545 | 1547 | ||
| 1548 | + /** | ||
| 1549 | + * Return the value of the os.arch propery | ||
| 1550 | + */ | ||
| 1551 | + static public String getNativeArch() { | ||
| 1552 | + return nativeArch; | ||
| 1553 | + } | ||
| 1554 | + | ||
| 1555 | + /* | ||
| 1556 | + * Return a string that identifies the variant of a platform | ||
| 1557 | + * e.g. "32" or "64" on Intel | ||
| 1558 | + */ | ||
| 1559 | + static public String getVariant() { | ||
| 1560 | + return getVariant(PApplet.platform, getNativeArch(), getNativeBits()); | ||
| 1561 | + } | ||
| 1562 | + | ||
| 1563 | + static public String getVariant(int platform, String arch, int bits) { | ||
| 1564 | + if (platform == PConstants.LINUX && bits == 32 && "arm".equals(Base.getNativeArch())) { | ||
| 1565 | + // assume armv6hf for now | ||
| 1566 | + return "armv6hf"; | ||
| 1567 | + } else { | ||
| 1568 | + // 32 or 64 | ||
| 1569 | + return Integer.toString(bits); | ||
| 1570 | + } | ||
| 1571 | + } | ||
| 1546 | 1572 | ||
| 1547 | 1573 | /* | |
| 1548 | 1574 | static public String getPlatformName() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,6 +173,7 @@ private Library(File folder, String groupName) { | |||
| 173 | 173 | String platformName = platformNames[i]; | |
| 174 | 174 | String platformName32 = platformName + "32"; | |
| 175 | 175 | String platformName64 = platformName + "64"; | |
| 176 | + String platformNameArmv6hh = platformName + "-armv6hf"; | ||
| 176 | 177 | ||
| 177 | 178 | // First check for things like 'application.macosx=' or 'application.windows32' in the export.txt file. | |
| 178 | 179 | // These will override anything in the platform-specific subfolders. | |
@@ -182,6 +183,8 @@ private Library(File folder, String groupName) { | |||
| 182 | 183 | String[] platformList32 = platform32 == null ? null : PApplet.splitTokens(platform32, ", "); | |
| 183 | 184 | String platform64 = exportTable.get("application." + platformName + "64"); | |
| 184 | 185 | String[] platformList64 = platform64 == null ? null : PApplet.splitTokens(platform64, ", "); | |
| 186 | + String platformArmv6hf = exportTable.get("application." + platformName + "-armv6hf"); | ||
| 187 | + String[] platformListArmv6hf = platformArmv6hf == null ? null : PApplet.splitTokens(platformArmv6hf, ", "); | ||
| 185 | 188 | ||
| 186 | 189 | // If nothing specified in the export.txt entries, look for the platform-specific folders. | |
| 187 | 190 | if (platformAll == null) { | |
@@ -193,14 +196,17 @@ private Library(File folder, String groupName) { | |||
| 193 | 196 | if (platform64 == null) { | |
| 194 | 197 | platformList64 = listPlatformEntries(libraryFolder, platformName64, baseList); | |
| 195 | 198 | } | |
| 199 | + if (platformListArmv6hf == null) { | ||
| 200 | + platformListArmv6hf = listPlatformEntries(libraryFolder, platformNameArmv6hh, baseList); | ||
| 201 | + } | ||
| 196 | 202 | ||
| 197 | - if (platformList32 != null || platformList64 != null) { | ||
| 203 | + if (platformList32 != null || platformList64 != null || platformListArmv6hf != null) { | ||
| 198 | 204 | multipleArch[i] = true; | |
| 199 | 205 | } | |
| 200 | 206 | ||
| 201 | 207 | // if there aren't any relevant imports specified or in their own folders, | |
| 202 | 208 | // then use the baseList (root of the library folder) as the default. | |
| 203 | - if (platformList == null && platformList32 == null && platformList64 == null) { | ||
| 209 | + if (platformList == null && platformList32 == null && platformList64 == null && platformListArmv6hf == null) { | ||
| 204 | 210 | exportList.put(platformName, baseList); | |
| 205 | 211 | ||
| 206 | 212 | } else { | |
@@ -215,6 +221,9 @@ private Library(File folder, String groupName) { | |||
| 215 | 221 | if (platformList64 != null) { | |
| 216 | 222 | exportList.put(platformName64, platformList64); | |
| 217 | 223 | } | |
| 224 | + if (platformListArmv6hf != null) { | ||
| 225 | + exportList.put(platformNameArmv6hh, platformListArmv6hf); | ||
| 226 | + } | ||
| 218 | 227 | } | |
| 219 | 228 | } | |
| 220 | 229 | // for (String p : exportList.keySet()) { | |
@@ -369,8 +378,8 @@ public File[] getAppletExports() { | |||
| 369 | 378 | } | |
| 370 | 379 | ||
| 371 | 380 | ||
| 372 | - public File[] getApplicationExports(int platform, int bits) { | ||
| 373 | - String[] list = getApplicationExportList(platform, bits); | ||
| 381 | + public File[] getApplicationExports(int platform, String variant) { | ||
| 382 | + String[] list = getApplicationExportList(platform, variant); | ||
| 374 | 383 | return wrapFiles(list); | |
| 375 | 384 | } | |
| 376 | 385 | ||
@@ -380,14 +389,17 @@ public File[] getApplicationExports(int platform, int bits) { | |||
| 380 | 389 | * If no 32 or 64-bit version of the exports exists, it returns the version | |
| 381 | 390 | * that doesn't specify bit depth. | |
| 382 | 391 | */ | |
| 383 | - public String[] getApplicationExportList(int platform, int bits) { | ||
| 392 | + public String[] getApplicationExportList(int platform, String variant) { | ||
| 384 | 393 | String platformName = PConstants.platformNames[platform]; | |
| 385 | - if (bits == 32) { | ||
| 394 | + if (variant.equals("32")) { | ||
| 386 | 395 | String[] pieces = exportList.get(platformName + "32"); | |
| 387 | 396 | if (pieces != null) return pieces; | |
| 388 | - } else if (bits == 64) { | ||
| 397 | + } else if (variant.equals("64")) { | ||
| 389 | 398 | String[] pieces = exportList.get(platformName + "64"); | |
| 390 | 399 | if (pieces != null) return pieces; | |
| 400 | + } else if (variant.equals("armv6hf")) { | ||
| 401 | + String[] pieces = exportList.get(platformName + "-armv6hf"); | ||
| 402 | + if (pieces != null) return pieces; | ||
| 391 | 403 | } | |
| 392 | 404 | return exportList.get(platformName); | |
| 393 | 405 | } | |
@@ -408,12 +420,12 @@ public boolean hasMultipleArch(int platform) { | |||
| 408 | 420 | } | |
| 409 | 421 | ||
| 410 | 422 | ||
| 411 | - public boolean supportsArch(int platform, int bits) { | ||
| 423 | + public boolean supportsArch(int platform, String variant) { | ||
| 412 | 424 | // If this is a universal library, or has no natives, then we're good. | |
| 413 | 425 | if (multipleArch[platform] == false) { | |
| 414 | 426 | return true; | |
| 415 | 427 | } | |
| 416 | - return getApplicationExportList(platform, bits) != null; | ||
| 428 | + return getApplicationExportList(platform, variant) != null; | ||
| 417 | 429 | } | |
| 418 | 430 | ||
| 419 | 431 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,7 @@ | |||
| 37 | 37 | <!-- there is currently no JRE available --> | |
| 38 | 38 | <property name="jre.download.jdk" value="true" /> | |
| 39 | 39 | <property name="jre.downloader" value="linux-arm-vfp-hflt.tar.gz" /> | |
| 40 | + <property name="linux.dist" value="linux/processing-${version}-linux-armv6hf.tgz" /> | ||
| 40 | 41 | </target> | |
| 41 | 42 | ||
| 42 | 43 | <!-- Require Java 8 everywhere. --> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,8 +63,8 @@ | |||
| 63 | 63 | <!-- Copy shaders to bin. (Eclipse does this automatically.) --> | |
| 64 | 64 | <copy todir="bin"> | |
| 65 | 65 | <fileset dir="src"> | |
| 66 | - <include name="processing/opengl/shaders/*.glsl" /> | ||
| 67 | - <include name="icon/*.png" /> | ||
| 66 | + <include name="processing/opengl/shaders/*.glsl" /> | ||
| 67 | + <include name="icon/*.png" /> | ||
| 68 | 68 | </fileset> | |
| 69 | 69 | </copy> | |
| 70 | 70 | </target> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,3 +8,4 @@ application.windows32=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-wind | |||
| 8 | 8 | application.windows64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-windows-amd64.jar,gluegen-rt-natives-windows-amd64.jar | |
| 9 | 9 | application.linux32=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-i586.jar,gluegen-rt-natives-linux-i586.jar | |
| 10 | 10 | application.linux64=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-amd64.jar,gluegen-rt-natives-linux-amd64.jar | |
| 11 | + application.linux-armv6hf=core.jar,jogl-all.jar,gluegen-rt.jar,jogl-all-natives-linux-armv6hf.jar,gluegen-rt-natives-linux-armv6hf.jar | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7042,9 +7042,15 @@ protected void setDrawDefaults() { | |||
| 7042 | 7042 | if (smooth < 1) { | |
| 7043 | 7043 | pgl.disable(PGL.MULTISAMPLE); | |
| 7044 | 7044 | } else { | |
| 7045 | - pgl.enable(PGL.MULTISAMPLE); | ||
| 7045 | + // work around runtime exceptions in Broadcom's VC IV driver | ||
| 7046 | + if (false == OPENGL_RENDERER.equals("VideoCore IV HW")) { | ||
| 7047 | + pgl.enable(PGL.MULTISAMPLE); | ||
| 7048 | + } | ||
| 7049 | + } | ||
| 7050 | + // work around runtime exceptions in Broadcom's VC IV driver | ||
| 7051 | + if (false == OPENGL_RENDERER.equals("VideoCore IV HW")) { | ||
| 7052 | + pgl.disable(PGL.POLYGON_SMOOTH); | ||
| 7046 | 7053 | } | |
| 7047 | - pgl.disable(PGL.POLYGON_SMOOTH); | ||
| 7048 | 7054 | ||
| 7049 | 7055 | if (sized) { | |
| 7050 | 7056 | // reapplySettings(); | |
@@ -7154,14 +7160,27 @@ protected void getGLParameters() { | |||
| 7154 | 7160 | pgl.getIntegerv(PGL.MAX_TEXTURE_SIZE, intBuffer); | |
| 7155 | 7161 | maxTextureSize = intBuffer.get(0); | |
| 7156 | 7162 | ||
| 7157 | - pgl.getIntegerv(PGL.MAX_SAMPLES, intBuffer); | ||
| 7158 | - maxSamples = intBuffer.get(0); | ||
| 7163 | + // work around runtime exceptions in Broadcom's VC IV driver | ||
| 7164 | + if (false == OPENGL_RENDERER.equals("VideoCore IV HW")) { | ||
| 7165 | + pgl.getIntegerv(PGL.MAX_SAMPLES, intBuffer); | ||
| 7166 | + maxSamples = intBuffer.get(0); | ||
| 7167 | + } | ||
| 7159 | 7168 | ||
| 7160 | 7169 | if (anisoSamplingSupported) { | |
| 7161 | 7170 | pgl.getFloatv(PGL.MAX_TEXTURE_MAX_ANISOTROPY, floatBuffer); | |
| 7162 | 7171 | maxAnisoAmount = floatBuffer.get(0); | |
| 7163 | 7172 | } | |
| 7164 | 7173 | ||
| 7174 | + // overwrite the default shaders with vendor specific versions | ||
| 7175 | + // if needed | ||
| 7176 | + if (OPENGL_RENDERER.equals("VideoCore IV HW") || // Broadcom's binary driver for Raspberry Pi | ||
| 7177 | + OPENGL_RENDERER.equals("Gallium 0.4 on VC4")) { // Mesa driver for same hardware | ||
| 7178 | + defLightShaderVertURL = | ||
| 7179 | + PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LightVert-vc4.glsl"); | ||
| 7180 | + defTexlightShaderVertURL = | ||
| 7181 | + PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexLightVert-vc4.glsl"); | ||
| 7182 | + } | ||
| 7183 | + | ||
| 7165 | 7184 | glParamsRead = true; | |
| 7166 | 7185 | } | |
| 7167 | 7186 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -195,7 +195,13 @@ protected void initGL() { | |||
| 195 | 195 | if (profile == null) { | |
| 196 | 196 | if (PJOGL.profile == 2) { | |
| 197 | 197 | try { | |
| 198 | - profile = GLProfile.getGL2ES1(); | ||
| 198 | + if ("arm".equals(System.getProperty("os.arch"))) { | ||
| 199 | + // request at least GL2 or GLES2 | ||
| 200 | + profile = GLProfile.getGL2ES2(); | ||
| 201 | + } else { | ||
| 202 | + // stay compatible with previous versions for now | ||
| 203 | + profile = GLProfile.getGL2ES1(); | ||
| 204 | + } | ||
| 199 | 205 | } catch (GLException ex) { | |
| 200 | 206 | profile = GLProfile.getMaxFixedFunc(true); | |
| 201 | 207 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,153 @@ | |||
| 1 | + /* | ||
| 2 | + Part of the Processing project - http://processing.org | ||
| 3 | + | ||
| 4 | + Copyright (c) 2011-13 Ben Fry and Casey Reas | ||
| 5 | + | ||
| 6 | + This library is free software; you can redistribute it and/or | ||
| 7 | + modify it under the terms of the GNU Lesser General Public | ||
| 8 | + License version 2.1 as published by the Free Software Foundation. | ||
| 9 | + | ||
| 10 | + This library is distributed in the hope that it will be useful, | ||
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | + Lesser General Public License for more details. | ||
| 14 | + | ||
| 15 | + You should have received a copy of the GNU Lesser General | ||
| 16 | + Public License along with this library; if not, write to the | ||
| 17 | + Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
| 18 | + Boston, MA 02111-1307 USA | ||
| 19 | + */ | ||
| 20 | + | ||
| 21 | + #define PROCESSING_LIGHT_SHADER | ||
| 22 | + | ||
| 23 | + uniform mat4 modelviewMatrix; | ||
| 24 | + uniform mat4 transformMatrix; | ||
| 25 | + uniform mat3 normalMatrix; | ||
| 26 | + | ||
| 27 | + uniform int lightCount; | ||
| 28 | + uniform vec4 lightPosition[8]; | ||
| 29 | + uniform vec3 lightNormal[8]; | ||
| 30 | + uniform vec3 lightAmbient[8]; | ||
| 31 | + uniform vec3 lightDiffuse[8]; | ||
| 32 | + uniform vec3 lightSpecular[8]; | ||
| 33 | + uniform vec3 lightFalloff[8]; | ||
| 34 | + uniform vec2 lightSpot[8]; | ||
| 35 | + | ||
| 36 | + attribute vec4 position; | ||
| 37 | + attribute vec4 color; | ||
| 38 | + attribute vec3 normal; | ||
| 39 | + | ||
| 40 | + attribute vec4 ambient; | ||
| 41 | + attribute vec4 specular; | ||
| 42 | + attribute vec4 emissive; | ||
| 43 | + attribute float shininess; | ||
| 44 | + | ||
| 45 | + varying vec4 vertColor; | ||
| 46 | + varying vec4 backVertColor; | ||
| 47 | + | ||
| 48 | + const float zero_float = 0.0; | ||
| 49 | + const float one_float = 1.0; | ||
| 50 | + const vec3 zero_vec3 = vec3(0); | ||
| 51 | + | ||
| 52 | + float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) { | ||
| 53 | + vec3 lpv = lightPos - vertPos; | ||
| 54 | + vec3 dist = vec3(one_float); | ||
| 55 | + dist.z = dot(lpv, lpv); | ||
| 56 | + dist.y = sqrt(dist.z); | ||
| 57 | + return one_float / dot(dist, coeff); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + float spotFactor(vec3 lightPos, vec3 vertPos, vec3 lightNorm, float minCos, float spotExp) { | ||
| 61 | + vec3 lpv = normalize(lightPos - vertPos); | ||
| 62 | + vec3 nln = -one_float * lightNorm; | ||
| 63 | + float spotCos = dot(nln, lpv); | ||
| 64 | + return spotCos <= minCos ? zero_float : pow(spotCos, spotExp); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + float lambertFactor(vec3 lightDir, vec3 vecNormal) { | ||
| 68 | + return max(zero_float, dot(lightDir, vecNormal)); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + float blinnPhongFactor(vec3 lightDir, vec3 vertPos, vec3 vecNormal, float shine) { | ||
| 72 | + vec3 np = normalize(vertPos); | ||
| 73 | + vec3 ldp = normalize(lightDir - np); | ||
| 74 | + return pow(max(zero_float, dot(ldp, vecNormal)), shine); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + void main() { | ||
| 78 | + // Vertex in clip coordinates | ||
| 79 | + gl_Position = transformMatrix * position; | ||
| 80 | + | ||
| 81 | + // Vertex in eye coordinates | ||
| 82 | + vec3 ecVertex = vec3(modelviewMatrix * position); | ||
| 83 | + | ||
| 84 | + // Normal vector in eye coordinates | ||
| 85 | + vec3 ecNormal = normalize(normalMatrix * normal); | ||
| 86 | + vec3 ecNormalInv = ecNormal * -one_float; | ||
| 87 | + | ||
| 88 | + // Light calculations | ||
| 89 | + vec3 totalAmbient = vec3(0, 0, 0); | ||
| 90 | + | ||
| 91 | + vec3 totalFrontDiffuse = vec3(0, 0, 0); | ||
| 92 | + vec3 totalFrontSpecular = vec3(0, 0, 0); | ||
| 93 | + | ||
| 94 | + vec3 totalBackDiffuse = vec3(0, 0, 0); | ||
| 95 | + vec3 totalBackSpecular = vec3(0, 0, 0); | ||
| 96 | + | ||
| 97 | + // prevent register allocation failure by limiting ourselves to | ||
| 98 | + // two lights for now | ||
| 99 | + for (int i = 0; i < 2; i++) { | ||
| 100 | + if (lightCount == i) break; | ||
| 101 | + | ||
| 102 | + vec3 lightPos = lightPosition[i].xyz; | ||
| 103 | + bool isDir = zero_float < lightPosition[i].w; | ||
| 104 | + float spotCos = lightSpot[i].x; | ||
| 105 | + float spotExp = lightSpot[i].y; | ||
| 106 | + | ||
| 107 | + vec3 lightDir; | ||
| 108 | + float falloff; | ||
| 109 | + float spotf; | ||
| 110 | + | ||
| 111 | + if (isDir) { | ||
| 112 | + falloff = one_float; | ||
| 113 | + lightDir = -one_float * lightNormal[i]; | ||
| 114 | + } else { | ||
| 115 | + falloff = falloffFactor(lightPos, ecVertex, lightFalloff[i]); | ||
| 116 | + lightDir = normalize(lightPos - ecVertex); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + spotf = spotExp > zero_float ? spotFactor(lightPos, ecVertex, lightNormal[i], | ||
| 120 | + spotCos, spotExp) | ||
| 121 | + : one_float; | ||
| 122 | + | ||
| 123 | + if (any(greaterThan(lightAmbient[i], zero_vec3))) { | ||
| 124 | + totalAmbient += lightAmbient[i] * falloff; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + if (any(greaterThan(lightDiffuse[i], zero_vec3))) { | ||
| 128 | + totalFrontDiffuse += lightDiffuse[i] * falloff * spotf * | ||
| 129 | + lambertFactor(lightDir, ecNormal); | ||
| 130 | + totalBackDiffuse += lightDiffuse[i] * falloff * spotf * | ||
| 131 | + lambertFactor(lightDir, ecNormalInv); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + if (any(greaterThan(lightSpecular[i], zero_vec3))) { | ||
| 135 | + totalFrontSpecular += lightSpecular[i] * falloff * spotf * | ||
| 136 | + blinnPhongFactor(lightDir, ecVertex, ecNormal, shininess); | ||
| 137 | + totalBackSpecular += lightSpecular[i] * falloff * spotf * | ||
| 138 | + blinnPhongFactor(lightDir, ecVertex, ecNormalInv, shininess); | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + // Calculating final color as result of all lights (plus emissive term). | ||
| 143 | + // Transparency is determined exclusively by the diffuse component. | ||
| 144 | + vertColor = vec4(totalAmbient, 0) * ambient + | ||
| 145 | + vec4(totalFrontDiffuse, 1) * color + | ||
| 146 | + vec4(totalFrontSpecular, 0) * specular + | ||
| 147 | + vec4(emissive.rgb, 0); | ||
| 148 | + | ||
| 149 | + backVertColor = vec4(totalAmbient, 0) * ambient + | ||
| 150 | + vec4(totalBackDiffuse, 1) * color + | ||
| 151 | + vec4(totalBackSpecular, 0) * specular + | ||
| 152 | + vec4(emissive.rgb, 0); | ||
| 153 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ uniform vec4 lightPosition[8]; | |||
| 29 | 29 | uniform vec3 lightNormal[8]; | |
| 30 | 30 | uniform vec3 lightAmbient[8]; | |
| 31 | 31 | uniform vec3 lightDiffuse[8]; | |
| 32 | - uniform vec3 lightSpecular[8]; | ||
| 32 | + uniform vec3 lightSpecular[8]; | ||
| 33 | 33 | uniform vec3 lightFalloff[8]; | |
| 34 | 34 | uniform vec2 lightSpot[8]; | |
| 35 | 35 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments