Skip to content

Commit 5fcb528

Browse files
committed
automatically get update() method
1 parent d8f1715 commit 5fcb528

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

libraries/vr/src/processing/vr/PSurfaceVR.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.File;
2626
import java.io.InputStream;
27+
import java.lang.reflect.Method;
2728

2829
import javax.microedition.khronos.egl.EGLConfig;
2930

@@ -57,12 +58,21 @@ public class PSurfaceVR extends PSurfaceGLES {
5758
protected GvrActivity vrActivity;
5859
protected AndroidVRStereoRenderer renderer;
5960

61+
protected Method updateMethod;
62+
protected Object[] noArgs = new Object[] {};
63+
6064
public PSurfaceVR(PGraphics graphics, AppComponent component, SurfaceHolder holder, boolean vr) {
6165
this.sketch = graphics.parent;
6266
this.graphics = graphics;
6367
this.component = component;
6468
this.pgl = (PGLES)((PGraphicsOpenGL)graphics).pgl;
6569

70+
Class<?> c = sketch.getClass();
71+
try {
72+
updateMethod = c.getMethod("update", new Class[] {});
73+
} catch (Exception e) {
74+
}
75+
6676
vrActivity = (GvrActivity)component;
6777
this.activity = vrActivity;
6878
pvr = (PGraphicsVR)graphics;
@@ -276,6 +286,12 @@ public void onNewFrame(HeadTransform transform) {
276286
hadnleGVREnumError();
277287
pgl.getGL(null);
278288
pvr.headTransform(transform);
289+
if (updateMethod != null) {
290+
try {
291+
updateMethod.invoke(sketch, noArgs);
292+
} catch (Exception e) {
293+
}
294+
}
279295
}
280296

281297
@Override

0 commit comments

Comments
 (0)