Search in sources :

Example 1 with ShaderState

use of com.jogamp.opengl.util.glsl.ShaderState in project narchy by automenta.

the class GLSL method initShaders.

private void initShaders(GL2 gl) {
    if (!gl.hasGLSL()) {
        System.err.println("No GLSL available, no rendering.");
        return;
    }
    st = new ShaderState();
    // st.setVerbose(true);
    // final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader",
    // "shader/bin", "gears", true);
    // final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader",
    // "shader/bin", "gears", true);
    CharSequence fsrc = null;
    try {
        fsrc = new StringBuilder(new String(GLSL.class.getClassLoader().getResourceAsStream(// "glsl/metablob.glsl"
        "glsl/16seg.glsl").readAllBytes()));
    } catch (IOException e) {
        e.printStackTrace();
    }
    // vp0 = new ShaderCode(GL_VERTEX_SHADER, 1, new CharSequence[][]{{vsrc}});
    fp0 = new ShaderCode(GL_FRAGMENT_SHADER, 1, new CharSequence[][] { { fsrc } });
    // vp0.defaultShaderCustomization(gl, true, true);
    fp0.defaultShaderCustomization(gl, true, true);
    final ShaderProgram sp0 = new ShaderProgram();
    // sp0.add(gl, vp0, System.err);
    sp0.add(gl, fp0, System.err);
    st.attachShaderProgram(gl, sp0, true);
    // Use debug pipeline
    // gl.getContext().addGLDebugListener(new GLDebugMessageHandler.StdErrGLDebugListener(true));
    // make sure .. for shared context (impacts OSX 10.9)
    gl.glFinish();
}
Also used : ShaderProgram(com.jogamp.opengl.util.glsl.ShaderProgram) ShaderState(com.jogamp.opengl.util.glsl.ShaderState) IOException(java.io.IOException) ShaderCode(com.jogamp.opengl.util.glsl.ShaderCode)

Aggregations

ShaderCode (com.jogamp.opengl.util.glsl.ShaderCode)1 ShaderProgram (com.jogamp.opengl.util.glsl.ShaderProgram)1 ShaderState (com.jogamp.opengl.util.glsl.ShaderState)1 IOException (java.io.IOException)1