Using texture() in combination with JBox2D
- by Valentino Ru
I'm getting some trouble using the texture() method inside beginShape()/endShape() clause.
In the display()-method of my class TowerElement (a bar which is DYNAMIC), I draw the object like following:
void display(){
Vec2 pos = level.getLevel().getBodyPixelCoord(body);
float a = body.getAngle(); // needed for rotation
pushMatrix();
translate(pos.x, pos.y);
rotate(-a);
fill(temp); // temp is a color defined in the constructor
stroke(0);
beginShape();
vertex(-w/2,-h/2);
vertex(w/2,-h/2);
vertex(w/2,h-h/2);
vertex(-w/2,h-h/2);
endShape(CLOSE);
popMatrix();
}
Now, according to the API, I can use the texture() method inside the shape definition. Now when I remove the fill(temp) and put texture(img) (img is a PImage defined in the constructor), the stroke gets drawn, but the bar isn't filled and I get the warning
texture() is not available with this renderer
What can I do in order to use textures anyway? I don't even understand the error message, since I do not know much about different renderers.