Open main menu

CDOT Wiki β

Changes

FSOSS 2010/processing.js/texture1

366 bytes added, 14:56, 27 October 2010
no edit summary
FSOSS 2010
Andor Salga
Example of texture
*/
import processing.opengl.*;
// Preload the image using a Pjs directive
/* @pjs preload="processing.png"; */
PImage crateImage;
size(400, 400, OPENGL);
crateImage = loadImage("processing.png");
 
// We're going to specify our texture coordinates using
// normalized values (0..1) rather than image coordinates
textureMode(NORMALIZED);
}
/* Draw a box using a specific Pimage*/
void drawBox(PImage img){
background(200);
vertex( 1, 1, -1, 0, 1);
// +Z "front" face
vertex(-1, -1, 1, 0, 0);
vertex( 1, -1, 1, 1, 0);
endShape();
}
void draw()
stroke(255);
// center in the canvas, bring towards the camera
translate(width/2, height/2, 150);
// convert 45 degrees into radians and
// rotate by that amount
rotateY(radians(45));
rotateX( frameCount/250.0f );
// make the box a bit larger
scale(50);
1
edit