Java Code Examples for android.opengl.GLES30#glGetAttribLocation()

The following examples show how to use android.opengl.GLES30#glGetAttribLocation() . 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: GLDrawer2DES3.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * シェーダープログラム変更時の初期化処理
 * glUseProgramが呼ばれた状態で返る
 */
@Override
protected void init() {
	if (DEBUG) Log.v(TAG, "init:");
	GLES30.glUseProgram(hProgram);
	maPositionLoc = GLES30.glGetAttribLocation(hProgram, "aPosition");
	maTextureCoordLoc = GLES30.glGetAttribLocation(hProgram, "aTextureCoord");
	muMVPMatrixLoc = GLES30.glGetUniformLocation(hProgram, "uMVPMatrix");
	muTexMatrixLoc = GLES30.glGetUniformLocation(hProgram, "uTexMatrix");
	//
	GLES30.glUniformMatrix4fv(muMVPMatrixLoc,
		1, false, mMvpMatrix, 0);
	GLES30.glUniformMatrix4fv(muTexMatrixLoc,
		1, false, mMvpMatrix, 0);
	updateVertices();
}
 
Example 2
Source File: Square.java    From opengl with Apache License 2.0 5 votes vote down vote up
/**
 * Encapsulates the OpenGL ES instructions for drawing this shape.
 *
 * @param mvpMatrix - The Model View Project matrix in which to draw
 * this shape.
 */
public void draw(float[] mvpMatrix) {
    // Add program to OpenGL environment
    GLES30.glUseProgram(mProgram);

    // get handle to vertex shader's vPosition member
    mPositionHandle = GLES30.glGetAttribLocation(mProgram, "vPosition");

    // Enable a handle to the triangle vertices
    GLES30.glEnableVertexAttribArray(mPositionHandle);

    // Prepare the triangle coordinate data
    GLES30.glVertexAttribPointer(
            mPositionHandle, COORDS_PER_VERTEX,
            GLES30.GL_FLOAT, false,
            vertexStride, vertexBuffer);

    // get handle to fragment shader's vColor member
    mColorHandle = GLES30.glGetUniformLocation(mProgram, "vColor");

    // Set color for drawing the triangle
    GLES30.glUniform4fv(mColorHandle, 1, color, 0);

    // get handle to shape's transformation matrix
    mMVPMatrixHandle = GLES30.glGetUniformLocation(mProgram, "uMVPMatrix");
    MyGLRenderer.checkGlError("glGetUniformLocation");

    // Apply the projection and view transformation
    GLES30.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
    MyGLRenderer.checkGlError("glUniformMatrix4fv");

    // Draw the square
    GLES30.glDrawElements(
            GLES30.GL_TRIANGLES, drawOrder.length,
            GLES30.GL_UNSIGNED_SHORT, drawListBuffer);

    // Disable vertex array
    GLES30.glDisableVertexAttribArray(mPositionHandle);
}
 
Example 3
Source File: Triangle.java    From opengl with Apache License 2.0 5 votes vote down vote up
/**
 * Encapsulates the OpenGL ES instructions for drawing this shape.
 *
 * @param mvpMatrix - The Model View Project matrix in which to draw
 * this shape.
 */
public void draw(float[] mvpMatrix) {
    // Add program to OpenGL environment
    GLES30.glUseProgram(mProgram);

    // get handle to vertex shader's vPosition member
    mPositionHandle = GLES30.glGetAttribLocation(mProgram, "vPosition");

    // Enable a handle to the triangle vertices
    GLES30.glEnableVertexAttribArray(mPositionHandle);

    // Prepare the triangle coordinate data
    GLES30.glVertexAttribPointer(
            mPositionHandle, COORDS_PER_VERTEX,
            GLES30.GL_FLOAT, false,
            vertexStride, vertexBuffer);

    // get handle to fragment shader's vColor member
    mColorHandle = GLES30.glGetUniformLocation(mProgram, "vColor");

    // Set color for drawing the triangle
    GLES30.glUniform4fv(mColorHandle, 1, color, 0);

    // get handle to shape's transformation matrix
    mMVPMatrixHandle = GLES30.glGetUniformLocation(mProgram, "uMVPMatrix");
    MyGLRenderer.checkGlError("glGetUniformLocation");

    // Apply the projection and view transformation
    GLES30.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
    MyGLRenderer.checkGlError("glUniformMatrix4fv");

    // Draw the triangle
    GLES30.glDrawArrays(GLES30.GL_TRIANGLES, 0, vertexCount);

    // Disable vertex array
    GLES30.glDisableVertexAttribArray(mPositionHandle);
}
 
Example 4
Source File: GLDrawer2DES3.java    From libcommon with Apache License 2.0 2 votes vote down vote up
/**
 * アトリビュート変数のロケーションを取得
 * glUseProgramが呼ばれた状態で返る
 * IShaderDrawer2dの実装
 * @param name
 * @return
 */
@Override
public int glGetAttribLocation(@NonNull final String name) {
	GLES30.glUseProgram(hProgram);
	return GLES30.glGetAttribLocation(hProgram, name);
}