P2D/OPENGL text rendering in 2.0b8
in
Programming Questions
•
5 months ago
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).
- PShape aShape;
- PFont font;
- void setup() {
- size(500,500,OPENGL); //<-- changed from size(500,500)
- smooth();
- font = createFont("serif",20,true);
- // First create the shape
- aShape = createShape();
- //aShape = new PShape(3); //<-- need this if you're using default renderer or it'll throw an error
- aShape.beginShape(); //<-- added this in
- // You can set fill and stroke
- aShape.fill(102); //<-- moved from before 'aShape = createShape()'
- aShape.stroke(255); //<-- moved from before 'aShape = createShape()'
- aShape.strokeWeight(2); //<-- moved from before 'aShape = createShape()'
- // Here, we are hardcoding a series of vertices
- aShape.vertex(0, 0);
- aShape.vertex(100,0);
- aShape.vertex(100,100);
- aShape.vertex(0,100);
- // We are done with the shape
- aShape.endShape(CLOSE); //<-- changed from aShape.end();
- }
- void draw() {
- background(255);
- // draw the shape.
- shape(aShape,mouseX,mouseY); // <-- doesn't appear if I use default renderer
- // write some text
- fill(0); textAlign(CENTER,CENTER);
- int i=-1; while(++i<10){
- textSize(15+i);
- text("bigger",width/2,23*i+20);
- }
- }
Any idea what I'm doing wrong?
Thanks!
1