# I want to show text in screen independently while using 3D camera

**URL:** <https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361>\
**Category:** Coding Questions\
**Created:** [May 1, 2020, 6:18pm UTC](https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361 "2020-05-01T18:18:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SilverPrevail](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@SilverPrevail](https://discourse.processing.org/u/SilverPrevail)\
**Post date:** [May 1, 2020, 6:18pm UTC](https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361/1 "2020-05-01T18:18:43Z")

</div>

```auto
import java.awt.AWTException;
import java.awt.Robot;

public class Player{
  public float x;
  public float y;
  public float z;
  public float vz;
  public float theta;
  public float phi;
  public float speed;
}

boolean isUp,isDown,isRight,isLeft,isJump;
int Pspeed = 5;
Robot robby;  
PGraphics pg;

int w=1920,h=1080;
Player P=new Player();
void setup(){
  fullScreen(P3D);
  P.x=0;
  P.y=0;
  P.z=100;
  P.theta=P.phi=0;
  P.speed = 5;
  try
  {
    robby = new Robot();
  }
  catch (AWTException e)
  {
    println("Robot class not supported by your system!");
    exit();
  }
  robby.mouseMove(w/2,h/2);
  pg = createGraphics(w, h);
}

void drawSphere(float x,float y,float z,float r){
  pushMatrix();
    translate(x,y,z);
    sphere(r);
  popMatrix();
}

void keyPressed() {
  setMove(keyCode, true);
}
 
void keyReleased() {
  setMove(keyCode, false);
}

boolean setMove(int k, boolean b) {
  switch (k) {
  case 'W':
  case UP:
    return isUp = b;
 
  case 'S':
  case DOWN:
    return isDown = b;
 
  case 'A':
  case LEFT:
    return isLeft = b;
 
  case 'D':
  case RIGHT:
    return isRight = b;
    
  case ' ':
    return isJump = b;
 
  default:
    return b;
  }
}

void moveP(){
  if(isUp){
    P.x+=P.speed*cos(P.theta);
    P.y+=P.speed*sin(P.theta);
  }
  if(isDown){
    P.x-=P.speed*cos(P.theta);
    P.y-=P.speed*sin(P.theta);
  }
  if(isLeft){
    P.x+=P.speed*sin(P.theta);
    P.y-=P.speed*cos(P.theta);
  }
  if(isRight){
    P.x-=P.speed*sin(P.theta);
    P.y+=P.speed*cos(P.theta);
  }
  if(isJump){
    if(P.z-100<=5)
      P.vz=10;
  }
  P.z+=P.vz;
  if(P.z-100>0)
    P.vz-=0.5;
  P.z=max(P.z,100);
}

void draw(){
  noCursor();
  background(255/2);
//THIS IS THE CODE//
  hint(DISABLE_DEPTH_TEST);
  pushMatrix();
  resetMatrix();
  fill(255);
  camera();
  textSize(50);
  text("Quarks was here", 700,700);
  popMatrix();
  hint(ENABLE_DEPTH_TEST);
//THIS IS THE CODE//
  rectMode(CENTER);
  fill(128,64,0);
  rect(0,0,1000,1000);
  lights();
  fill(0,0,255);
  drawSphere(0,0,300,100);
  fill(0,255,0);
  drawSphere(0,300,0,100);
  fill(255,0,0);
  drawSphere(300,0,0,100);
  fill(255,255,0);
  drawSphere(0,0,-300,100);
  fill(255,0,255);
  drawSphere(0,-300,0,100);
  fill(0,255,255);
  drawSphere(-300,0,0,100);
  P.theta+=-(w/2-mouseX+0.0)*3/w;
  P.phi+=-(h/2-mouseY+0.0)/h;
  P.phi=constrain(P.phi,-PI/2,PI/2);
  robby.mouseMove(w/2,h/2);
  moveP();
  camera(P.x,P.y,P.z,
  P.x+cos(P.phi)*cos(P.theta),P.y+cos(P.phi)*sin(P.theta),P.z-sin(P.phi),
  cos(P.phi+90)*cos(P.theta),cos(P.phi+90)*sin(P.theta),-sin(P.phi+90));
//THIS IS THE CODE//
  hint(DISABLE_DEPTH_TEST);
  pushMatrix();
  resetMatrix();
  fill(255);
  camera();
  textSize(50);
  text("Quarks was here", 150,150);
  popMatrix();
  hint(ENABLE_DEPTH_TEST);
//THIS IS THE CODE//
}

```

This is my code, and I wanted to write a independent text on the screen from the 3d images I’m showing. You can see the codes I’ve tried at draw function. The code written above the text is obscured by the 3d objects, and the code written below changes transparency while I move my mouse.  
Why does this happen? And how can I show text at my screen, without any of these problems?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 1, 2020, 6:23pm UTC](https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361/2 "2020-05-01T18:23:38Z")

</div>

See number 9

> **[25 life-saving tips for Processing](https://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/)**
>
> I have bundled a huge number and variety of code examples in this single mega-post. Please learn from my mistakes and experiences! ;-)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 1, 2020, 6:24pm UTC](https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361/3 "2020-05-01T18:24:04Z")

</div>

…and welcome to the forum!

Great to have you here!

---

<div class="post-metadata">

**Author:** ![SilverPrevail](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@SilverPrevail](https://discourse.processing.org/u/SilverPrevail)\
**Post date:** [May 1, 2020, 6:26pm UTC](https://discourse.processing.org/t/i-want-to-show-text-in-screen-independently-while-using-3d-camera/20361/4 "2020-05-01T18:26:33Z")

</div>

Great thanks to you. So it was because I haven’t turned off the lights… I am really new to processing(It’s been only two weeks since I’ve been taught this at school and I’m been told to make a fps game ;-; ) and it’s really kind of you to answer this so fast! Thanks again!
