Open main menu

CDOT Wiki β

Changes

FSOSS 2010/processing.js/texture1

158 bytes added, 13:08, 27 October 2010
no edit summary
*/
import processing.opengl.*;
/* @pjs preload="crate1.jpg; */
 
PImage crate;
/* @pjs preload="processing.png"; */
PImage crateImage;
void setup()
{
size(400, 400, OPENGL);
crate crateImage = loadImage("crate1processing.jpgpng");
textureMode(NORMALIZED);
}
void drawBox(PImage img){
background(200);
 
void drawBox(PImage i){
beginShape(QUADS);
texture(iimg);
// -Z "back" face
vertex( 1, -1, -1, 0, 0);
vertex(-1, 1, -1, 1, 1);
vertex( 1, 1, -1, 0, 1);
vertex(-1, -1, 1, 0, 0);
vertex( 1, -1, 1, 1, 0);
vertex( 1, 1, 1, 1, 1);
vertex(-1, 1, 1, 0, 1);
// +Y "bottom" face
vertex(-1, 1, 1, 0, 0);
vertex( 1, 1, -1, 1, 1);
vertex(-1, 1, -1, 0, 1);
// -Y "top" face
vertex(-1, -1, -1, 0, 0);
vertex( 1, -1, 1, 1, 1);
vertex(-1, -1, 1, 0, 1);
// +X "right" face
vertex( 1, -1, 1, 0, 0);
vertex( 1, 1, -1, 1, 1);
vertex( 1, 1, 1, 0, 1);
// -X "left" face
vertex(-1, -1, -1, 0, 0);
vertex(-1, 1, 1, 1, 1);
vertex(-1, 1, -1, 0, 1);
endShape();
}
void draw()
{
background(0);
stroke(255);
// center in the canvas
rotateY(radians(45));
rotateX( frameCount/250.0f );
scale(50);
drawBox(cratecrateImage);
}
</source>
[http://matrix.senecac.on.ca/~asalga/pjswebide/index.php?sketchID=34 Run me]
1
edit