Loading...
Logo
Processing Forum
Hi,

I'd like to use a bunch of PShapes in my sketch but have found that when I change my renderer to either P2D or OPENGL, my text starts looking awful. If I use the default JAVA2D renderer though, then the text looks great but my PShapes don't appear.

I read this post on text rendering in P2D/P3D but my problem isn't that the text doesn't appear so much as the text just looks bad.(I get the same thing using both createFont(name,size,true)  and loadFont(".... .vlw")). 


Here's some simple code I wrote up to test things out. It's loosely based on the star example at  http://processing.org/learning/pshape/  (with some changes to make it work -- denoted by arrows in the comments).
Copy code
  1. PShape aShape;
  2.  PFont font; 
  3.   void setup() { 
  4.     size(500,500,OPENGL);  //<-- changed from size(500,500)
  5.     smooth(); 
  6.     font = createFont("serif",20,true);
  7.     // First create the shape 
  8.     aShape = createShape(); 
  9.     //aShape = new PShape(3); //<-- need this if you're using default renderer or it'll throw an error
  10.     aShape.beginShape(); //<-- added this in
  11.     // You can set fill and stroke 
  12.     aShape.fill(102);  //<-- moved from before 'aShape = createShape()'
  13.     aShape.stroke(255);  //<-- moved from before 'aShape = createShape()'
  14.     aShape.strokeWeight(2);  //<-- moved from before 'aShape = createShape()'
  15.    
  16.     // Here, we are hardcoding a series of vertices 
  17.     aShape.vertex(0, 0); 
  18.     aShape.vertex(100,0); 
  19.     aShape.vertex(100,100); 
  20.     aShape.vertex(0,100); 
  21.     
  22.     // We are done with the shape 
  23.     aShape.endShape(CLOSE);  //<-- changed from aShape.end();
  24.   } 
  25.    
  26.   void draw() { 
  27.     background(255); 
  28.     // draw the shape. 
  29.     shape(aShape,mouseX,mouseY); // <-- doesn't appear if I use default renderer
  30.     
  31.     // write some text
  32.     fill(0); textAlign(CENTER,CENTER);
  33.     int i=-1; while(++i<10){
  34.       textSize(15+i); 
  35.       text("bigger",width/2,23*i+20);
  36.     }
  37.   } 
 Any idea what I'm doing wrong?

Thanks!

Replies(2)

I have exactly the same problem with text on P2D, P3D and OPENGL. it looks blurry and not even perfectly aligned. 

I believe the new OpenGL renders display text from a pre-rendered texture. To have good quality text, you need to create the font at the exact textsize you will display it. If you display at multiple sizes, you need to create fonts at multiple sizes.