Hi,
I'm actuallly learning how 2D textures works within P3D.
I've tried something really simple, create a texture and map over a square. The result is kinda weird, got some perspective distortion.
After read a bit of opengl tutorials, this doesn't seems to be that weird.
I think i've to use glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST) in opengl to get ride of it but what for P3D ?
Does Processing have any core functions to handle that ?
Here's the source code:
Quote:PGraphics b;
int l = 24;
void setup()
{
size(200, 200, P3D);
b = createGraphics(l*2, l*2, P3D);
textureMode(NORMALIZED);
}
void draw()
{
//generate the texture
b.beginDraw();
b.noStroke();
b.fill(0);
b.rect(0, 0, l, l);
b.rect(l, l, l, l);
b.fill(255);
b.rect(l, 0, l, l);
b.rect(0, l, l, l);
b.endDraw();
//basic tranformations
pushMatrix();
translate(width/2, height/2);
rotateX(-PI/4);
rotateY(-PI/4);
beginShape(QUADS);
texture(b);
vertex(l, -l, -l, 0, 0);
vertex(-l, -l, -l, 0, 1);
vertex(-l, -l, l, 1, 1);
vertex(l, -l, l, 1, 0);
endShape();
popMatrix();
image(b, 0 ,0);
}