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:com.redthirddivision.quad.rendering.shaders.Shader.java

License:Apache License

public void cleanUp() {
    stop();/*from   www .j a  v  a2  s.  c o  m*/
    GL20.glDetachShader(programID, vertexID);
    GL20.glDetachShader(programID, fragmentID);
    GL20.glDeleteShader(vertexID);
    GL20.glDeleteShader(fragmentID);
    GL20.glDeleteProgram(programID);
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Detaches the given shader from this program. Can be safely done at any
 * point after linking.//  ww w. j  a  v a  2  s  .  c o m
 * 
 * @param shader The shader to detach.
 * @return This shader program.
 */
public ShaderProgram detach(Shader shader) {
    GL20.glDetachShader(id, shader.id);
    shaders.remove(shader);
    return this;
}

From source file:com.samrj.devil.gl.ShaderProgram.java

License:Open Source License

/**
 * Detaches all shaders from this program. Should be called after linking.
 * //from w  w  w  . j a va  2 s  . co  m
 * @return This shader program.
 */
public ShaderProgram detachAll() {
    for (Shader shader : shaders)
        GL20.glDetachShader(id, shader.id);
    shaders.clear();
    return this;
}

From source file:com.wicpar.sinkingsimulatorclassic.graphics.ShaderProgram.java

License:Open Source License

public ShaderProgram setShaders(Shader... shaders) {
    if (ID == null)
        create();//from w  w w  .j a va 2 s .co m
    if (this.shaders.size() != 0) {
        for (Shader shader : this.shaders) {
            GL20.glDetachShader(ID, shader.getID());
        }
        this.shaders.clear();
    }
    for (Shader shader : shaders) {
        GL20.glAttachShader(ID, shader.getID());
    }
    GL20.glLinkProgram(ID);
    if (GL20.glGetProgrami(ID, GL20.GL_LINK_STATUS) != GL11.GL_TRUE) {
        logger.error("failed to link program: \n" + GL20.glGetProgramInfoLog(ID));
    }
    return this;
}

From source file:eu.over9000.veya.rendering.Program.java

License:Open Source License

public Program(final String shaderName, final String[] uniformNames) {
    final int vsID = Program.loadShader(
            Program.class.getResourceAsStream("/shaders/" + shaderName + "/vertex.glsl"),
            GL20.GL_VERTEX_SHADER);/*from  w  ww  .j av  a 2  s  . co m*/
    final int fsID = Program.loadShader(
            Program.class.getResourceAsStream("/shaders/" + shaderName + "/fragment.glsl"),
            GL20.GL_FRAGMENT_SHADER);

    this.id = GL20.glCreateProgram();
    GL20.glAttachShader(this.id, vsID);
    GL20.glAttachShader(this.id, fsID);

    GL20.glLinkProgram(this.id);
    Program.checkLinkage(this.id);

    //GL20.glValidateProgram(this.id);
    //Program.checkValidation(this.id);

    GL20.glDetachShader(this.id, vsID);
    GL20.glDetachShader(this.id, fsID);

    GL20.glDeleteShader(vsID);
    GL20.glDeleteShader(fsID);

    this.uniformLocations = new HashMap<>(uniformNames.length + 1, 1);
    for (final String name : uniformNames) {
        final int loc = GL20.glGetUniformLocation(this.id, name);
        this.uniformLocations.put(name, loc);
        System.out.println("UniformLoc for " + name + "=" + loc);
    }

    Util.checkGLError();
}

From source file:fr.ign.cogit.geoxygene.util.gl.GLProgram.java

License:Open Source License

/**
 * Mark all shaders and program for deletion
 *///w  w w.  j a  v a2 s.c  o m
public synchronized void dispose() {
    if (this.programId != -1) {
        GLTools.glCheckError("before program " + this.getName() + " shader detach");
        for (GLShader shader : this.shaders) {
            GL20.glDetachShader(this.programId, shader.getId());
        }
        GLTools.glCheckError("before program " + this.getName() + " deletion");
        GL20.glDeleteProgram(this.programId);
        GLTools.glCheckError("after program " + this.getName() + " deletion");
        this.programId = -1;
        this.shaders.clear();
        this.uniforms.clear();
        this.uniforms_location.clear();
    }
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

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

From source file:lessur.util.shader.ShaderManager.java

License:GNU General Public License

/**
 * Removes a program and all shaders associated with it
 * @param The id/index of the program// ww w . ja  v a 2s.  c o  m
 */
public void removeProgram(int programID) {
    Set<Integer> shaders = programToShaders.get(programID);
    if (shaders == null) {
        throw new IllegalArgumentException("The programID " + programID + "does not exist");
    }
    //detach Shaders from program
    for (int id : shaders) {
        if (has_opengl2) {
            GL20.glDetachShader(programID, id);
        } else if (has_arb) {
            ARBShaderObjects.glDetachObjectARB(programID, id);
        }
    }
    //Delete unused shaders
    for (int id : shaders) {
        Set<Integer> progs = shaderToPrograms.get(id);
        progs.remove(programID);
        if (progs.isEmpty()) {
            if (has_opengl2) {
                GL20.glDeleteShader(id);
            }
            shaderToPrograms.remove(id);
        }
    }
    //Delete Program
    if (has_opengl2) {
        GL20.glDeleteProgram(programID);
    } else if (has_arb) {
        ARBShaderObjects.glDeleteObjectARB(programID);
    }
    programToShaders.remove(programID);
}

From source file:me.thehutch.fusion.engine.render.opengl.gl20.OpenGL20Program.java

License:Open Source License

@Override
public void dispose() {
    ensureCreated("Program must be created to dispose.");
    // Detach and delete each shader
    this.shaders.forEach((int shader) -> {
        GL20.glDetachShader(id, shader);
        GL20.glDeleteShader(shader);/*from w w  w.  ja  va 2s  .  c  o  m*/
        return true;
    });
    // Delete the program
    GL20.glDeleteProgram(id);
    // Clear the shaders set
    this.shaders.clear();
    // Clear the uniforms map
    this.uniforms.clear();
    // Check for errors
    RenderUtil.checkGLError();
    // Dispose the program
    super.dispose();
}

From source file:net.smert.frameworkgl.opengl.helpers.ShaderHelper.java

License:Apache License

public void detach(int programID, int shaderID) {
    GL20.glDetachShader(programID, shaderID);
}