|
24 | 24 |
|
25 | 25 | import java.io.File;
|
26 | 26 | import java.io.InputStream;
|
| 27 | +import java.lang.reflect.Method; |
27 | 28 |
|
28 | 29 | import javax.microedition.khronos.egl.EGLConfig;
|
29 | 30 |
|
@@ -57,12 +58,21 @@ public class PSurfaceVR extends PSurfaceGLES {
|
57 | 58 | protected GvrActivity vrActivity;
|
58 | 59 | protected AndroidVRStereoRenderer renderer;
|
59 | 60 |
|
| 61 | + protected Method updateMethod; |
| 62 | + protected Object[] noArgs = new Object[] {}; |
| 63 | + |
60 | 64 | public PSurfaceVR(PGraphics graphics, AppComponent component, SurfaceHolder holder, boolean vr) {
|
61 | 65 | this.sketch = graphics.parent;
|
62 | 66 | this.graphics = graphics;
|
63 | 67 | this.component = component;
|
64 | 68 | this.pgl = (PGLES)((PGraphicsOpenGL)graphics).pgl;
|
65 | 69 |
|
| 70 | + Class<?> c = sketch.getClass(); |
| 71 | + try { |
| 72 | + updateMethod = c.getMethod("update", new Class[] {}); |
| 73 | + } catch (Exception e) { |
| 74 | + } |
| 75 | + |
66 | 76 | vrActivity = (GvrActivity)component;
|
67 | 77 | this.activity = vrActivity;
|
68 | 78 | pvr = (PGraphicsVR)graphics;
|
@@ -276,6 +286,12 @@ public void onNewFrame(HeadTransform transform) {
|
276 | 286 | hadnleGVREnumError();
|
277 | 287 | pgl.getGL(null);
|
278 | 288 | pvr.headTransform(transform);
|
| 289 | + if (updateMethod != null) { |
| 290 | + try { |
| 291 | + updateMethod.invoke(sketch, noArgs); |
| 292 | + } catch (Exception e) { |
| 293 | + } |
| 294 | + } |
279 | 295 | }
|
280 | 296 |
|
281 | 297 | @Override
|
|
0 commit comments