Package org.jzy3d.io.glsl
Class GLSLProgram
- java.lang.Object
-
- org.jzy3d.io.glsl.GLSLProgram
-
public class GLSLProgram extends Object
Below is description of the GLSL program lifecycle, with Jzy3d methods, and underlying OpenGL methods.- load shaders with
attachVertexShader()
andattachFragmentShader()
- glCreateShader
- glShaderSource
- glCompileShader
- glGetShaderiv (verify status)
- glGetShaderInfoLog (log errors)
- link(gl) links the compiled shaders
- glCreateProgram
- glAttachShader
- glLinkProgram
- glGetProgramiv (verify status)
- glGetProgramInfoLog (log errors)
- glValidateProgram
- bind(gl) mount the program @ rendering
- glUseProgram
bindTextureRECT(gl)
- unbind(gl) unmount the program @ rendering
- glUseProgram(0)
- destroy(gl)
- glDeleteShader
- glDeleteProgram
- load shaders with
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GLSLProgram.GLSLWarnType
static class
GLSLProgram.Strictness
Control the behaviour of a GLSL program with errors (throwing exceptions, create warnings, etc)
-
Field Summary
Fields Modifier and Type Field Description static GLSLProgram.Strictness
DEFAULT_STRICTNESS
protected List<Integer>
fragmentShaders_
protected static org.apache.logging.log4j.Logger
log
protected Integer
programId
protected GLSLProgram.Strictness
strictness
protected List<Integer>
vertexShaders_
static boolean
WARN_SHOW_SHADER_SOURCE
protected StringBuffer
warnBuffer
-
Constructor Summary
Constructors Constructor Description GLSLProgram()
GLSLProgram(GLSLProgram.Strictness strictness)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(com.jogamp.opengl.GL2 gl)
void
bindTexture(com.jogamp.opengl.GL2 gl, int target, String texname, int texid, int texunit)
void
bindTexture2D(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)
void
bindTexture3D(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)
void
bindTextureRECT(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)
protected void
checkShaderLogInfo(com.jogamp.opengl.GL2 inGL, int shaderObjectID)
read logs and either throw exception, print to console or append to error log according to the configuredGLSLProgram.Strictness
void
compileFragmentShader(com.jogamp.opengl.GL2 gl, URL infoURL, String content)
void
compileVertexShader(com.jogamp.opengl.GL2 gl, URL infoURL, String content)
void
destroy(com.jogamp.opengl.GL2 gl)
Integer
getProgramId()
void
link(com.jogamp.opengl.GL2 gl)
Create a program and attach previously loaded and compiled shaders.void
loadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, InputStream stream)
void
loadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, InputStream stream, URL infoURL)
void
loadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, URL fileURL)
void
loadAndCompileShaders(com.jogamp.opengl.GL2 gl, ShaderFilePair files)
void
loadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, InputStream stream)
void
loadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, InputStream stream, URL infoURL)
void
loadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, URL fileURL)
String
readErrors(com.jogamp.opengl.GL2 gl, int iID)
void
setTextureUnit(com.jogamp.opengl.GL2 gl, String texname, int texunit)
void
setUniform(com.jogamp.opengl.GL2 gl, String name, float value)
void
setUniform(com.jogamp.opengl.GL2 gl, String name, float[] values, int count)
void
unbind(com.jogamp.opengl.GL2 gl)
void
validateProgram(com.jogamp.opengl.GL2 gl)
void
verifyLinkStatus(com.jogamp.opengl.GL2 gl, int programId)
void
verifyShaderCompiled(com.jogamp.opengl.GL2 gl, URL fileURL, int programId, String content)
protected void
warn(String info, GLSLProgram.GLSLWarnType type)
protected void
warnLink(com.jogamp.opengl.GL2 gl, String error, int linkStatus, int logLength)
protected void
warnScript(com.jogamp.opengl.GL2 gl, URL fileURL, String error, int compileStatus, int logLength, String content)
-
-
-
Field Detail
-
DEFAULT_STRICTNESS
public static GLSLProgram.Strictness DEFAULT_STRICTNESS
-
WARN_SHOW_SHADER_SOURCE
public static boolean WARN_SHOW_SHADER_SOURCE
-
log
protected static org.apache.logging.log4j.Logger log
-
programId
protected Integer programId
-
warnBuffer
protected StringBuffer warnBuffer
-
strictness
protected GLSLProgram.Strictness strictness
-
-
Constructor Detail
-
GLSLProgram
public GLSLProgram()
-
GLSLProgram
public GLSLProgram(GLSLProgram.Strictness strictness)
-
-
Method Detail
-
link
public void link(com.jogamp.opengl.GL2 gl)
Create a program and attach previously loaded and compiled shaders. Performs validation and warn according to program strictness.
-
bind
public void bind(com.jogamp.opengl.GL2 gl)
-
unbind
public void unbind(com.jogamp.opengl.GL2 gl)
-
destroy
public void destroy(com.jogamp.opengl.GL2 gl)
-
setUniform
public void setUniform(com.jogamp.opengl.GL2 gl, String name, float value)
-
setUniform
public void setUniform(com.jogamp.opengl.GL2 gl, String name, float[] values, int count)
-
setTextureUnit
public void setTextureUnit(com.jogamp.opengl.GL2 gl, String texname, int texunit)
-
bindTexture
public void bindTexture(com.jogamp.opengl.GL2 gl, int target, String texname, int texid, int texunit)
-
bindTexture2D
public void bindTexture2D(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)
-
bindTexture3D
public void bindTexture3D(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)
-
bindTextureRECT
public void bindTextureRECT(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)
-
loadAndCompileShaders
public void loadAndCompileShaders(com.jogamp.opengl.GL2 gl, ShaderFilePair files)
-
loadAndCompileVertexShader
public void loadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, URL fileURL)
-
loadAndCompileVertexShader
public void loadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, InputStream stream)
-
loadAndCompileVertexShader
public void loadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, InputStream stream, URL infoURL)
- Parameters:
gl
-stream
- shader source code ressourceinfoURL
- only used as information for warnings if shader does not compile properly
-
loadAndCompileFragmentShader
public void loadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, URL fileURL)
-
loadAndCompileFragmentShader
public void loadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, InputStream stream)
-
loadAndCompileFragmentShader
public void loadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, InputStream stream, URL infoURL)
-
compileVertexShader
public void compileVertexShader(com.jogamp.opengl.GL2 gl, URL infoURL, String content)
-
compileFragmentShader
public void compileFragmentShader(com.jogamp.opengl.GL2 gl, URL infoURL, String content)
-
verifyShaderCompiled
public void verifyShaderCompiled(com.jogamp.opengl.GL2 gl, URL fileURL, int programId, String content)
-
verifyLinkStatus
public void verifyLinkStatus(com.jogamp.opengl.GL2 gl, int programId)
-
readErrors
public String readErrors(com.jogamp.opengl.GL2 gl, int iID)
-
validateProgram
public void validateProgram(com.jogamp.opengl.GL2 gl)
-
checkShaderLogInfo
protected void checkShaderLogInfo(com.jogamp.opengl.GL2 inGL, int shaderObjectID)
read logs and either throw exception, print to console or append to error log according to the configuredGLSLProgram.Strictness
-
warnScript
protected void warnScript(com.jogamp.opengl.GL2 gl, URL fileURL, String error, int compileStatus, int logLength, String content)
-
warnLink
protected void warnLink(com.jogamp.opengl.GL2 gl, String error, int linkStatus, int logLength)
-
warn
protected void warn(String info, GLSLProgram.GLSLWarnType type)
-
getProgramId
public Integer getProgramId()
-
-