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

The following examples show how to use android.opengl.GLES20#glBindAttribLocation() . 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: PositionTextureCoordinatesUniformColorShaderProgram.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
protected void link(final GLState pGLState) throws ShaderProgramLinkException {
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES_LOCATION, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES);

	super.link(pGLState);

	PositionTextureCoordinatesUniformColorShaderProgram.sUniformModelViewPositionMatrixLocation = this.getUniformLocation(ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX);
	PositionTextureCoordinatesUniformColorShaderProgram.sUniformTexture0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_0);
	PositionTextureCoordinatesUniformColorShaderProgram.sUniformColorLocation = this.getUniformLocation(ShaderProgramConstants.UNIFORM_COLOR);
}
 
Example 2
Source File: PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
protected void link(final GLState pGLState) throws ShaderProgramLinkException {
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_0_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION_0);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_1_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION_1);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES_LOCATION, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES);

	super.link(pGLState);

	PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformModelViewPositionMatrixLocation = this.getUniformLocation(ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX);
	PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformTexture0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_0);
	PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformTexture1Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_1);
	PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformTextureSelectTexture0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURESELECT_TEXTURE_0);
	PositionTextureCoordinatesPositionInterpolationTextureSelectShaderProgram.sUniformPositionInterpolationMix0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_POSITION_INTERPOLATION_MIX_0);
}
 
Example 3
Source File: FeatureShader.java    From geoar-app with Apache License 2.0 5 votes vote down vote up
private void linkProgram(final String[] attributes) {
	if (programHandle <= 0) {
		throw new IllegalStateException("Invalid program handle");
	}
	if (vertexShaderHandle <= 0) {
		throw new IllegalStateException("Invalid vertex shader handle");
	}
	if (fragmentShaderHandle <= 0) {
		throw new IllegalStateException("Invalid fragment shader handle");
	}
	if (programHandle != 0) {
		GLES20.glAttachShader(programHandle, vertexShaderHandle);
		GLES20.glAttachShader(programHandle, fragmentShaderHandle);

		GLES20.glBindAttribLocation(programHandle, 0, ATTRIBUTE_POSITION);
		// GLES20.glBindAttribLocation(programHandle, 1, ATTRIBUTE_COLOR);
		GLES20.glBindAttribLocation(programHandle, 1, ATTRIBUTE_NORMAL);
		// GLES20.glBindAttribLocation(programHandle, 3, ATTRIBUTE_TEXTURE);
		// if (attributes != null) {
		// for (int i = 0, size = attributes.length; i < size; i++)
		// GLES20.glBindAttribLocation(programHandle, i+1, attributes[i]);
		// }

		GLES20.glLinkProgram(programHandle);

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

		if (status[0] == 0) {
			LOG.error("Error compiling program: "
					+ GLES20.glGetProgramInfoLog(programHandle));
			// GLES20.glDeleteProgram(programHandle);
			// programHandle = 0;
		}
	} else {
		throw new RuntimeException("Error creating Program.");
	}
}
 
Example 4
Source File: PositionColorShaderProgram.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
protected void link(final GLState pGLState) throws ShaderProgramLinkException {
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_COLOR_LOCATION, ShaderProgramConstants.ATTRIBUTE_COLOR);

	super.link(pGLState);

	PositionColorShaderProgram.sUniformModelViewPositionMatrixLocation = this.getUniformLocation(ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX);
}
 
Example 5
Source File: PositionTextureCoordinatesShaderProgram.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
@Override
protected void link(final GLState pGLState) throws ShaderProgramLinkException {
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES_LOCATION, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES);

	super.link(pGLState);

	PositionTextureCoordinatesShaderProgram.sUniformModelViewPositionMatrixLocation = this.getUniformLocation(ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX);
	PositionTextureCoordinatesShaderProgram.sUniformTexture0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_0);
}
 
Example 6
Source File: PositionColorTextureCoordinatesShaderProgram.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
protected void link(final GLState pGLState) throws ShaderProgramLinkException {
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_COLOR_LOCATION, ShaderProgramConstants.ATTRIBUTE_COLOR);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES_LOCATION, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES);

	super.link(pGLState);

	PositionColorTextureCoordinatesShaderProgram.sUniformModelViewPositionMatrixLocation = this.getUniformLocation(ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX);
	PositionColorTextureCoordinatesShaderProgram.sUniformTexture0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_0);
}
 
Example 7
Source File: PositionTextureCoordinatesTextureSelectShaderProgram.java    From tilt-game-android with MIT License 5 votes vote down vote up
@Override
protected void link(final GLState pGLState) throws ShaderProgramLinkException {
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_POSITION_LOCATION, ShaderProgramConstants.ATTRIBUTE_POSITION);
	GLES20.glBindAttribLocation(this.mProgramID, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES_LOCATION, ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES);

	super.link(pGLState);

	PositionTextureCoordinatesTextureSelectShaderProgram.sUniformModelViewPositionMatrixLocation = this.getUniformLocation(ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX);
	PositionTextureCoordinatesTextureSelectShaderProgram.sUniformTexture0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_0);
	PositionTextureCoordinatesTextureSelectShaderProgram.sUniformTexture1Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURE_1);
	PositionTextureCoordinatesTextureSelectShaderProgram.sUniformTextureSelectTexture0Location = this.getUniformLocation(ShaderProgramConstants.UNIFORM_TEXTURESELECT_TEXTURE_0);
}
 
Example 8
Source File: GLUtil.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Helper function to compile and link a program.
 *
 * @param vertexShaderHandle   An OpenGL handle to an already-compiled vertex shader.
 * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
 * @param attributes           Attributes that need to be bound to the program.
 * @return An OpenGL handle to the program.
 */
public static int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes) {
    int programHandle = GLES20.glCreateProgram();

    if (programHandle != 0) {
        // Bind the vertex shader to the program.
        GLES20.glAttachShader(programHandle, vertexShaderHandle);

        // Bind the fragment shader to the program.
        GLES20.glAttachShader(programHandle, fragmentShaderHandle);

        // Bind attributes
        if (attributes != null) {
            final int size = attributes.length;
            for (int i = 0; i < size; i++) {
                GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
            }
        }

        // Link the two shaders together into a program.
        GLES20.glLinkProgram(programHandle);

        // Get the link status.
        final int[] linkStatus = new int[1];
        GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);

        // If the link failed, delete the program.
        if (linkStatus[0] == 0) {
            Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));
            GLES20.glDeleteProgram(programHandle);
            programHandle = 0;
        }
    }

    if (programHandle == 0) {
        throw new RuntimeException("Error creating program.");
    }

    return programHandle;
}
 
Example 9
Source File: ShaderHelper.java    From secureit with MIT License 4 votes vote down vote up
/**
 * Helper function to compile and link a program.
 * 
 * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.
 * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
 * @param attributes Attributes that need to be bound to the program.
 * @return An OpenGL handle to the program.
 */
public static int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes) 
{
	int programHandle = GLES20.glCreateProgram();
	
	if (programHandle != 0) 
	{
		// Bind the vertex shader to the program.
		GLES20.glAttachShader(programHandle, vertexShaderHandle);			

		// Bind the fragment shader to the program.
		GLES20.glAttachShader(programHandle, fragmentShaderHandle);
		
		// Bind attributes
		if (attributes != null)
		{
			final int size = attributes.length;
			for (int i = 0; i < size; i++)
			{
				GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
			}						
		}
		
		// Link the two shaders together into a program.
		GLES20.glLinkProgram(programHandle);

		// Get the link status.
		final int[] linkStatus = new int[1];
		GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);

		// If the link failed, delete the program.
		if (linkStatus[0] == 0) 
		{				
			Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));
			GLES20.glDeleteProgram(programHandle);
			programHandle = 0;
		}
	}
	
	if (programHandle == 0)
	{
		throw new RuntimeException("Error creating program.");
	}
	
	return programHandle;
}
 
Example 10
Source File: ShaderHelper.java    From StarWars.Android with MIT License 4 votes vote down vote up
/**
 * Helper function to compile and link a program.
 * 
 * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.
 * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
 * @param attributes Attributes that need to be bound to the program.
 * @return An OpenGL handle to the program.
 */
public static int createAndLinkProgram(final int vertexShaderHandle,
                                          final int fragmentShaderHandle,
                                          final String[] attributes) {

	int programHandle = GLES20.glCreateProgram();
	
	if (programHandle != 0) {
		// Bind the vertex shader to the program.
		GLES20.glAttachShader(programHandle, vertexShaderHandle);

		// Bind the fragment shader to the program.
		GLES20.glAttachShader(programHandle, fragmentShaderHandle);
		
		// Bind attributes
		if (attributes != null) {
			final int size = attributes.length;
			for (int i = 0; i < size; i++) {
				GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
			}						
		}
		
		// Link the two shaders together into a program.
		GLES20.glLinkProgram(programHandle);

		// Get the link status.
		final int[] linkStatus = new int[1];
		GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);

		// If the link failed, delete the program.
		if (linkStatus[0] == 0) {
			Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));
			GLES20.glDeleteProgram(programHandle);
			programHandle = 0;
		}
	}
	
	if (programHandle == 0) {
		throw new RuntimeException("Error creating program.");
	}
	
	return programHandle;
}
 
Example 11
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void bindAttribLocation(int program, int index, String name) {
    GLES20.glBindAttribLocation(program, index, name);
}
 
Example 12
Source File: Shader.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public Shader(String vertexShader, String fragmentShader, String attributes[], String uniforms[]) {
    this.program = GLES20.glCreateProgram();

    CompilationResult vResult = compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
    if (vResult.status == GLES20.GL_FALSE) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Vertex shader compilation failed");
        }
        destroyShader(vResult.shader, 0, program);
        return;
    }

    CompilationResult fResult = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);
    if (fResult.status == GLES20.GL_FALSE) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Fragment shader compilation failed");
        }
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    GLES20.glAttachShader(program, vResult.shader);
    GLES20.glAttachShader(program, fResult.shader);

    for (int i = 0; i < attributes.length; i++) {
        GLES20.glBindAttribLocation(program, i, attributes[i]);
    }

    if (linkProgram(program) == GLES20.GL_FALSE) {
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    for (String uniform : uniforms) {
        uniformsMap.put(uniform, GLES20.glGetUniformLocation(program, uniform));
    }

    if (vResult.shader != 0) {
        GLES20.glDeleteShader(vResult.shader);
    }

    if (fResult.shader != 0) {
        GLES20.glDeleteShader(fResult.shader);
    }
}
 
Example 13
Source File: Shader.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public Shader(String vertexShader, String fragmentShader, String[] attributes, String[] uniforms) {
    this.program = GLES20.glCreateProgram();

    CompilationResult vResult = compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
    if (vResult.status == GLES20.GL_FALSE) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Vertex shader compilation failed");
        }
        destroyShader(vResult.shader, 0, program);
        return;
    }

    CompilationResult fResult = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);
    if (fResult.status == GLES20.GL_FALSE) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Fragment shader compilation failed");
        }
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    GLES20.glAttachShader(program, vResult.shader);
    GLES20.glAttachShader(program, fResult.shader);

    for (int i = 0; i < attributes.length; i++) {
        GLES20.glBindAttribLocation(program, i, attributes[i]);
    }

    if (linkProgram(program) == GLES20.GL_FALSE) {
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    for (String uniform : uniforms) {
        uniformsMap.put(uniform, GLES20.glGetUniformLocation(program, uniform));
    }

    if (vResult.shader != 0) {
        GLES20.glDeleteShader(vResult.shader);
    }

    if (fResult.shader != 0) {
        GLES20.glDeleteShader(fResult.shader);
    }
}
 
Example 14
Source File: ShaderHelper.java    From ShapesInOpenGLES2.0 with MIT License 4 votes vote down vote up
/**
 * Helper function to compile and link a program.
 * 
 * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.
 * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
 * @param attributes Attributes that need to be bound to the program.
 * @return An OpenGL handle to the program.
 */
public static int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes) 
{
	int programHandle = GLES20.glCreateProgram();
	
	if (programHandle != 0) 
	{
		// Bind the vertex shader to the program.
		GLES20.glAttachShader(programHandle, vertexShaderHandle);			

		// Bind the fragment shader to the program.
		GLES20.glAttachShader(programHandle, fragmentShaderHandle);
		
		// Bind attributes
		if (attributes != null)
		{
			final int size = attributes.length;
			for (int i = 0; i < size; i++)
			{
				GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
			}						
		}
		
		// Link the two shaders together into a program.
		GLES20.glLinkProgram(programHandle);

		// Get the link status.
		final int[] linkStatus = new int[1];
		GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);

		// If the link failed, delete the program.
		if (linkStatus[0] == 0) 
		{				
			Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));
			GLES20.glDeleteProgram(programHandle);
			programHandle = 0;
		}
	}
	
	if (programHandle == 0)
	{
		throw new RuntimeException("Error creating program.");
	}
	
	return programHandle;
}
 
Example 15
Source File: Cube.java    From augmentedreality with Apache License 2.0 4 votes vote down vote up
public Cube() {
    //first setup the mVertices correctly.
    mVertices = ByteBuffer
            .allocateDirect(mVerticesData.length * 4)
            .order(ByteOrder.nativeOrder())
            .asFloatBuffer()
            .put(mVerticesData);
    mVertices.position(0);

    //setup the shaders
    int vertexShader;
    int fragmentShader;
    int programObject;
    int[] linked = new int[1];

    // Load the vertex/fragment shaders
    vertexShader = ShaderUtil.LoadShader(GLES20.GL_VERTEX_SHADER, vShaderStr);
    fragmentShader = ShaderUtil.LoadShader(GLES20.GL_FRAGMENT_SHADER, fShaderStr);

    // Create the program object
    programObject = GLES20.glCreateProgram();

    if (programObject == 0) {
        Log.e(TAG, "So some kind of error, but what?");
        return;
    }

    GLES20.glAttachShader(programObject, vertexShader);
    GLES20.glAttachShader(programObject, fragmentShader);

    // Bind vPosition to attribute 0
    GLES20.glBindAttribLocation(programObject, 0, "vPosition");

    // Link the program
    GLES20.glLinkProgram(programObject);

    // Check the link status
    GLES20.glGetProgramiv(programObject, GLES20.GL_LINK_STATUS, linked, 0);

    if (linked[0] == 0) {
        Log.e(TAG, "Error linking program:");
        Log.e(TAG, GLES20.glGetProgramInfoLog(programObject));
        GLES20.glDeleteProgram(programObject);
        return;
    }

    // Store the program object
    mProgramObject = programObject;

    //now everything is setup and ready to draw.
    Matrix.setIdentityM(modelMatrix, 0);
}
 
Example 16
Source File: GLES20DrawContext.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", GLES20.GL_VERTEX_SHADER);
		fragmentShader = createShader(name+".frag", GLES20.GL_FRAGMENT_SHADER);
	} catch (IOException e) {
		e.printStackTrace();

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

	program = GLES20.glCreateProgram();

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

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

	GLES20.glLinkProgram(program);
	GLES20.glValidateProgram(program);

	//GLES20.glDetachShader(program, vertexShader);
	//GLES20.glDetachShader(program, fragmentShader);
	GLES20.glDeleteShader(vertexShader);
	GLES20.glDeleteShader(fragmentShader);

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

	int[] link_status = new int[1];
	GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, link_status, 0);
	if(link_status[0] == 0) {
		GLES20.glDeleteProgram(program);
		throw new Error("Could not link " + name);
	}

	for(int i = 0;i != ufs.length;i++) {
		int uf = GLES20.glGetUniformLocation(program, uniform_names[i]);
		ufs[i] = uf;
	}
	shaders.add(this);
}
 
Example 17
Source File: Shader.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public Shader(String vertexShader, String fragmentShader, String[] attributes, String[] uniforms) {
    this.program = GLES20.glCreateProgram();

    CompilationResult vResult = compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
    if (vResult.status == GLES20.GL_FALSE) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Vertex shader compilation failed");
        }
        destroyShader(vResult.shader, 0, program);
        return;
    }

    CompilationResult fResult = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);
    if (fResult.status == GLES20.GL_FALSE) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.e("Fragment shader compilation failed");
        }
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    GLES20.glAttachShader(program, vResult.shader);
    GLES20.glAttachShader(program, fResult.shader);

    for (int i = 0; i < attributes.length; i++) {
        GLES20.glBindAttribLocation(program, i, attributes[i]);
    }

    if (linkProgram(program) == GLES20.GL_FALSE) {
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    for (String uniform : uniforms) {
        uniformsMap.put(uniform, GLES20.glGetUniformLocation(program, uniform));
    }

    if (vResult.shader != 0) {
        GLES20.glDeleteShader(vResult.shader);
    }

    if (fResult.shader != 0) {
        GLES20.glDeleteShader(fResult.shader);
    }
}
 
Example 18
Source File: GLRenderer.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
protected void bindShaderAttributes() {
		GLES20.glBindAttribLocation(programHandle, 0, ATTRIBUTE_POSITION);
		GLES20.glBindAttribLocation(programHandle, 1, ATTRIBUTE_TEXCOORD);
	} 
Example 19
Source File: GLRenderer.java    From UltimateAndroid with Apache License 2.0 votes vote down vote up
protected void bindShaderAttributes() {
		GLES20.glBindAttribLocation(programHandle, 0, ATTRIBUTE_POSITION);
		GLES20.glBindAttribLocation(programHandle, 1, ATTRIBUTE_TEXCOORD);
	} 
Example 20
Source File: GLRenderer.java    From AndroidFastImageProcessing with MIT License votes vote down vote up
protected void bindShaderAttributes() {
		GLES20.glBindAttribLocation(programHandle, 0, ATTRIBUTE_POSITION);
		GLES20.glBindAttribLocation(programHandle, 1, ATTRIBUTE_TEXCOORD);
	}