# Draw 2D on top in VR mode

**URL:** <https://discourse.processing.org/t/draw-2d-on-top-in-vr-mode/5401>\
**Category:** Processing for Android\
**Created:** [November 10, 2018, 12:05pm UTC](https://discourse.processing.org/t/draw-2d-on-top-in-vr-mode/5401 "2018-11-10T12:05:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Post date:** [November 10, 2018, 12:05pm UTC](https://discourse.processing.org/t/draw-2d-on-top-in-vr-mode/5401/1 "2018-11-10T12:05:10Z")

</div>

There is the eye function for the VR mode:

[https://android.processing.org/reference/vr/eye.html](https://android.processing.org/reference/vr/eye.html)

here an example from the reference:

```auto
import processing.vr.*;

void setup() {
  fullScreen(STEREO);
}

void draw() {
   // draw scene...

   pushMatrix();
   eye();
   translate(0, 0, 100);
   ellipse(0, 0, 50, 50);
   popMatrix();
}

```

As you can see after the `eye()` call it is followed with a translate in the `z` direction.  
For me to get the 0,0 coordinate in the left top corner I have to do something like:

`translate(-width/2, -height/2, 1350);`

But the 1350 is just guessing and will probably fail on larger or smaller screens or screen with a different aspect ratio.

Is there a proper way to go into ‘2D’?

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [November 10, 2018, 1:24pm UTC](https://discourse.processing.org/t/draw-2d-on-top-in-vr-mode/5401/2 "2018-11-10T13:24:31Z")

</div>

You can use hint(DISABLE\_DEPTH\_TEST) to write on the screen and ENABLE\_DEPTH\_TEST to change back again.

---

<div class="post-metadata">

**Author:** ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Post date:** [November 10, 2018, 6:04pm UTC](https://discourse.processing.org/t/draw-2d-on-top-in-vr-mode/5401/3 "2018-11-10T18:04:37Z")

</div>

It ain’t about that. It’s about the position of the camera and the shape of the frustum.  
And that the motion doesn’t effect where it is displayed.

A bit like how you can normally use `camera()` to get to the default position.

---

<div class="post-metadata">

**Author:** ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Post date:** [November 26, 2018, 11:24pm UTC](https://discourse.processing.org/t/draw-2d-on-top-in-vr-mode/5401/4 "2018-11-26T23:24:13Z")

</div>

What I tried now is:

```java
void begin_2d() {

  pushMatrix();

  resetMatrix();

  // TODO figure out how this is defined

  applyMatrix(
    001.0000, 000.0000, 000.0000, -960.0000, 
    000.0000, 001.0000, 000.0000, -540.0000, 
    000.0000, 000.0000, 001.0000, -935.3074, 
    000.0000, 000.0000, 000.0000, 001.0000
    );

  noLights();
}

void end_2d() {
  popMatrix();
}

```

I got the coordinates from using a regular app first and checked that matrix.  
Although it looks close it is still incorrect.  
If someone could still help with the issue that would be really great.

---

<div class="post-metadata">

**Author:** ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)\
**Post date:** [November 27, 2018, 2:27pm UTC](https://discourse.processing.org/t/draw-2d-on-top-in-vr-mode/5401/5 "2018-11-27T14:27:31Z")

</div>

Ok, getting closer:

```auto

void begin_2d() {
  hint(DISABLE_DEPTH_TEST);
  pushMatrix();
  resetMatrix();
  ortho(0, width, -height, 0, -Float.MAX_VALUE, Float.MAX_VALUE);
}

void end_2d() {
  popMatrix();  
}

```

Only `DISABLE_DEPTH_TEST` doesn’t seem to work.
