Program

Represents an OpenGL program. A program holds the necessary shaders for the rendering pipeline. When using GL20, it is strongly recommended to set the attribute layout in the {@link org.spout.renderer.api.gl.Shader}s with {@link org.spout.renderer.api.gl.Shader#setAttributeLayout(String, int)}}, which must be done before attaching it. The layout allows for association between the attribute index in the vertex data and the name in the shaders. For GL30, it is recommended to do so in the shaders instead, using the "layout" keyword. Failing to do so might result in partial, wrong or missing rendering, and affects models using multiple attributes. The texture layout should also be setup using {@link Shader#setTextureLayout(int, String)} in the same way.

Members

Functions

attachShader
void attachShader(Shader shader)

Attaches a shader to the program.

bindSampler
void bindSampler(uint unit)

Binds the sampler to the texture unit. The binding is done according to the texture layout, which must be set in the program for the textures that will be used before any binding can be done.

destroy
void destroy()
Undocumented in source. Be warned that the author may not have intended to support it.
detachShader
void detachShader(Shader shader)

Detaches a shader from the shader.

getID
uint getID()

Gets the ID for this program as assigned by OpenGL.

getShaders
Shader[] getShaders()

Returns the shaders that have been attached to this program.

getUniformNames
string[] getUniformNames()

Returns an set containing all of the uniform names for this program.

link
void link()

Links the shaders together in the program. This makes it usable.

setUniform
void setUniform(string name, bool b)

Sets a uniform boolean in the shader to the desired value.

setUniform
void setUniform(string name, int i)

Sets a uniform integer in the shader to the desired value.

setUniform
void setUniform(string name, float f)

Sets a uniform float in the shader to the desired value.

setUniform
void setUniform(string name, float[] fs)

Sets a uniform float array in the shader to the desired value.

setUniform
void setUniform(string name, float x, float y)

Sets a uniform {@link com.flowpowered.math.vector.Vector2f} in the shader to the desired value.

setUniform
void setUniform(string name, float x, float y, float z)

Sets a uniform {@link com.flowpowered.math.vector.Vector3f} in the shader to the desired value.

setUniform
void setUniform(string name, float x, float y, float z, float w)

Sets a uniform {@link com.flowpowered.math.vector.Vector4f} in the shader to the desired value.

setUniform
void setUniform(string name, float[4] m)

Sets a uniform {@link com.flowpowered.math.matrix.Matrix4f} in the shader to the desired value.

setUniform
void setUniform(string name, float[9] m)

Sets a uniform {@link com.flowpowered.math.matrix.Matrix4f} in the shader to the desired value.

setUniform
void setUniform(string name, float[16] m)

Sets a uniform {@link com.flowpowered.math.matrix.Matrix4f} in the shader to the desired value.

use
void use()

Binds this program to the OpenGL context.

Variables

id
uint id;
Undocumented in source.

Inherited Members

From Creatable

create
void create()

Creates the resources. It can now be used.

destroy
void destroy()

Releases the resource. It can not longer be used.

isCreated
bool isCreated()

Returns true if the resource was created and is ready for use, false if otherwise.

checkCreated
void checkCreated()

Throws an exception if the resource hasn't been created yet.

checkNotCreated
void checkNotCreated()

Throws an exception if the resource has been created already.

From GLVersioned

getGLVersion
GLVersion getGLVersion()

Returns the lowest OpenGL version required by this object's implementation.

Meta