Skip to content

Commit a5984ad

Browse files
authored
Merge pull request #378 from processing/rc1
Merge rc1 branch
2 parents 79fc0f4 + 2b0f03a commit a5984ad

File tree

83 files changed

+5004
-4393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5004
-4393
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
<classpathentry combineaccessrules="false" kind="src" path="/processing-app"/>
66
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
77
<classpathentry combineaccessrules="false" kind="src" path="/processing-java"/>
8-
<classpathentry kind="lib" path="/processing-java/mode/antlr.jar"/>
8+
<classpathentry kind="lib" path="mode/gradle-tooling-api-4.0.jar"/>
99
<classpathentry kind="output" path="core/bin"/>
1010
</classpath>

build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ allprojects {
1414
apply plugin: 'java'
1515

1616
ext.android_platform = "$sdkdir/platforms/android-$sdkver"
17+
ext.android_tools_lib = "$sdkdir/platforms/android-$sdkver/tools/lib"
1718
ext.core_jar_path = "$rootDir/processing-core.zip"
1819

1920
repositories {
2021
jcenter()
2122
flatDir dirs: "$rootDir/core/library"
2223
flatDir dirs: "$rootDir/core/build/libs"
2324
flatDir dirs: "$rootDir/libraries/vr/library"
25+
flatDir dirs: "$sdkdir/tools/lib"
2426
flatDir dirs: android_platform
27+
flatDir dirs: android_tools_lib
2528
}
2629

2730
sourceCompatibility = 1.7
@@ -32,9 +35,10 @@ dependencies {
3235
compile name: 'android'
3336
compile project(":core")
3437
compile project(":libraries:vr")
35-
compile group: 'org.processing', name: 'core', version: '3.2.3'
36-
compile group: 'org.processing', name: 'pde', version: '3.2.3'
37-
compile group: 'org.processing', name: 'java-mode', version: '3.2.3'
38+
compile group: 'org.processing', name: 'core', version: '3.3.4'
39+
compile group: 'org.processing', name: 'pde', version: '3.3.4'
40+
compile group: 'org.processing', name: 'java-mode', version: '3.3.4'
41+
compile "org.gradle:gradle-tooling-api:4.0"
3842
}
3943

4044
sourceSets {
@@ -71,13 +75,16 @@ task dist {
7175

7276
Files.copy(file("mode.properties").toPath(),
7377
file("$root/mode.properties").toPath(), REPLACE_EXISTING);
78+
79+
FileUtils.copyDirectory(file("tools/SDKUpdater/tool"),
80+
file("$root/tools/SDKUpdater/tool"))
81+
FileUtils.copyDirectory(file("tools/SDKUpdater/src"),
82+
file("$root/tools/SDKUpdater/src"))
7483

7584
FileUtils.copyDirectory(file("libraries/vr/examples"),
7685
file("$root/libraries/vr/examples"))
7786
FileUtils.copyDirectory(file("libraries/vr/gvrsdk"),
7887
file("$root/libraries/vr/gvrsdk"))
79-
FileUtils.copyDirectory(file("libraries/vr/lib"),
80-
file("$root/libraries/vr/lib"))
8188
FileUtils.copyDirectory(file("libraries/vr/library"),
8289
file("$root/libraries/vr/library"))
8390
FileUtils.copyDirectory(file("libraries/vr/src"),

build.xml

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<!-- path to the main processing repo -->
66
<property name="processing.dir" value="../processing" />
77

8+
<!-- path to the android sdk -->
9+
<property name="sdk.dir" value="/Users/andres/code/android/android-studio/sdk" />
10+
811
<property name="core.jar.path" value="processing-core.zip" />
912
<property name="mode.jar.path" value="mode/AndroidMode.jar" />
1013
<property name="mode.dist.path" value="release/AndroidMode.zip" />
@@ -28,21 +31,16 @@
2831
<!-- env used to set classpath below -->
2932
<property environment="env" />
3033

31-
<!--
32-
classpath="../core/library/core.jar; lib/ant.jar; lib/ant-launcher.jar; lib/antlr.jar; lib/apple.jar; lib/jdt-core.jar; lib/jna.jar; lib/org-netbeans-swing-outline.jar;lib/com.ibm.icu_4.4.2.v20110823.jar;lib/jdi.jar;lib/jdimodel.jar;lib/org.eclipse.osgi_3.8.1.v20120830-144521.jar"
33-
-->
3434
<javac source="1.7"
3535
target="1.7"
3636
destdir="bin"
3737
encoding="UTF-8"
3838
includeAntRuntime="false"
3939
classpath="${processing.dir}/core/library/core.jar;
4040
${processing.dir}/java/mode/JavaMode.jar;
41-
${processing.dir}/java/mode/antlr.jar;
42-
${processing.dir}/java/mode/org.eclipse.core.runtime.jar;
43-
${processing.dir}/app/pde.jar;
44-
${processing.dir}/app/lib/ant.jar;
45-
${processing.dir}/app/lib/ant-launcher.jar"
41+
${processing.dir}/java/mode/org.eclipse.core.runtime.jar;
42+
${processing.dir}/app/pde.jar;
43+
mode/gradle-tooling-api-4.0.jar"
4644
debug="on">
4745
<src path="src" />
4846
</javac>
@@ -53,35 +51,10 @@
5351
<jar basedir="bin" destfile="${mode.jar.path}" />
5452
</target>
5553

56-
57-
<!-- now that this is standalone, probably not really needed -->
58-
<!--
59-
<target name="android-dist-check">
60-
-->
61-
<!-- ensure that the processing-core.zip file has been built -->
62-
<!--
63-
<available file="${core.jar.path}"
64-
property="android-core-present" />
65-
-->
66-
<!--<echo message="${target.path}/modes/android/processing-core.zip" />-->
67-
<!--
68-
<fail unless="android-core-present"
69-
message="processing-core.zip was not built, but is required for dist. Install the Android tools, set ANDROID_SDK, and try again." />
70-
</target>
71-
-->
72-
7354

7455
<target name="dist" depends="build"
7556
description="Create AndroidMode.zip and AndroidMode.txt">
7657
<mkdir dir="release" />
77-
78-
<!--
79-
<copy todir="mode">
80-
<fileset dir="core/library">
81-
<include name="*.jar" />
82-
</fileset>
83-
</copy>
84-
-->
8558

8659
<zip destfile="${mode.dist.path}">
8760
<zipfileset dir="." prefix="AndroidMode">
@@ -92,6 +65,8 @@
9265
<include name="examples/**" />
9366
<include name="icons/**" />
9467
<include name="theme/**" />
68+
<include name="tools/SDKUpdater/tool/**" />
69+
<include name="tools/SDKUpdater/src/**" />
9570
<include name="libraries/vr/library.properties" />
9671
<include name="libraries/vr/examples/**" />
9772
<include name="libraries/vr/gvrsdk/**" />
@@ -112,13 +87,14 @@
11287

11388
<target name="subprojects-clean">
11489
<subant buildpath="core" target="clean"/>
115-
<subant buildpath="libraries/vr" target="clean"/>
90+
<subant buildpath="tools/SDKUpdater" target="clean"/>
91+
<subant buildpath="libraries/vr" target="clean"/>
11692
</target>
11793

11894
<target name="subprojects-build">
11995
<subant buildpath="core" target="build"/>
120-
<subant buildpath="libraries/vr" target="build"/>
96+
<subant buildpath="tools/SDKUpdater" target="build"/>
97+
<subant buildpath="libraries/vr" target="build"/>
12198
</target>
122-
12399

124100
</project>

core/src/assets/shaders/LineVert.glsl

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Part of the Processing project - http://processing.org
33
4-
Copyright (c) 2012-16 The Processing Foundation
4+
Copyright (c) 2012-17 The Processing Foundation
55
Copyright (c) 2004-12 Ben Fry and Casey Reas
66
Copyright (c) 2001-04 Massachusetts Institute of Technology
77
@@ -35,53 +35,63 @@ attribute vec4 direction;
3535

3636
varying vec4 vertColor;
3737

38-
vec3 clipToWindow(vec4 clip, vec4 viewport) {
39-
vec3 post_div = clip.xyz / clip.w;
40-
vec2 xypos = (post_div.xy + vec2(1.0, 1.0)) * 0.5 * viewport.zw;
41-
return vec3(xypos, post_div.z * 0.5 + 0.5);
42-
}
43-
44-
vec4 windowToClipVector(vec2 window, vec4 viewport, float clip_w) {
45-
vec2 xypos = (window / viewport.zw) * 2.0;
46-
return vec4(xypos, 0.0, 0.0) * clip_w;
47-
}
48-
4938
void main() {
5039
vec4 posp = modelviewMatrix * position;
51-
40+
vec4 posq = modelviewMatrix * (position + vec4(direction.xyz, 0));
41+
5242
// Moving vertices slightly toward the camera
5343
// to avoid depth-fighting with the fill triangles.
5444
// Discussed here:
5545
// http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848
5646
posp.xyz = posp.xyz * scale;
57-
vec4 clipp = projectionMatrix * posp;
47+
posq.xyz = posq.xyz * scale;
48+
49+
vec4 p = projectionMatrix * posp;
50+
vec4 q = projectionMatrix * posq;
51+
52+
// formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])
53+
// screen_p = (p.xy/p.w + <1,1>) * 0.5 * viewport.zw
54+
55+
// prevent division by W by transforming the tangent formula (div by 0 causes
56+
// the line to disappear, see https://github.com/processing/processing/issues/5183)
57+
// t = screen_q - screen_p
58+
//
59+
// tangent is normalized and we don't care which direction it points to (+-)
60+
// t = +- normalize( screen_q - screen_p )
61+
// t = +- normalize( (q.xy/q.w+<1,1>)*0.5*viewport.zw - (p.xy/p.w+<1,1>)*0.5*viewport.zw )
62+
//
63+
// extract common factor, <1,1> - <1,1> cancels out
64+
// t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * viewport.zw )
65+
//
66+
// convert to common divisor
67+
// t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * viewport.zw )
68+
//
69+
// remove the common scalar divisor/factor, not needed due to normalize and +-
70+
// (keep viewport - can't remove because it has different components for x and y
71+
// and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)
72+
// t = +- normalize( (q.xy*p.w - p.xy*q.w) * viewport.zw )
73+
74+
vec2 tangent = normalize((q.xy*p.w - p.xy*q.w) * viewport.zw);
75+
76+
// flip tangent to normal (it's already normalized)
77+
vec2 normal = vec2(-tangent.y, tangent.x);
78+
5879
float thickness = direction.w;
59-
60-
if (thickness != 0.0) {
61-
vec4 posq = posp + modelviewMatrix * vec4(direction.xyz, 0);
62-
posq.xyz = posq.xyz * scale;
63-
vec4 clipq = projectionMatrix * posq;
64-
65-
vec3 window_p = clipToWindow(clipp, viewport);
66-
vec3 window_q = clipToWindow(clipq, viewport);
67-
vec3 tangent = window_q - window_p;
68-
69-
vec2 perp = normalize(vec2(-tangent.y, tangent.x));
70-
vec2 offset = perp * thickness;
71-
72-
if (0 < perspective) {
73-
// Perspective correction (lines will look thiner as they move away
74-
// from the view position).
75-
gl_Position.xy = clipp.xy + offset.xy;
76-
gl_Position.zw = clipp.zw;
77-
} else {
78-
// No perspective correction.
79-
vec4 offsetp = windowToClipVector(offset, viewport, clipp.w);
80-
gl_Position = clipp + offsetp;
81-
}
82-
} else {
83-
gl_Position = clipp;
84-
}
85-
80+
vec2 offset = normal * thickness;
81+
82+
// Perspective ---
83+
// convert from world to clip by multiplying with projection scaling factor
84+
// to get the right thickness (see https://github.com/processing/processing/issues/5182)
85+
// invert Y, projections in Processing invert Y
86+
vec2 perspScale = (projectionMatrix * vec4(1, -1, 0, 0)).xy;
87+
88+
// No Perspective ---
89+
// multiply by W (to cancel out division by W later in the pipeline) and
90+
// convert from screen to clip (derived from clip to screen above)
91+
vec2 noPerspScale = p.w / (0.5 * viewport.zw);
92+
93+
gl_Position.xy = p.xy + offset.xy * mix(noPerspScale, perspScale, float(perspective > 0));
94+
gl_Position.zw = p.zw;
95+
8696
vertColor = color;
8797
}

core/src/assets/shaders/PointVert.glsl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Part of the Processing project - http://processing.org
33
4-
Copyright (c) 2012-16 The Processing Foundation
4+
Copyright (c) 2012-17 The Processing Foundation
55
Copyright (c) 2004-12 Ben Fry and Casey Reas
66
Copyright (c) 2001-04 Massachusetts Institute of Technology
77
@@ -32,24 +32,25 @@ attribute vec2 offset;
3232

3333
varying vec4 vertColor;
3434

35-
vec4 windowToClipVector(vec2 window, vec4 viewport, float clipw) {
36-
vec2 xypos = (window / viewport.zw) * 2.0;
37-
return vec4(xypos, 0.0, 0.0) * clipw;
38-
}
39-
4035
void main() {
4136
vec4 pos = modelviewMatrix * position;
4237
vec4 clip = projectionMatrix * pos;
43-
44-
if (0 < perspective) {
45-
// Perspective correction (points will look thiner as they move away
46-
// from the view position).
47-
gl_Position = clip + projectionMatrix * vec4(offset.xy, 0, 0);
48-
} else {
49-
// No perspective correction.
50-
vec4 cloff = windowToClipVector(offset.xy, viewport, clip.w);
51-
gl_Position = clip + cloff;
52-
}
38+
39+
// Perspective ---
40+
// convert from world to clip by multiplying with projection scaling factor
41+
// invert Y, projections in Processing invert Y
42+
vec2 perspScale = (projectionMatrix * vec4(1, -1, 0, 0)).xy;
43+
44+
// formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])
45+
// screen_p = (p.xy/p.w + <1,1>) * 0.5 * viewport.zw
46+
47+
// No Perspective ---
48+
// multiply by W (to cancel out division by W later in the pipeline) and
49+
// convert from screen to clip (derived from clip to screen above)
50+
vec2 noPerspScale = clip.w / (0.5 * viewport.zw);
51+
52+
gl_Position.xy = clip.xy + offset.xy * mix(noPerspScale, perspScale, float(perspective > 0));
53+
gl_Position.zw = clip.zw;
5354

5455
vertColor = color;
5556
}

core/src/processing/a2d/PGraphicsAndroid2D.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ public void endDraw() {
241241
if (screen != null) {
242242
screen.drawBitmap(bitmap, new Matrix(), null);
243243
}
244+
} catch (Exception e) {
245+
e.printStackTrace();
244246
} finally {
245247
if (screen != null) {
246248
try {

0 commit comments

Comments
 (0)