Java Code Examples for org.lwjgl.opengl.GL20#glDeleteProgram()

The following examples show how to use org.lwjgl.opengl.GL20#glDeleteProgram() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CurveRenderState.java    From opsu-dance with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Cleanup any OpenGL objects that may have been initialized.
 */
private void shutdown() {
	if (gradientTexture != 0) {
		GL11.glDeleteTextures(gradientTexture);
		gradientTexture = 0;
	}

	if (program != 0) {
		GL20.glDeleteProgram(program);
		program = 0;
		attribLoc = 0;
		texCoordLoc = 0;
		colLoc = 0;
		colBorderLoc = 0;
		texLoc = 0;
	}
}
 
Example 2
Source File: OpenGLRenderer20.java    From ldparteditor with MIT License 6 votes vote down vote up
@Override
public void dispose() {
    GL20.glUseProgram(0);
    if (pGlossId != -1) {
        if (vsGlossId != -1)
            GL20.glDetachShader(pGlossId, vsGlossId);
        if (fsGlossId != -1)
            GL20.glDetachShader(pGlossId, fsGlossId);
    }
    if (vsGlossId != -1)
        GL20.glDeleteShader(vsGlossId);
    if (fsGlossId != -1)
        GL20.glDeleteShader(fsGlossId);

    if (pGlossId != -1)
        GL20.glDeleteProgram(pGlossId);
    // Dispose all textures
    for (Iterator<GTexture> it = textureSet.iterator() ; it.hasNext();) {
        GTexture tex = it.next();
        NLogger.debug(getClass(), "Dispose texture: {0}", tex); //$NON-NLS-1$
        tex.dispose(this);
        it.remove();
    }
}
 
Example 3
Source File: LegacyCurveRenderState.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Cleanup any OpenGL objects that may have been initialized.
 */
private void shutdown() {
	if (gradientTexture != 0) {
		GL11.glDeleteTextures(gradientTexture);
		gradientTexture = 0;
	}

	if (program != 0) {
		GL20.glDeleteProgram(program);
		program = 0;
		attribLoc = 0;
		texCoordLoc = 0;
		colLoc = 0;
		colBorderLoc = 0;
		texLoc = 0;
	}
}
 
Example 4
Source File: CurveRenderState.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Cleanup any OpenGL objects that may have been initialized.
 */
private void shutdown() {
	if (gradientTexture != 0) {
		GL11.glDeleteTextures(gradientTexture);
		gradientTexture = 0;
	}

	if (program != 0) {
		GL20.glDeleteProgram(program);
		program = 0;
		attribLoc = 0;
		texCoordLoc = 0;
		colLoc = 0;
		colBorderLoc = 0;
		texLoc = 0;
	}
}
 
Example 5
Source File: OpenGL3_TheQuadTextured.java    From ldparteditor with MIT License 5 votes vote down vote up
private void destroyOpenGL() {  
    // Delete the texture
    GL11.glDeleteTextures(texIds[0]);
    GL11.glDeleteTextures(texIds[1]);
     
    // Delete the shaders
    GL20.glUseProgram(0);
    GL20.glDetachShader(pId, vsId);
    GL20.glDetachShader(pId, fsId);
     
    GL20.glDeleteShader(vsId);
    GL20.glDeleteShader(fsId);
    GL20.glDeleteProgram(pId);
     
    // Select the VAO
    GL30.glBindVertexArray(vaoId);
     
    // Disable the VBO index from the VAO attributes list
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
     
    // Delete the vertex VBO
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboId);
     
    // Delete the index VBO
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboiId);
     
    // Delete the VAO
    GL30.glBindVertexArray(0);
    GL30.glDeleteVertexArrays(vaoId);
     
    this.exitOnGLError("destroyOpenGL");
     
    Display.destroy();
}
 
Example 6
Source File: GenericShader.java    From LWJGUI with MIT License 4 votes vote down vote up
public void cleanup() {
	GL20.glDeleteShader(vertexId);
	GL20.glDeleteShader(fragmentId);
	GL20.glDeleteProgram(id);
}
 
Example 7
Source File: ShaderProgram.java    From LowPolyWater with The Unlicense 4 votes vote down vote up
public void cleanUp() {
	GL20.glUseProgram(0);
	GL20.glDeleteProgram(programID);
}
 
Example 8
Source File: ShaderProgram.java    From OpenGL-Animation with The Unlicense 4 votes vote down vote up
public void cleanUp() {
	stop();
	GL20.glDeleteProgram(programID);
}
 
Example 9
Source File: GLShader.java    From ldparteditor with MIT License 4 votes vote down vote up
void dispose() {
    GL20.glUseProgram(0);
    GL20.glDeleteProgram(program);
    uniformMap.clear();
}
 
Example 10
Source File: LWJGL20DrawContext.java    From settlers-remake with MIT License 4 votes vote down vote up
private ShaderProgram(String name) {
	int vertexShader = -1;
	int fragmentShader;

	String vname = name;
	if(name.contains("-")) vname = name.split("-")[0];

	try {
		vertexShader = createShader(vname+".vert", GL20.GL_VERTEX_SHADER);
		fragmentShader = createShader(name+".frag", GL20.GL_FRAGMENT_SHADER);
	} catch (IOException e) {
		e.printStackTrace();

		if(vertexShader != -1) GL20.glDeleteShader(vertexShader);
		throw new Error("could not read shader files", e);
	}

	program = GL20.glCreateProgram();
	setObjectLabel(KHRDebug.GL_PROGRAM, program, name);

	GL20.glAttachShader(program, vertexShader);
	GL20.glAttachShader(program, fragmentShader);

	GL20.glBindAttribLocation(program, 0, "vertex");
	GL20.glBindAttribLocation(program, 1, "texcoord");
	GL20.glBindAttribLocation(program, 2, "color");

	GL20.glLinkProgram(program);
	GL20.glValidateProgram(program);

	GL20.glDetachShader(program, vertexShader);
	GL20.glDetachShader(program, fragmentShader);
	GL20.glDeleteShader(vertexShader);
	GL20.glDeleteShader(fragmentShader);

	String log = GL20.glGetProgramInfoLog(program);
	if(debugOutput != null && !log.isEmpty()) System.out.print("info log of " + name + "=====\n" + log + "==== end\n");

	if(GL20.glGetProgrami(program, GL20.GL_LINK_STATUS) == 0) {

		GL20.glDeleteProgram(program);
		throw new Error("Could not link " + name);
	}

	for(int i = 0;i != ufs.length;i++) {
		int uf = GL20.glGetUniformLocation(program, uniform_names[i]);
		ufs[i] = uf;
	}
	shaders.add(this);
}
 
Example 11
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glDeleteProgram(int program) {
	GL20.glDeleteProgram(program);
}