-
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e43607
commit cac5c64
Showing
8 changed files
with
123 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifdef GL_ES | ||
precision mediump float; | ||
precision mediump int; | ||
#endif | ||
|
||
varying vec4 vertColor; | ||
|
||
void main() { | ||
gl_FragColor = vertColor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
uniform mat4 transform; | ||
|
||
attribute vec3 position; | ||
attribute vec4 color; | ||
|
||
varying vec4 vertColor; | ||
|
||
void main() { | ||
gl_Position = transform * vec4(position, 1); | ||
|
||
//we avoid affecting the Z component by the transform | ||
//because it would mess up our depth testing | ||
gl_Position.z = position.z; | ||
|
||
vertColor = color.zyxw; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
debug/apps/fast2d/src/main/java/fast2d/SketchShaderNoTex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fast2d; | ||
|
||
import processing.core.PApplet; | ||
import processing.opengl.PShader; | ||
|
||
public class SketchShaderNoTex extends PApplet { | ||
PShader sh; | ||
|
||
public void settings() { | ||
// fullScreen(P2D); | ||
fullScreen(P2DX); | ||
} | ||
|
||
public void setup() { | ||
orientation(LANDSCAPE); | ||
sh = loadShader("frag.glsl", "vert.glsl"); | ||
shader(sh); | ||
} | ||
|
||
public void draw() { | ||
translate(mouseX, mouseY); | ||
rect(0, 0, 400, 400); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
int join = MITER; | ||
int cap = SQUARE; | ||
|
||
boolean premultiply = true; | ||
|
||
float dev = 10; //deviation | ||
|
||
//change these parameters to benchmark various things | ||
int unit = 10; | ||
//line, triangle, rect, ellipse, point | ||
int[] amount = { 20, 15, 10, 5, 40 }; | ||
|
||
void setup() { | ||
fullScreen(P2DX); | ||
strokeCap(cap); | ||
strokeJoin(join); | ||
PGraphics2DX.premultiplyMatrices = premultiply; | ||
|
||
textFont(createFont("SansSerif", 15 * displayDensity)); | ||
} | ||
|
||
public void draw() { | ||
background(255); | ||
|
||
strokeWeight(2 * displayDensity); | ||
stroke(0); | ||
fill(200); | ||
|
||
for (int i = 0; i < amount[0]*unit; ++i) { | ||
float x = random(width); | ||
float y = random(height); | ||
line(x, y, x + random(-dev, dev), y + random(-dev, dev)); | ||
} | ||
|
||
for (int i = 0; i < amount[1]*unit; ++i) { | ||
float x = random(width); | ||
float y = random(height); | ||
triangle(x, y, | ||
x + random(-dev*2, dev*2), y + random(-dev*2, dev*2), | ||
x + random(-dev*2, dev*2), y + random(-dev*2, dev*2)); | ||
} | ||
|
||
for (int i = 0; i < amount[2]*unit; ++i) { | ||
rect(random(width), random(height), random(dev), random(dev)); | ||
} | ||
|
||
for (int i = 0; i < amount[3]*unit; ++i) { | ||
ellipse(random(width), random(height), random(dev*2), random(dev*2)); | ||
} | ||
|
||
for (int i = 0; i < amount[4]*unit; ++i) { | ||
point(random(width), random(height)); | ||
} | ||
|
||
//large ellipse to test smoothness of outline | ||
ellipse(width/2, height/2, width/2, height/4); | ||
|
||
fill(255, 0, 0); | ||
text((int) frameRate + " fps", 30, 30); | ||
} |