# Rendering issues when not using APDE (PShape)

**URL:** <https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852>\
**Category:** Processing for Android\
**Created:** [July 26, 2020, 8:47pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852 "2020-07-26T20:47:16Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [July 26, 2020, 8:47pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/1 "2020-07-26T20:47:16Z")

</div>

When using PShapes in Processing, I ran in the following issue:

```auto

PShape cubeShape;
PShape secondaryShape;
PImage cubeImage;
PImage blank;
float rotationX;
float rotationY;
float sX, sY;
int childs;
PFont questionFont, optionFont;

void setup(){
  frameRate(60);
  orientation(PORTRAIT);
  fullScreen(P3D);
  shapeMode(CORNER);
  textAlign(CORNER);
  smooth(5);
  cubeShape = loadShape("Abc.obj");
  cubeShape.setFill(color(255));
  cubeShape.setTint(color(255));
  secondaryShape = loadShape("Abc.obj");
  secondaryShape.setFill(color(255));
  secondaryShape.setTint(color(255,255,255));
  cubeImage = loadImage("cubesite_front.PNG");
  childs = cubeShape.getChildCount();
  questionFont = createFont("cube.ttf",7); 
  optionFont = createFont("cube.ttf", 85);
  textureWrap(REPEAT);
  textureMode(IMAGE);
  secondaryShape.setTexture(loadImage("cubesite_any.png"));
  rotationX = 0.0f;
  rotationY = 0.0f;
  editSite(cubeImage, "Test", "Left", "Top", "Right", "Bottom");
  cubeImage = getMirror(cubeImage);
}

void draw(){
  cubeShape.setTexture(cubeImage);
  Runtime runtime = Runtime.getRuntime();
  float usedRam = 1.0f - (float) runtime.freeMemory() / (float) runtime.totalMemory();
  int usedRamPercent = (int) (usedRam*100.0f);
  background(255);
  lights();
  textSize(width/20);
  fill(0,125,255);
  text("Rotation X: " + String.valueOf(degrees(rotationX)).split("\\.")[0]+"°\n"+"Rotation Y: " + String.valueOf(degrees(rotationY)).split("\\.")[0]+"°",width/20,height/20);
  String rightBar = "Touch X: " + String.valueOf(sX) + "\nTouch Y: " + String.valueOf(sY) 
  + "\n\nRAM: " + usedRamPercent + "%"
  + "\nFPS: " + String.valueOf(frameRate).split("\\.")[0];
  text(rightBar,width-width/20-textWidth(rightBar),height/20); 
  textSize(width/20);
  fill(125,25,0);
  text("",width/2,height/7);
  if (rotationX>=TWO_PI||rotationX<=-TWO_PI) rotationX=0;
  if (rotationY>=TWO_PI||rotationY<=-TWO_PI) rotationY=0;
  for (int i = 0; i <childs; i++){
    PShape currentChild = cubeShape.getChild(i); 
    PShape secondaryChild = secondaryShape.getChild(i);
    boolean front = true;
    for (int j = 0; j < currentChild.getVertexCount(); j++){
      PVector currentVector = currentChild.getVertex(j);
      front = !(currentVector.z<0.95);
    }
    pushMatrix();
    translate(width/2,height/2,height/6);
    scale(height/7);
    rotateX(rotationX);
    rotateY(rotationY);
    shape(front ? currentChild : secondaryChild);
    popMatrix();
  }
}
 

PImage getMirror(PImage img) {
  PGraphics pg = createGraphics(img.width, img.height, JAVA2D);
  pg.beginDraw();
  pg.smooth(4);
  pg.scale(-1, 1);
  pg.image(img, -img.width, 0);
  pg.endDraw();
  return pg.get();
}

private void editSite(PImage background, String center, String left, String top, String right, String bottom){ 
  PGraphics siteGraphics = createGraphics(background.width,background.height); 
  imageMode(CORNER); 
  siteGraphics.beginDraw(); 
  siteGraphics.image(background,0,0); 
  siteGraphics.textSize(width/10); 
  fittedText(siteGraphics,center,questionFont,siteGraphics.width/2,siteGraphics.height/2,siteGraphics.width-siteGraphics.width/6,siteGraphics.height-siteGraphics.height/6); 
  siteGraphics.pushMatrix(); 
  siteGraphics.translate(0,0);
  siteGraphics.rotate(-HALF_PI); 
  siteGraphics.textAlign(CENTER, CENTER); 
  siteGraphics.textFont(optionFont); 
  siteGraphics.text(left,-siteGraphics.height/2,siteGraphics.width/6/2); 
  siteGraphics.rotate(PI); 
  siteGraphics.text(right,siteGraphics.height/2,-siteGraphics.width+siteGraphics.width/6/2); 
  siteGraphics.rotate(-HALF_PI); 
  siteGraphics.text(top,siteGraphics.width/2,siteGraphics.height/6/2); 
  siteGraphics.text(bottom,siteGraphics.width/2,siteGraphics.height-siteGraphics.height/6/2); siteGraphics.popMatrix(); 
  siteGraphics.endDraw(); 
  cubeImage = siteGraphics.get(); 
}

private final char NEWLINE = '\n'; private final String SPACE_SEPARATOR = " "; private final String SPLIT_REGEXP= "\\s+"; String breakLines(String input, int maxLineLength) { String[] tokens = input.split(SPLIT_REGEXP); StringBuilder output = new StringBuilder(input.length()); int lineLen = 0; for (int i = 0; i < tokens.length; i++) { String word = tokens[i]; if (lineLen + (SPACE_SEPARATOR + word).length() > maxLineLength) { if (i > 0) output.append(NEWLINE); lineLen = 0; } if (i < tokens.length - 1 && (lineLen + (word + SPACE_SEPARATOR).length() + tokens[i + 1].length() <=maxLineLength)) word += SPACE_SEPARATOR; output.append(word); lineLen += word.length(); } return output.toString();}
void fittedText(PGraphics graphics,String text, PFont font, float posX, float posY, float fitX, float fitY){ 
  text = breakLines(text, 15); 
  graphics.textFont(font); 
  graphics.textAlign(CENTER,CENTER); 
  graphics.textSize(min(font.getSize()*fitX/textWidth(text), fitY)); 
  graphics.textLeading(graphics.textSize*1.1); 
  graphics.text(text, posX, posY);
}

void mousePressed(){
  sX = mouseX;
  sY = mouseY;
}
void mouseDragged(){
  rotationX += (mouseY-sY)*(HALF_PI/(width));
  sY = mouseY;
  rotationY += (mouseX-sX)*(HALF_PI/(width));
  sX = mouseX;
}

```

The above demo code functions perfectly when run via APDE, but the texture is just one solid ugly color when build/run from a windows machine via PDE or Android Studio:

 ![bad](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cb6d6ab0eb11fba03dc656e9c97c97c6b26ff88b.jpeg) ![good](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5d86a802eee232db3873dc6fd73fd8d5d106b740.jpeg)

Does anyone know why this is happening and how I can fix it?

If needed I will upload the model as well if it is relevant!

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [July 26, 2020, 8:54pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/2 "2020-07-26T20:54:55Z")

</div>

> [@Mesalcode](#):
>
> If needed I will upload the model as well if it is relevant!

Could you zip all and place a shared link on Gdrive or alike?

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [July 27, 2020, 7:22am UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/3 "2020-07-27T07:22:13Z")

</div>

[Here you go!](https://drive.google.com/file/d/1rmax4TvLXBcYblhqjXHtLchJUjYRv9YK/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [July 27, 2020, 7:23pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/4 "2020-07-27T19:23:27Z")

</div>

Fonts?..

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [July 27, 2020, 8:07pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/5 "2020-07-27T20:07:19Z")

</div>

Excuse me, but could you clarify? Are the fonts the problem causing this? If you are asking for the font file, it is included in the rar file.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [July 27, 2020, 9:33pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/6 "2020-07-27T21:33:57Z")

</div>

> [@Mesalcode](#):
>
> could you clarify

Sorry. I tested it on APDE and forgot that you need to use “app mode” when importing a file.  
I’ve tried for one hour to make my PC recognize my phone without success.  
USB debugging on, right phone driver installed, ADB reset, but nothing.  
And I’v got the emulator never to work. So I can’t help you to test the code.  
On APDE the code runs fine. The only thing I would add is a boolean to only draw when dragging, (to save battery.)

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [July 28, 2020, 8:24am UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/7 "2020-07-28T08:24:20Z")

</div>

Thank you for the advice. This is only a demo, but I think this implementation would be great in the real code too. Anyways the real problem still remains ☹. [This is the only thread I found, where the OP has the same problem.](https://forum.processing.org/two/discussion/19232/textures-on-3d-object-showing-as-solid-color)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [July 28, 2020, 10:46am UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/8 "2020-07-28T10:46:53Z")

</div>

You could try to solve it by taking away piece of code bit by bit, until finding the culprit.  
APDE uses a previous Processing Android mode ([Version 4.0](https://github.com/processing/processing-android/releases/tag/android-267)) You could install it on the PC to test it. Why do you need to run it on PC?

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 28, 2020, 4:59pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/9 "2020-07-28T16:59:20Z")

</div>

@Mesalcode === i have tested your code with android MM and P5 desktop osX 10.12: i get exactly what you want without any error (except for smooth which has to be called before beginShape)…Same thing with AS. I guess that your problem is with the cube.ttf font that i have installed in my font library. At this moment i got an alert: duplicate font with another name (i dont know what it was). Changing your font to Arial Black.ttf, the result is the same: good. Though Frame rate is slow (5FPS at max) and the other faces are not textured.

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [July 28, 2020, 5:25pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/10 "2020-07-28T17:25:33Z")

</div>

Could you send me the edited code that ran fine for you? When I try to rename the font file, it doesn’t change anything for me.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 28, 2020, 5:28pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/11 "2020-07-28T17:28:36Z")

</div>

@Mesalcode === it is useless; i have used exactly your code, just changing smooth and createFont() and putting ArialBlack.ttf font in the data folder .

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [July 28, 2020, 5:30pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/12 "2020-07-28T17:30:56Z")

</div>

I did that and it still doesn’t work for me on Windows. You meantioned some sort of font library, which are you using?

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 28, 2020, 5:34pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/13 "2020-07-28T17:34:11Z")

</div>

@Mesalcode === as i run osX the font library is inside the general library as a subfolder: i dont know for windows.  
PS: i have tested with nougat and Huawei phone: everything works fine (your Touch is not dip, and it returns weird values, like 1000) but that is not the main problem.

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [July 28, 2020, 6:02pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/14 "2020-07-28T18:02:31Z")

</div>

@akenaton For me even this minimal code doesn’t display the texture correctly.

```auto
PShape cubeShape;
PImage cubeImage;

void setup(){
  orientation(PORTRAIT);
  fullScreen(P3D);
  shapeMode(CORNER);
  textureWrap(REPEAT);
  textureMode(IMAGE);
  cubeShape = loadShape("Abc.obj");
  cubeShape.setFill(color(255));
  cubeShape.setTint(color(255));
  cubeImage = loadImage("cubesite_front.PNG");
  cubeShape.setTexture(cubeImage);
  
}

void draw(){
  background(255);
  lights();
  translate(width/2,height/2,height/6);
  scale(height/7);
  shape(cubeShape);
}

```

Does this work on your machine?

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 29, 2020, 9:10am UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/15 "2020-07-29T09:10:25Z")

</div>

@Mesalcode === tested; it works: i can see the same thing than on you image, without text.

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [August 2, 2020, 5:45pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/16 "2020-08-02T17:45:50Z")

</div>

Thats so odd… The same code just produces this one-colored cube for me.

What Processing version are you using?

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [August 3, 2020, 8:38am UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/17 "2020-08-03T08:38:53Z")

</div>

@Mesalcode === i dont know exactly but quite the last one

---

<div class="post-metadata">

**Author:** ![Mesalcode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mesalcode/32/9284_2.png) [@Mesalcode](https://discourse.processing.org/u/Mesalcode)\
**Post date:** [August 26, 2020, 12:43pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/18 "2020-08-26T12:43:26Z")

</div>

Just to confirm, you really used Android Mode and launched the above code on your phone without an issue? I tried this on Windows and Pop!\_OS and it just never works.

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [August 26, 2020, 12:55pm UTC](https://discourse.processing.org/t/rendering-issues-when-not-using-apde-pshape/22852/19 "2020-08-26T12:55:30Z")

</div>

@Mesalcode === i do confirm; tested with nexus7 MM && huawei 9.
