public class PShader extends java.lang.Object implements PConstants
Modifier and Type | Field and Description |
---|---|
int |
glFragment |
int |
glProgram |
int |
glVertex |
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
Constructor and Description |
---|
PShader() |
PShader(PApplet parent) |
PShader(PApplet parent,
java.lang.String[] vertSource,
java.lang.String[] fragSource) |
PShader(PApplet parent,
java.lang.String vertFilename,
java.lang.String fragFilename)
Creates a shader program using the specified vertex and fragment
shaders.
|
PShader(PApplet parent,
java.net.URL vertURL,
java.net.URL fragURL) |
Modifier and Type | Method and Description |
---|---|
void |
bind()
Initializes (if needed) and binds the shader program.
|
boolean |
bound()
Returns true if the shader is bound, false otherwise.
|
void |
init() |
void |
set(java.lang.String name,
boolean x) |
void |
set(java.lang.String name,
boolean[] vec) |
void |
set(java.lang.String name,
boolean[] boolvec,
int ncoords) |
void |
set(java.lang.String name,
boolean x,
boolean y) |
void |
set(java.lang.String name,
boolean x,
boolean y,
boolean z) |
void |
set(java.lang.String name,
boolean x,
boolean y,
boolean z,
boolean w) |
void |
set(java.lang.String name,
float x) |
void |
set(java.lang.String name,
float[] vec) |
void |
set(java.lang.String name,
float[] vec,
int ncoords) |
void |
set(java.lang.String name,
float x,
float y) |
void |
set(java.lang.String name,
float x,
float y,
float z) |
void |
set(java.lang.String name,
float x,
float y,
float z,
float w) |
void |
set(java.lang.String name,
int x) |
void |
set(java.lang.String name,
int[] vec) |
void |
set(java.lang.String name,
int[] vec,
int ncoords) |
void |
set(java.lang.String name,
int x,
int y) |
void |
set(java.lang.String name,
int x,
int y,
int z) |
void |
set(java.lang.String name,
int x,
int y,
int z,
int w) |
void |
set(java.lang.String name,
PImage tex) |
void |
set(java.lang.String name,
PMatrix2D mat) |
void |
set(java.lang.String name,
PMatrix3D mat) |
void |
set(java.lang.String name,
PMatrix3D mat,
boolean use3x3) |
void |
set(java.lang.String name,
PVector vec) |
void |
setFragmentShader(java.lang.String fragFilename) |
void |
setFragmentShader(java.lang.String[] fragSource) |
void |
setFragmentShader(java.net.URL fragURL) |
void |
setVertexShader(java.lang.String vertFilename) |
void |
setVertexShader(java.lang.String[] vertSource) |
void |
setVertexShader(java.net.URL vertURL) |
void |
unbind()
Unbinds the shader program.
|
public int glProgram
public int glVertex
public int glFragment
public PShader()
public PShader(PApplet parent)
public PShader(PApplet parent, java.lang.String vertFilename, java.lang.String fragFilename)
parent
- the parent programvertFilename
- name of the vertex shaderfragFilename
- name of the fragment shaderpublic PShader(PApplet parent, java.net.URL vertURL, java.net.URL fragURL)
vertURL
- network location of the vertex shaderfragURL
- network location of the fragment shaderpublic PShader(PApplet parent, java.lang.String[] vertSource, java.lang.String[] fragSource)
public void setVertexShader(java.lang.String vertFilename)
public void setVertexShader(java.net.URL vertURL)
public void setVertexShader(java.lang.String[] vertSource)
public void setFragmentShader(java.lang.String fragFilename)
public void setFragmentShader(java.net.URL fragURL)
public void setFragmentShader(java.lang.String[] fragSource)
public void bind()
public void unbind()
public boolean bound()
public void set(java.lang.String name, int x)
name
- the name of the uniform variable to modifyx
- first component of the variable to modifypublic void set(java.lang.String name, int x, int y)
y
- second component of the variable to modify. The variable has to be declared with an array/vector type in the shader (i.e.: int[2], vec2)public void set(java.lang.String name, int x, int y, int z)
z
- third component of the variable to modify. The variable has to be declared with an array/vector type in the shader (i.e.: int[3], vec3)public void set(java.lang.String name, int x, int y, int z, int w)
w
- fourth component of the variable to modify. The variable has to be declared with an array/vector type in the shader (i.e.: int[4], vec4)public void set(java.lang.String name, float x)
public void set(java.lang.String name, float x, float y)
public void set(java.lang.String name, float x, float y, float z)
public void set(java.lang.String name, float x, float y, float z, float w)
public void set(java.lang.String name, PVector vec)
vec
- modifies all the components of an array/vector uniform variable. PVector can only be used if the type of the variable is vec3.public void set(java.lang.String name, boolean x)
public void set(java.lang.String name, boolean x, boolean y)
public void set(java.lang.String name, boolean x, boolean y, boolean z)
public void set(java.lang.String name, boolean x, boolean y, boolean z, boolean w)
public void set(java.lang.String name, int[] vec)
public void set(java.lang.String name, int[] vec, int ncoords)
ncoords
- number of coordinates per element, max 4public void set(java.lang.String name, float[] vec)
public void set(java.lang.String name, float[] vec, int ncoords)
public void set(java.lang.String name, boolean[] vec)
public void set(java.lang.String name, boolean[] boolvec, int ncoords)
public void set(java.lang.String name, PMatrix2D mat)
mat
- matrix of valuespublic void set(java.lang.String name, PMatrix3D mat)
public void set(java.lang.String name, PMatrix3D mat, boolean use3x3)
use3x3
- enforces the matrix is 3 x 3public void set(java.lang.String name, PImage tex)
tex
- sets the sampler uniform variable to read from this image texturepublic void init()