-
-
Save appspell/94c08d4f878ab11d9bd4eb12def6af24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onSurfaceCreated(gl: GL10?, config: EGLConfig?) { | |
// create shader program from the source code | |
createProgram(vertexShaderSource, fragmentShaderSource) | |
// bind vector shader attributes | |
inPositionHandle = GLES20.glGetAttribLocation(program, VERTEX_SHADER_IN_POSITION) | |
checkGlError("glGetAttribLocation $VERTEX_SHADER_IN_POSITION") | |
if (inPositionHandle == UNKNOWN_ATTRIBUTE) throw RuntimeException("Could not get attrib location for $VERTEX_SHADER_IN_POSITION") | |
inTextureHandle = GLES20.glGetAttribLocation(program, VERTEX_SHADER_IN_TEXTURE_COORD) | |
checkGlError("glGetAttribLocation $VERTEX_SHADER_IN_TEXTURE_COORD") | |
if (inTextureHandle == UNKNOWN_ATTRIBUTE) throw RuntimeException("Could not get attrib location for $VERTEX_SHADER_IN_TEXTURE_COORD") | |
uMVPMatrixHandle = GLES20.glGetUniformLocation(program, VERTEX_SHADER_UNIFORM_MATRIX_MVP) | |
checkGlError("glGetUniformLocation $VERTEX_SHADER_UNIFORM_MATRIX_MVP") | |
if (uMVPMatrixHandle == UNKNOWN_ATTRIBUTE) throw RuntimeException("Could not get uniform location for $VERTEX_SHADER_UNIFORM_MATRIX_MVP") | |
uSTMatrixHandle = GLES20.glGetUniformLocation(program, VERTEX_SHADER_UNIFORM_MATRIX_STM) | |
checkGlError("glGetUniformLocation $VERTEX_SHADER_UNIFORM_MATRIX_STM") | |
if (uSTMatrixHandle == UNKNOWN_ATTRIBUTE) throw RuntimeException("Could not get uniform location for $VERTEX_SHADER_UNIFORM_MATRIX_STM") | |
// (!) bind attributes for fragment shader | |
uMyUniform = GLES30.glGetUniformLocation(program, FRAGMENT_SHADER_UNIFORM_MY_UNIFORM) | |
checkGlError("glGetUniformLocation $FRAGMENT_SHADER_UNIFORM_MY_UNIFORM") | |
if (uMyUniform == UNKNOWN_ATTRIBUTE) throw RuntimeException("Could not get uniform location for $FRAGMENT_SHADER_UNIFORM_MY_UNIFORM") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment