|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neovisionaries.android.opengl.Shader<TShader>
public abstract class Shader<TShader extends Shader<TShader>>
OpenGL ES shader.
// E X A M P L E 1 // Create a shader.Shader
shader = newVertexShader
(); //Shader shader = newFragmentShader
(); // Set a shader source code. String shaderSource = "..."; shader.setSource
(shaderSource); // Compile the shader source code. shader.compile
();
// E X A M P L E 2 // Just one line.Shader
shader = newVertexShader
("...").compile
();
Program
Constructor Summary | |
---|---|
protected |
Shader(ShaderType type)
A constructor with a shader type. |
protected |
Shader(ShaderType type,
File file)
A constructor with a shader type and a shader source file. |
protected |
Shader(ShaderType type,
InputStream in)
This constructor is an alias of Shader (type, in, false). |
protected |
Shader(ShaderType type,
InputStream in,
boolean close)
A constructor with a shader type and an input stream from which a shader source should be read. |
protected |
Shader(ShaderType type,
String source)
A constructor with a shader type and a shader source. |
Method Summary | |
---|---|
TShader |
compile()
Compile the source code given by setSource(String) . |
TShader |
delete()
Delete this shader. |
int |
getId()
Get the shader ID which is a return value from glCreateShader(). |
ShaderState |
getState()
Get the state of this shader. |
boolean |
isAutoDeleted()
Check if auto-deletion is enabled. |
static void |
releaseCompiler()
Tell the GLES implementation that resources used by the shader compiler can be released. |
TShader |
setAutoDeleted(boolean autoDeleted)
Enable/disable auto-deletion. |
TShader |
setSource(File file)
Set a shader source code. |
TShader |
setSource(String source)
Set a shader source code. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Shader(ShaderType type) throws GLESException
ShaderState.CREATED
.
type
- ShaderType.VERTEX
or ShaderType.FRAGMENT
.
IllegalArgumentException
- The given argument is null.
GLESException
- glCreateShader() failed.VertexShader.VertexShader()
,
FragmentShader.FragmentShader()
,
glCreateShaderprotected Shader(ShaderType type, String source) throws GLESException
ShaderState.SOURCE_SET
.
type
- ShaderType.VERTEX
or ShaderType.FRAGMENT
.source
- A shader source code.
IllegalArgumentException
- Either or both of the arguments are null.
GLESException
- glCreateShader() failed.VertexShader.VertexShader(String)
,
FragmentShader.FragmentShader(String)
,
glCreateShader,
glShaderSourceprotected Shader(ShaderType type, File file) throws IOException, GLESException
ShaderState.SOURCE_SET
.
type
- ShaderType.VERTEX
or ShaderType.FRAGMENT
.file
- A file whose content is a shader source code.
IllegalArgumentException
- Either or both of the arguments are null.
IOException
- Failed to read the content of the given file.
GLESException
- glCreateShader() failed.VertexShader.VertexShader(File)
,
FragmentShader.FragmentShader(File)
,
glCreateShader,
glShaderSourceprotected Shader(ShaderType type, InputStream in) throws IOException, GLESException
Shader
(type, in, false).
IOException
GLESException
Shader(ShaderType, InputStream, boolean)
,
VertexShader.VertexShader(InputStream)
,
FragmentShader.FragmentShader(InputStream)
,
glCreateShader,
glShaderSourceprotected Shader(ShaderType type, InputStream in, boolean close) throws IOException, GLESException
ShaderState.SOURCE_SET
.
type
- ShaderType.VERTEX
or ShaderType.FRAGMENT
.in
- An input stream that feeds a shader source code.close
- If true is given, the input stream is closed before
this method returns.
IllegalArgumentException
- 'type' is null or 'in' is null.
IOException
- Failed to read the content of the input stream.
GLESException
- glCreateShader() failed.VertexShader.VertexShader(InputStream, boolean)
,
FragmentShader.FragmentShader(InputStream, boolean)
,
glCreateShader,
glShaderSourceMethod Detail |
---|
public int getId()
public ShaderState getState()
public TShader delete()
ShaderState.DELETED
.
Note that calling this method detaches this shader from all the programs that this shader is currently attached to.
If auto-deletion is enabled by setAutoDeleted
(true), this method is automatically called
when this instance is detached from the last program that
this instance is attached to.
setAutoDeleted(boolean)
public boolean isAutoDeleted()
public TShader setAutoDeleted(boolean autoDeleted)
If 'true' is given to this method, auto-deletion is enabled,
meaning that delete()
is called automatically when
this instance is detached from the last program that this
instance was attached to.
autoDeleted
- True to enable auto-deletion. False to disable it.
public TShader setSource(String source)
ShaderState.SOURCE_SET
.
source
- A shader source code.
IllegalArgumentException
- The given argument is null.
IllegalStateException
- This shader has already been deleted.public TShader setSource(File file) throws IOException
ShaderState.SOURCE_SET
.
file
- A file that contains a shader source code.
IllegalArgumentException
- The given argument is null.
IllegalStateException
- This shader has already been deleted.
IOException
- Failed to read the given file.public TShader compile() throws GLESException
setSource(String)
.
If the current state of this shader is COMPILED
, nothing is executed.
If this method returns without any exception, the state of
this instance is ShaderState.COMPILED
.
IllegalStateException
- No shader source is set, or this shader has already
been deleted.
GLESException
- glCompileShader() failed.public static void releaseCompiler()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |