|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.neovisionaries.android.opengl.Program
public class Program
OpenGL ES shader program.
// E X A M P L E 1 // Create a program.Program
program = newProgram
(); // Attach a vertex shader.VertexShader
vShader = newVertexShader
("...").compile
(); program.attach
(vShader); // Attach a fragment shader.FragmentShader
fShader = newFragmentShader
("...").compile
(); program.attach
(fShader); // Link the shaders. program.link
(); // Use the program. program.use
(); // Delete the program. program.delete
(); // Delete the shaders. vShader.delete
(); fShader.delete
();
// E X A M P L E 2 // Create a program with shaders.Program
program = newProgram
( newVertexShader
("...").setAutoDeleted
(true), newFragmentShader
("...").setAutoDeleted
(true) ); // Use the program. Compiling and linking are performed // automatically because use() calls link() if not linked // yet and link() calls compile() of shaders if they are // not compiled yet. program.use
(); // Delete the program. Shaders are deleted automatically // because setAutoDeleted(true) of them has been called. program.delete
();
Shader
,
Attribute
,
Uniform
Constructor Summary | |
---|---|
Program(Shader<?>... shaders)
A constructor. |
Method Summary | |
---|---|
Program |
attach(Shader<?> shader)
Attach a shader to this program. |
void |
delete()
Delete this program. |
Program |
detach(Shader<?> shader)
Detach a shader from this program. |
Attribute |
getAttribute(String attributeName)
Get an attribute. |
int |
getId()
Get the program ID which is a return value from glCreateProgram(). |
Sampler |
getSampler(String name)
Get a Sampler object. |
ProgramState |
getState()
Get the state of this program. |
Uniform |
getUniform(String name)
Get a Uniform object. |
Program |
link()
Link attached shaders. |
Program |
setAttribute(String attributeName,
Attribute attribute)
Set an attribute. |
static void |
unuse()
Call glUseProgram(0). |
Program |
use()
Use this program. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Program(Shader<?>... shaders) throws GLESException
NEEDS_LINKING
.
shaders
- Shaders to attach to this program. Shaders can
be attached also by attach(Shader)
later.
Shaders that have already been deleted are not
attached even if they appear in the given list.
GLESException
- glCreateProgram() failed.Method Detail |
---|
public int getId()
public ProgramState getState()
public void delete()
DELETED
.
Attached shaders, if any, are detached from this program explicitly before this method returns.
public Program attach(Shader<?> shader)
NEEDS_LINKING
.
shader
- A shader to attach to this program.
IllegalArgumentException
- IllegalStateException
- This program has already been deleted.public Program detach(Shader<?> shader)
NEEDS_LINKING
.
IllegalArgumentException
- The given argument is null, or the shader is not attached
to this program.
IllegalStateException
- This program has already been deleted.public Program link() throws GLESException
LINKED
, nothing is executed.
Before calling glLinkProgram(), shaders attached to this program
are compiled if they have not been compiled yet. If this method
returns without any exception, the state of this program is
LINKED
.
IllegalStateException
- GLESException
- glLinkProgram() or glCompileShader() failed.public Program use() throws GLESException
link()
is executed before calling glUseProgram().
IllegalStateException
- This program has already been deleted.
GLESException
- Linking failed.public static void unuse()
public Uniform getUniform(String name) throws GLESException
name
- A name of a uniform variable.
Uniform
object to manipulate the uniform variable.
IllegalArgumentException
- The argument is null.
GLESException
- There is no such a uniform variable having the name.public Sampler getSampler(String name) throws GLESException
name
- A name of a uniform sampler variable.
Sampler
object to manipulate the uniform sampler variable.
IllegalArgumentException
- The argument is null.
GLESException
- There is no such a uniform variable having the name.public Attribute getAttribute(String attributeName)
attributeName
- Name of an attribute variable in this program.
Attribute
object for the attribute variable.
If an attribute variable having the name is not found
in this program, null is returned.
IllegalArgumentException
- The arguments is null.
IllegalStateException
- This program has already been deleted.public Program setAttribute(String attributeName, Attribute attribute)
This method has the same effect of
glBindAttribLocation(this.getId()
, attribute.getIndex()
, attributeName).
attributeName
- The name of the attribute in this program.attribute
- The attribute data to set.
IllegalArgumentException
- Either or both of the arguments are null.
IllegalStateException
- This program has already been deleted.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |