public final class ShaderLoader extends Object
ShaderLoader
is a simple utility for loading shaders. It takes shaders directly as
strings. It will create and compile the shaders, and link them together into a program. Both
compiling and linking are verified. If a problem occurs a GLException
is thrown with
the appropriate log attached.
Note it is highly recommended that if the developer passes the strings directly to ShaderLoader
that they contain newlines. That way if any errors do occur their line numbers
will be reported correctly. This means that if the shader is to be embedded in Java code, a
"\n" should be appended to every line.
Modifier and Type | Method and Description |
---|---|
static boolean |
isProgramLinked(javax.media.opengl.GL2ES2 gl,
int program)
Checks that a shader program was linked successfully.
|
static boolean |
isProgramValidated(javax.media.opengl.GL2ES2 gl,
int program)
Checks that a shader program was validated successfully.
|
static boolean |
isShaderCompiled(javax.media.opengl.GL2ES2 gl,
int shader)
Checks that a shader was compiled correctly.
|
static int |
loadProgram(javax.media.opengl.GL2ES2 gl,
String vss,
String fss)
Loads a shader program from a pair of strings.
|
public static boolean isShaderCompiled(javax.media.opengl.GL2ES2 gl, int shader)
gl
- OpenGL context, assumed not nullshader
- OpenGL handle to a shaderpublic static boolean isProgramLinked(javax.media.opengl.GL2ES2 gl, int program)
gl
- OpenGL context, assumed not nullprogram
- OpenGL handle to a shader programpublic static boolean isProgramValidated(javax.media.opengl.GL2ES2 gl, int program)
gl
- OpenGL context, assumed not nullprogram
- OpenGL handle to a shader programpublic static int loadProgram(javax.media.opengl.GL2ES2 gl, String vss, String fss)
gl
- Current OpenGL contextvss
- Vertex shader sourcefss
- Fragment shader sourceNullPointerException
- if context or either source is nullIllegalArgumentException
- if either source is emptyjavax.media.opengl.GLException
- if program did not compile, link, or validate successfullyCopyright © 2018 Metron, Inc.. All rights reserved.