Example usage for org.lwjgl.opengl GL20 glDetachShader

List of usage examples for org.lwjgl.opengl GL20 glDetachShader

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL20 glDetachShader.

Prototype

public static void glDetachShader(@NativeType("GLuint") int program, @NativeType("GLuint") int shader) 

Source Link

Document

Detaches a shader object from a program object to which it is attached.

Usage

From source file:br.com.perin.shaders.ShaderProgram.java

public void cleanUp() {
    stop();//w  ww  . java2  s .com
    GL20.glDetachShader(programId, vertexShaderId);
    GL20.glDetachShader(programId, fragmentShaderId);
    GL20.glDeleteShader(vertexShaderId);
    GL20.glDeleteShader(fragmentShaderId);
    GL20.glDeleteProgram(programId);
}

From source file:com.adavr.player.globjects.Program.java

License:Open Source License

public void detachShader(Shader shader) {
    GL20.glDetachShader(id, shader.id);
}

From source file:com.auroraengine.opengl.shaders.GLProgram.java

License:Open Source License

@Override
public void forceDestroy() {
    if (index != 0) {
        GL20.glDetachShader(index, vertex.index);
        GL20.glDetachShader(index, fragment.index);
        vertex.destroy(this);
        fragment.destroy(this);
        GL20.glDeleteProgram(index);/*from   ww w. ja  va 2 s  . c o  m*/
    }
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

public void glDetachShader(int program, int shader) {
    GL20.glDetachShader(program, shader);
}

From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Program.java

License:MIT License

@Override
public void detachShader(Shader shader) {
    checkCreated();/*from w  ww  .j a v  a2  s. c  o  m*/
    // Attach the shader
    GL20.glDetachShader(id, shader.getID());
    // Check for errors
    LWJGLUtil.checkForGLError();
    // Remove the shader from the set
    shaders.remove(shader);
    // Remove all attribute and texture layouts
    for (String attribute : shader.getAttributeLayouts().keySet()) {
        attributeLayouts.remove(attribute);
    }
    for (int unit : shader.getTextureLayouts().keys()) {
        textureLayouts.remove(unit);
    }
}

From source file:com.geekyaubergine.geekyjgameutil.shader.ShaderProgram.java

License:Open Source License

@Override
public void unloadResource() {
    stop();// w  ww . j  a  v  a 2  s  .  c  om
    GL20.glDetachShader(programID, vertexShaderID);
    GL20.glDetachShader(programID, fragmentShaderID);
    GL20.glDeleteShader(vertexShaderID);
    GL20.glDeleteShader(fragmentShaderID);
    GL20.glDeleteProgram(programID);
}

From source file:com.github.ryancwilliams.WJ3dPL.graphics.GLUtils.ShaderProgram.java

License:Apache License

/**
 * Creates a new shader program with the provided vertex and fragment 
 * shader source code./*from  www.j a va 2s. co  m*/
 * The provided attributes are linked to this program.
 * @param vertexShaderSource the source code of the vertex shader.
 * @param fragmentShaderSource the source code of the fragment shader.
 * @param attributes The Vertex Attributes to bind to this shader program.
 * @throws LWJGLException If their is a issue compiling the shaders or 
 * creating or binding the program.  
 */
public ShaderProgram(String vertexShaderSource, String fragmentShaderSource, List<VertexAttribute> attributes)
        throws LWJGLException {
    //Check if any of the sourcecode paramaters are null
    if (fragmentShaderSource == null || fragmentShaderSource == null) {
        //If any of the sourcecode paramaters were null
        //throw a exception
        throw new IllegalArgumentException("Shader source may not be null");
    }
    //Check if shaders are not supported
    if (!ShaderProgram.isSupported()) {
        //If shaders are not supported
        //throw a exception
        throw new LWJGLException("Shaders are not supported on this device");
    }

    //Compile the shaders
    int vertexShader = ShaderProgram.compileShader(GL20.GL_VERTEX_SHADER, vertexShaderSource);
    int fragmentShader = ShaderProgram.compileShader(GL20.GL_FRAGMENT_SHADER, fragmentShaderSource);

    //Create the program
    this.program = GL20.glCreateProgram();

    //Bind the attrib locations
    //Check if attributes were provided
    if (attributes != null) {
        //For each attribute
        for (VertexAttribute attribute : attributes) {
            //Check if the attribute is not null
            if (attribute != null) {
                //bind the attribute
                GL20.glBindAttribLocation(this.program, attribute.index, attribute.name);
            }
        }
    }

    //Attach the shaders
    GL20.glAttachShader(this.program, vertexShader);
    GL20.glAttachShader(this.program, fragmentShader);

    //Link the program
    GL20.glLinkProgram(this.program);

    //Get if the program link was good
    boolean programLink = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS) == GL11.GL_TRUE;

    //Get the log
    String infoLog = GL20.glGetProgramInfoLog(this.program,
            GL20.glGetProgrami(this.program, GL20.GL_INFO_LOG_LENGTH));

    //Log the log if a log is present
    if (infoLog != null && infoLog.trim().length() != 0) {
        Logger.getLogger(ShaderProgram.class.getName()).log(Level.FINEST, infoLog);
    }

    //Check if program link is bad
    if (programLink == false) {
        throw new LWJGLException("Failure in linking program. Error log:\n" + infoLog);
    }

    //detach and delete the shaders which are no longer needed
    GL20.glDetachShader(this.program, vertexShader);
    GL20.glDetachShader(this.program, fragmentShader);
    GL20.glDeleteShader(vertexShader);
    GL20.glDeleteShader(fragmentShader);
}

From source file:com.google.gapid.glviewer.gl.Shader.java

License:Apache License

private void detachShaders() {
    int[] shaders = getAttachedShaders(handle);
    for (int i = 0; i < shaders.length; i++) {
        GL20.glDetachShader(handle, shaders[i]);
        GL20.glDeleteShader(shaders[i]);
    }//from w  w  w . j  a  v  a 2 s  .c o  m
}

From source file:com.kauridev.lunarfever.graphics.ShaderProgram.java

License:Open Source License

private void disposeShaders() {
    if (vert != 0) {
        GL20.glDetachShader(program, vert);
        GL20.glDeleteShader(vert);//from  www  . j ava2 s .  c om
        vert = 0;
    }

    if (frag != 0) {
        GL20.glDetachShader(program, frag);
        GL20.glDeleteShader(frag);
        frag = 0;
    }
}

From source file:com.opengrave.og.resources.ShaderProgram.java

License:Open Source License

public void compile() {
    Util.checkErr();/* w  ww  .  j  a  v  a  2  s  .  c  om*/

    PID = GL20.glCreateProgram();
    Util.checkErr();

    vert = loadShader(sfv.getSource(), GL20.GL_VERTEX_SHADER);
    Util.checkErr();

    frag = loadShader(sff.getSource(), GL20.GL_FRAGMENT_SHADER);
    Util.checkErr();

    GL20.glAttachShader(PID, vert);
    Util.checkErr();

    GL20.glAttachShader(PID, frag);
    Util.checkErr();

    GL20.glLinkProgram(PID);
    Util.checkErr();

    System.out.println(GL20.glGetProgramInfoLog(PID, 2000));
    Util.checkErr();

    GL20.glValidateProgram(PID);
    Util.checkErr();

    // System.out.println("Compiled " + label + " as number " + PID);
    if (GL20.glGetProgrami(PID, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
        new DebugExceptionHandler(new Exception(), label, GL20.glGetShaderInfoLog(PID, 2000),
                GL20.glGetProgramInfoLog(PID, 2000));
        // System.out.println("Failed to link " + label);
        // System.out.println(sfv.getSource());
        // System.out.println(sff.getSource());

        // Util.checkErr();

        // printShaderLogs();
    }
    Util.checkErr();

    GL20.glDetachShader(PID, vert);
    Util.checkErr();

    GL20.glDetachShader(PID, frag);
    GL20.glDeleteShader(vert);
    Util.checkErr();

    GL20.glDeleteShader(frag);
    Util.checkErr();
}