MCPcopy Index your code
hub / github.com/benfry/processing4 / PShader

Class PShader

core/src/processing/opengl/PShader.java:49–1477  ·  view source on GitHub ↗

This class encapsulates a GLSL shader program, including a vertex and a fragment shader. It is compatible with P2D and P3D, but not with the default renderer. Use the loadShader() function to load your shader code. Note: It's strongly encouraged to use loadShader() to create a PSha

Source from the content-addressed store, hash-verified

47 * including a vertex and a fragment shader
48 */
49public class PShader implements PConstants {
50 static protected final int POINT = 0;
51 static protected final int LINE = 1;
52 static protected final int POLY = 2;
53 static protected final int COLOR = 3;
54 static protected final int LIGHT = 4;
55 static protected final int TEXTURE = 5;
56 static protected final int TEXLIGHT = 6;
57
58 static protected String pointShaderAttrRegexp =
59 "attribute *vec2 *offset";
60 static protected String pointShaderInRegexp =
61 "in *vec2 *offset;";
62 static protected String lineShaderAttrRegexp =
63 "attribute *vec4 *direction";
64 static protected String lineShaderInRegexp =
65 "in *vec4 *direction";
66 static protected String pointShaderDefRegexp =
67 "#define *PROCESSING_POINT_SHADER";
68 static protected String lineShaderDefRegexp =
69 "#define *PROCESSING_LINE_SHADER";
70 static protected String colorShaderDefRegexp =
71 "#define *PROCESSING_COLOR_SHADER";
72 static protected String lightShaderDefRegexp =
73 "#define *PROCESSING_LIGHT_SHADER";
74 static protected String texShaderDefRegexp =
75 "#define *PROCESSING_TEXTURE_SHADER";
76 static protected String texlightShaderDefRegexp =
77 "#define *PROCESSING_TEXLIGHT_SHADER";
78 static protected String polyShaderDefRegexp =
79 "#define *PROCESSING_POLYGON_SHADER";
80 static protected String triShaderAttrRegexp =
81 "#define *PROCESSING_TRIANGLES_SHADER";
82 static protected String quadShaderAttrRegexp =
83 "#define *PROCESSING_QUADS_SHADER";
84
85 protected PApplet parent;
86 // The main renderer associated to the parent PApplet.
87 //protected PGraphicsOpenGL pgMain;
88 // We need a reference to the renderer since a shader might
89 // be called by different renderers within a single application
90 // (the one corresponding to the main surface, or other offscreen
91 // renderers).
92 protected PGraphicsOpenGL primaryPG;
93 protected PGraphicsOpenGL currentPG;
94 protected PGL pgl;
95 protected int context; // The context that created this shader.
96
97 // The shader type: POINT, LINE, POLY, etc.
98 protected int type;
99
100 public int glProgram;
101 public int glVertex;
102 public int glFragment;
103 private GLResourceShader glres;
104
105 protected URL vertexURL;
106 protected URL fragmentURL;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected