Usage example:
String source =
"uniform sampler2D myTex;" +
"void main(void)" +
"{" +
" vec4 src = texture2D(myTex, gl_TexCoord[0].st);" +
" gl_FragColor = src.bgra;" + // swizzle!
"}";
ES2Shader shader = new ES2Shader(source);
shader.setConstant("myTex", 0); // myTex will be on texture unit 0
...
shader.enable();
texture.enable();
texture.bind();
...
texture.disable();
shader.disable();
};
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ES2Context | |
| private float[] | |
| private final boolean | |
| private final int | |
| private int | programID
The handle to the OpenGL shader program object. |
| private final Map | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| private | ES2Shader(ES2Context context, int programID, int vertexShaderID, int[] fragmentShaderID, Map<String, Integer> samplers, int maxTexCoordIndex, boolean isPixcoordUsed)
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static ES2Shader | createFromSource(ES2Context context, String vert, String[] frag, Map<String, Integer> samplers, Map<String, Integer> attributes, int maxTexCoordIndex, boolean isPixcoordUsed)
|
| pack-priv static ES2Shader | createFromSource(ES2Context context, String vert, InputStream frag, Map<String, Integer> samplers, Map<String, Integer> attributes, int maxTexCoordIndex, boolean isPixcoordUsed)
|
| public void | disable()
Implements com. Disables this shader program in the current GL context's state. |
| public void | dispose()
Implements abstract com. Implements com. Disposes the native resources used by this program object. |
| public void | enable()
Implements com. Enables this shader program in the current GL context's state. |
| public int | Returns: the maximum texcoord index referenced by this shader programReturns the maximum texcoord index referenced by this shader program. |
| public int | Returns: the OpenGL program object handle for this fragment shaderReturns the underlying OpenGL program object handle for this fragment shader. |
| private ES2Shader. | |
| public boolean | Returns: true if this shader uses the special pixcoord variableReturns true if this shader uses the special pixcoord variable, otherwise returns false |
| public boolean | isValid()
Implements com. Returns whether this shader is valid and can be used for rendering. |
| pack-priv static String | |
| public void | setConstant(String
the name of the uniform variable to be set name, int the first uniform parameter i0)Implements com. Sets the uniform variable of the given name with the provided integer value. |
| public void | setConstant(String
the name of the uniform variable to be set name, int the first uniform parameter i0, int the second uniform parameter i1)Implements com. Sets the uniform variable of the given name with the provided integer values. |
| public void | setConstant(String
the name of the uniform variable to be set name, int the first uniform parameter i0, int the second uniform parameter i1, int the third uniform parameter i2)Implements com. Sets the uniform variable of the given name with the provided integer values. |
| public void | setConstant(String
the name of the uniform variable to be set name, int the first uniform parameter i0, int the second uniform parameter i1, int the third uniform parameter i2, int the fourth uniform parameter i3)Implements com. Sets the uniform variable of the given name with the provided integer values. |
| public void | setConstant(String
the name of the uniform variable to be set name, float the first uniform parameter f0)Implements com. Sets the uniform variable of the given name with the provided float value. |
| public void | setConstant(String
the name of the uniform variable to be set name, float the first uniform parameter f0, float the second uniform parameter f1)Implements com. Sets the uniform variable of the given name with the provided float values. |
| public void | setConstant(String
the name of the uniform variable to be set name, float the first uniform parameter f0, float the second uniform parameter f1, float the third uniform parameter f2)Implements com. Sets the uniform variable of the given name with the provided float values. |
| public void | setConstant(String
the name of the uniform variable to be set name, float the first uniform parameter f0, float the second uniform parameter f1, float the third uniform parameter f2, float the fourth uniform parameter f3)Implements com. Sets the uniform variable of the given name with the provided float values. |
| public void | setConstants(String
the name of the uniform variable to be set name, IntBuffer the array values to be set buf, int the offset into the vals array off, int the number of ivec4 elements in the array count)Implements com. Sets the uniform array variable of the given name with the provided int array values. |
| public void | setConstants(String
the name of the uniform variable to be set name, FloatBuffer the array values to be set buf, int the offset into the vals array off, int the number of vec4 elements in the array count)Implements com. Sets the uniform array variable of the given name with the provided float array values. |
| public void |
| context | back to summary |
|---|---|
| private final ES2Context context | |
| currentMatrix | back to summary |
|---|---|
| private float[] currentMatrix | |
| isPixcoordUsed | back to summary |
|---|---|
| private final boolean isPixcoordUsed | |
| maxTexCoordIndex | back to summary |
|---|---|
| private final int maxTexCoordIndex | |
| programID | back to summary |
|---|---|
| private int programID The handle to the OpenGL shader program object. | |
| uniforms | back to summary |
|---|---|
| private final Map<String, ES2Shader. | |
| valid | back to summary |
|---|---|
| private boolean valid | |
| ES2Shader | back to summary |
|---|---|
| private ES2Shader(ES2Context context, int programID, int vertexShaderID, int[] fragmentShaderID, Map<String, Integer> samplers, int maxTexCoordIndex, boolean isPixcoordUsed) throws RuntimeException | |
| createFromSource | back to summary |
|---|---|
| pack-priv static ES2Shader createFromSource(ES2Context context, String vert, String[] frag, Map<String, Integer> samplers, Map<String, Integer> attributes, int maxTexCoordIndex, boolean isPixcoordUsed) | |
| createFromSource | back to summary |
|---|---|
| pack-priv static ES2Shader createFromSource(ES2Context context, String vert, InputStream frag, Map<String, Integer> samplers, Map<String, Integer> attributes, int maxTexCoordIndex, boolean isPixcoordUsed) | |
| disable | back to summary |
|---|---|
| public void disable() throws RuntimeException Implements com. Disables this shader program in the current GL context's state.
| |
| dispose | back to summary |
|---|---|
| public void dispose() throws RuntimeException Implements abstract com. Implements com. Disposes the native resources used by this program object.
| |
| enable | back to summary |
|---|---|
| public void enable() throws RuntimeException Implements com. Enables this shader program in the current GL context's state.
| |
| getMaxTexCoordIndex | back to summary |
|---|---|
| public int getMaxTexCoordIndex() Returns the maximum texcoord index referenced by this shader program.
| |
| getProgramObject | back to summary |
|---|---|
| public int getProgramObject() Returns the underlying OpenGL program object handle for this fragment shader. Most applications will not need to access this, since it is handled automatically by the enable() and dispose() methods.
| |
| getUniform | back to summary |
|---|---|
| private ES2Shader. | |
| isPixcoordUsed | back to summary |
|---|---|
| public boolean isPixcoordUsed() Returns true if this shader uses the special pixcoord variable, otherwise returns false
| |
| isValid | back to summary |
|---|---|
| public boolean isValid() Implements com. Doc from com. Returns whether this shader is valid and can be used for rendering. Called on the rendering thread.
| |
| readStreamIntoString | back to summary |
|---|---|
| pack-priv static String readStreamIntoString(InputStream in) | |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, int i0) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided integer value.
| |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, int i0, int i1) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided integer values.
| |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, int i0, int i1, int i2) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided integer values.
| |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, int i0, int i1, int i2, int i3) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided integer values.
| |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, float f0) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided float value.
| |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, float f0, float f1) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided float values.
| |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, float f0, float f1, float f2) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided float values.
| |
| setConstant | back to summary |
|---|---|
| public void setConstant(String name, float f0, float f1, float f2, float f3) throws RuntimeException Implements com. Sets the uniform variable of the given name with the provided float values.
| |
| setConstants | back to summary |
|---|---|
| public void setConstants(String name, IntBuffer buf, int off, int count) throws RuntimeException Implements com. Sets the uniform array variable of the given name with the provided int array values.
| |
| setConstants | back to summary |
|---|---|
| public void setConstants(String name, FloatBuffer buf, int off, int count) throws RuntimeException Implements com. Sets the uniform array variable of the given name with the provided float array values.
| |
| setMatrix | back to summary |
|---|---|
| public void setMatrix(String name, float[] buf) throws RuntimeException Sets the uniform matrix variable of the given name with the provided float array values.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ES2Context | |
| private int[] | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| private | ES2ShaderDisposerRecord(ES2Context context, int vertexShaderID, int[] fragmentShaderID, int programID)
|
| Modifier and Type | Method and Description |
|---|---|
| public void |
| context | back to summary |
|---|---|
| private final ES2Context context | |
| fragmentShaderID | back to summary |
|---|---|
| private int[] fragmentShaderID | |
| programID | back to summary |
|---|---|
| private int programID | |
| vertexShaderID | back to summary |
|---|---|
| private int vertexShaderID | |
| ES2ShaderDisposerRecord | back to summary |
|---|---|
| private ES2ShaderDisposerRecord(ES2Context context, int vertexShaderID, int[] fragmentShaderID, int programID) | |
| dispose | back to summary |
|---|---|
| public void dispose() Implements com.
| |
| Access | Constructor and Description |
|---|---|
| private |
| location | back to summary |
|---|---|
| private int location | |
| values | back to summary |
|---|---|
| private Object values | |
| Uniform | back to summary |
|---|---|
| private Uniform() | |