Skip to content

Instantly share code, notes, and snippets.

@studioijeoma
Created August 29, 2011 22:00
Show Gist options
  • Save studioijeoma/1179525 to your computer and use it in GitHub Desktop.
Save studioijeoma/1179525 to your computer and use it in GitHub Desktop.
PJS OPENGL PGraphics Test
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cube vs Pyramid Lighting Test</title>
<script type="text/javascript" src="http://processingjs.org/content/download/processing-js-1.3.0/processing-1.3.0.js"></script>
</head>
<body>
<canvas id="pjsCanvas"></canvas>
<script type="text/javascript">
(function() {
var canvas = document.getElementById('pjsCanvas');
var pjs = new Processing(canvas);
var pg;
pjs.setup = function() {
this.size(200, 200, this.OPENGL);
this.loop();
pg = this.createGraphics(80, 80, this.P3D);
}
pjs.draw = function() {
this.background(0);
this.lights();
this.noStroke();
this.fill(255);
this.translate(this.mouseX, this.mouseY);
this.rotateX(this.radians(this.mouseY));
this.rotateY(this.radians(this.mouseX));
this.box(60);
pg.beginDraw();
pg.background(255);
pg.stroke(255);
pg.noFill();
pg.translate(this.mouseX, this.mouseY);
pg.rotateX(this.radians(this.mouseY));
pg.rotateY(this.radians(this.mouseX));
pg.endDraw();
this.image(pg, 60, 60);
}
pjs.setup();
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment