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 classGLSLProgram.GLSLWarnTypestatic classGLSLProgram.StrictnessControl the behaviour of a GLSL program with errors (throwing exceptions, create warnings, etc)
-
Field Summary
Fields Modifier and Type Field Description static GLSLProgram.StrictnessDEFAULT_STRICTNESSprotected List<Integer>fragmentShaders_protected static org.apache.logging.log4j.Loggerlogprotected IntegerprogramIdprotected GLSLProgram.Strictnessstrictnessprotected List<Integer>vertexShaders_static booleanWARN_SHOW_SHADER_SOURCEprotected StringBufferwarnBuffer
-
Constructor Summary
Constructors Constructor Description GLSLProgram()GLSLProgram(GLSLProgram.Strictness strictness)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(com.jogamp.opengl.GL2 gl)voidbindTexture(com.jogamp.opengl.GL2 gl, int target, String texname, int texid, int texunit)voidbindTexture2D(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)voidbindTexture3D(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)voidbindTextureRECT(com.jogamp.opengl.GL2 gl, String texname, int texid, int texunit)protected voidcheckShaderLogInfo(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.StrictnessvoidcompileFragmentShader(com.jogamp.opengl.GL2 gl, URL infoURL, String content)voidcompileVertexShader(com.jogamp.opengl.GL2 gl, URL infoURL, String content)voiddestroy(com.jogamp.opengl.GL2 gl)IntegergetProgramId()voidlink(com.jogamp.opengl.GL2 gl)Create a program and attach previously loaded and compiled shaders.voidloadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, InputStream stream)voidloadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, InputStream stream, URL infoURL)voidloadAndCompileFragmentShader(com.jogamp.opengl.GL2 gl, URL fileURL)voidloadAndCompileShaders(com.jogamp.opengl.GL2 gl, ShaderFilePair files)voidloadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, InputStream stream)voidloadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, InputStream stream, URL infoURL)voidloadAndCompileVertexShader(com.jogamp.opengl.GL2 gl, URL fileURL)StringreadErrors(com.jogamp.opengl.GL2 gl, int iID)voidsetTextureUnit(com.jogamp.opengl.GL2 gl, String texname, int texunit)voidsetUniform(com.jogamp.opengl.GL2 gl, String name, float value)voidsetUniform(com.jogamp.opengl.GL2 gl, String name, float[] values, int count)voidunbind(com.jogamp.opengl.GL2 gl)voidvalidateProgram(com.jogamp.opengl.GL2 gl)voidverifyLinkStatus(com.jogamp.opengl.GL2 gl, int programId)voidverifyShaderCompiled(com.jogamp.opengl.GL2 gl, URL fileURL, int programId, String content)protected voidwarn(String info, GLSLProgram.GLSLWarnType type)protected voidwarnLink(com.jogamp.opengl.GL2 gl, String error, int linkStatus, int logLength)protected voidwarnScript(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()
-
-