This class encapsulates a GLSL shader program, including a vertex and a fragment shader. Based on the GLSLShader class from GLGraphics, which in turn was originally based in the code by JohnG: http://processing.org/discourse/beta/num_1159494801.html @webref rendering:shaders
| 41 | * @webref rendering:shaders |
| 42 | */ |
| 43 | public class PShader implements PConstants { |
| 44 | static protected final int POINT = 0; |
| 45 | static protected final int LINE = 1; |
| 46 | static protected final int POLY = 2; |
| 47 | static protected final int COLOR = 3; |
| 48 | static protected final int LIGHT = 4; |
| 49 | static protected final int TEXTURE = 5; |
| 50 | static protected final int TEXLIGHT = 6; |
| 51 | |
| 52 | static protected String pointShaderAttrRegexp = |
| 53 | "attribute *vec2 *offset"; |
| 54 | static protected String pointShaderInRegexp = |
| 55 | "in *vec2 *offset;"; |
| 56 | static protected String lineShaderAttrRegexp = |
| 57 | "attribute *vec4 *direction"; |
| 58 | static protected String lineShaderInRegexp = |
| 59 | "in *vec4 *direction"; |
| 60 | static protected String pointShaderDefRegexp = |
| 61 | "#define *PROCESSING_POINT_SHADER"; |
| 62 | static protected String lineShaderDefRegexp = |
| 63 | "#define *PROCESSING_LINE_SHADER"; |
| 64 | static protected String colorShaderDefRegexp = |
| 65 | "#define *PROCESSING_COLOR_SHADER"; |
| 66 | static protected String lightShaderDefRegexp = |
| 67 | "#define *PROCESSING_LIGHT_SHADER"; |
| 68 | static protected String texShaderDefRegexp = |
| 69 | "#define *PROCESSING_TEXTURE_SHADER"; |
| 70 | static protected String texlightShaderDefRegexp = |
| 71 | "#define *PROCESSING_TEXLIGHT_SHADER"; |
| 72 | static protected String polyShaderDefRegexp = |
| 73 | "#define *PROCESSING_POLYGON_SHADER"; |
| 74 | static protected String triShaderAttrRegexp = |
| 75 | "#define *PROCESSING_TRIANGLES_SHADER"; |
| 76 | static protected String quadShaderAttrRegexp = |
| 77 | "#define *PROCESSING_QUADS_SHADER"; |
| 78 | |
| 79 | protected PApplet parent; |
| 80 | // The main renderer associated to the parent PApplet. |
| 81 | //protected PGraphicsOpenGL pgMain; |
| 82 | // We need a reference to the renderer since a shader might |
| 83 | // be called by different renderers within a single application |
| 84 | // (the one corresponding to the main surface, or other offscreen |
| 85 | // renderers). |
| 86 | protected PGraphicsOpenGL primaryPG; |
| 87 | protected PGraphicsOpenGL currentPG; |
| 88 | protected PGL pgl; |
| 89 | protected int context; // The context that created this shader. |
| 90 | |
| 91 | // The shader type: POINT, LINE, POLY, etc. |
| 92 | protected int type; |
| 93 | |
| 94 | public int glProgram; |
| 95 | public int glVertex; |
| 96 | public int glFragment; |
| 97 | private GLResourceShader glres; |
| 98 | |
| 99 | protected URL vertexURL; |
| 100 | protected URL fragmentURL; |
nothing calls this directly
no outgoing calls
no test coverage detected