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

The following examples show how to use org.lwjgl.opengl.GL20#glDeleteShader() . 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: ShaderProgram.java    From LowPolyWater with The Unlicense 6 votes vote down vote up
public ShaderProgram(MyFile vertexFile, MyFile geometryFile, MyFile fragmentFile, String... inVariables) {
	int vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
	int geometryShaderID = loadShader(geometryFile, GL32.GL_GEOMETRY_SHADER);
	int fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
	programID = GL20.glCreateProgram();
	GL20.glAttachShader(programID, vertexShaderID);
	GL20.glAttachShader(programID, geometryShaderID);
	GL20.glAttachShader(programID, fragmentShaderID);
	bindAttributes(inVariables);
	GL20.glLinkProgram(programID);
	GL20.glDetachShader(programID, vertexShaderID);
	GL20.glDetachShader(programID, geometryShaderID);
	GL20.glDetachShader(programID, fragmentShaderID);
	GL20.glDeleteShader(vertexShaderID);
	GL20.glDeleteShader(geometryShaderID);
	GL20.glDeleteShader(fragmentShaderID);
}
 
Example 2
Source File: GLShader.java    From ldparteditor with MIT License 6 votes vote down vote up
public GLShader(final String vertexPath, final String fragmentPath) {
    final int vertex = createAndCompile(vertexPath, GL20.GL_VERTEX_SHADER);
    final int fragment = createAndCompile(fragmentPath, GL20.GL_FRAGMENT_SHADER);

    program = GL20.glCreateProgram();
    GL20.glAttachShader(program, fragment);
    GL20.glAttachShader(program, vertex);

    GL20.glLinkProgram(program);

    // FIXME Extract parameter locations
    // int baseImageLoc = GL20.glGetUniformLocation(program, "colorMap"); //$NON-NLS-1$

    if (GL20.glGetProgrami(program, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) {
        NLogger.error(GLShader.class, "Could not link shader: " + GL20.glGetProgramInfoLog(program, 1024)); //$NON-NLS-1$;
    }

    GL20.glDetachShader(program, fragment);
    GL20.glDetachShader(program, vertex);
    GL20.glDeleteShader(fragment);
    GL20.glDeleteShader(vertex);
}
 
Example 3
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 4
Source File: ShaderProgram.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
public ShaderProgram(MyFile vertexFile, MyFile fragmentFile, String... inVariables) {
	int vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
	int fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
	programID = GL20.glCreateProgram();
	GL20.glAttachShader(programID, vertexShaderID);
	GL20.glAttachShader(programID, fragmentShaderID);
	bindAttributes(inVariables);
	GL20.glLinkProgram(programID);
	GL20.glDetachShader(programID, vertexShaderID);
	GL20.glDetachShader(programID, fragmentShaderID);
	GL20.glDeleteShader(vertexShaderID);
	GL20.glDeleteShader(fragmentShaderID);
}
 
Example 5
Source File: ShaderProgram.java    From OpenGL-Animation with The Unlicense 5 votes vote down vote up
public ShaderProgram(MyFile vertexFile, MyFile fragmentFile, String... inVariables) {
	int vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
	int fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
	programID = GL20.glCreateProgram();
	GL20.glAttachShader(programID, vertexShaderID);
	GL20.glAttachShader(programID, fragmentShaderID);
	bindAttributes(inVariables);
	GL20.glLinkProgram(programID);
	GL20.glDetachShader(programID, vertexShaderID);
	GL20.glDetachShader(programID, fragmentShaderID);
	GL20.glDeleteShader(vertexShaderID);
	GL20.glDeleteShader(fragmentShaderID);
}
 
Example 6
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 7
Source File: LWJGL20DrawContext.java    From settlers-remake with MIT License 5 votes vote down vote up
private int createShader(String name, int type) throws IOException {
	int shader = GL20.glCreateShader(type);
	setObjectLabel(KHRDebug.GL_SHADER, shader, name);

	BufferedReader is = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/"+name)));
	StringBuilder source = new StringBuilder();
	String line;

	while((line = is.readLine()) != null) {
		source.append(line).append("\n");
	}

	GL20.glShaderSource(shader, source);
	GL20.glCompileShader(shader);


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

	if(GL20.glGetShaderi(shader, GL20.GL_COMPILE_STATUS) == 0) {

		GL20.glDeleteShader(shader);
		throw new Error("Could not compile " + name);
	}

	return shader;
}
 
Example 8
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 9
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 10
Source File: ShaderHelper.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void glDeleteShader(int shader) {
	GL20.glDeleteShader(shader);
}