Java Code Examples for android.opengl.GLES20#glDetachShader()

The following examples show how to use android.opengl.GLES20#glDetachShader() . 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: RRGLProgram.java    From RedReader with GNU General Public License v3.0 6 votes vote down vote up
private void link() {

		if(mFragmentShaderHandle == null || mVertexShaderHandle == null) throw new RuntimeException();

		GLES20.glLinkProgram(mHandle);

		final int[] linkStatus = new int[1];
		GLES20.glGetProgramiv(mHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);

		if(linkStatus[0] == 0) {
			final String log = GLES20.glGetProgramInfoLog(mHandle);
			GLES20.glDeleteProgram(mHandle);
			throw new RuntimeException(String.format(Locale.US, "Linker error: \"%s\".", log));
		}

		GLES20.glDetachShader(mHandle, mFragmentShaderHandle);
		GLES20.glDetachShader(mHandle, mVertexShaderHandle);

		GLES20.glDeleteShader(mFragmentShaderHandle);
		GLES20.glDeleteShader(mVertexShaderHandle);

		mFragmentShaderHandle = null;
		mVertexShaderHandle = null;
	}
 
Example 2
Source File: Program.java    From HokoBlur with Apache License 2.0 5 votes vote down vote up
@Override
    public void create(String vertexShaderCode, String fragmentShaderCode) {

        int vertexShader = 0;
        int fragmentShader = 0;
        try {
            vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
            fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);

            if (vertexShader == 0 || fragmentShader == 0) {
                return;
            }

            id = GLES20.glCreateProgram();
            if (id != 0) {
                GLES20.glAttachShader(id, vertexShader);
                GLES20.glAttachShader(id, fragmentShader);
                GLES20.glLinkProgram(id);
                checkGLError("Attach Shader");
                final int[] linkStatus = new int[1];
                GLES20.glGetProgramiv(id, GLES20.GL_LINK_STATUS, linkStatus, 0);
                if (linkStatus[0] != 1) {
                    Log.e(TAG, "Failed to link program");
                    GLES20.glDeleteProgram(id);
                    id = 0;
                }
//
            }
        } finally {
            GLES20.glDetachShader(id, vertexShader);
            GLES20.glDetachShader(id, fragmentShader);
            GLES20.glDeleteShader(vertexShader);
            GLES20.glDeleteShader(fragmentShader);
        }
    }
 
Example 3
Source File: OGLESShaderRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void deleteShader(Shader shader) {
        if (shader.getId() == -1) {
            logger.warning("Shader is not uploaded to GPU, cannot delete.");
            return;
        }
        for (ShaderSource source : shader.getSources()) {
            if (source.getId() != -1) {

                if (verboseLogging) {
                    logger.info("GLES20.glDetachShader(" + shader.getId() + ", " + source.getId() + ")");
                }

                GLES20.glDetachShader(shader.getId(), source.getId());
                // the next part is done by the GLObjectManager automatically
//                glDeleteShader(source.getId());
            }
        }
        // kill all references so sources can be collected
        // if needed.
        shader.resetSources();

        if (verboseLogging) {
            logger.info("GLES20.glDeleteProgram(" + shader.getId() + ")");
        }

        GLES20.glDeleteProgram(shader.getId());

        statistics.onDeleteShader();
    }
 
Example 4
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void detachShader(int program, int shader) {
    GLES20.glDetachShader(program, shader);
}