public static int createProgram ( String vertexSource , String fragmentSource ) { int vertexShader = loadShader ( GLES20 . GL_VERTEX_SHADER , vertexSource ) ; if ( vertexShader == 0 ) { return 0 ; } int pixelShader = loadShader ( GLES20 . GL_FRAGMENT_SHADER , fragmentSource ) ; if ( pixelShader == 0 ) { return 0 ; } int program = GLES20 . glCreateProgram ( ) ; checkGlError ( "glCreateProgram" ) ; if ( program == 0 ) { Log . e ( TAG , "Could not create program" ) ; } GLES20 . glAttachShader ( program , vertexShader ) ; checkGlError ( "glAttachShader" ) ; GLES20 . glAttachShader ( program , pixelShader ) ; checkGlError ( "glAttachShader" ) ; GLES20 . glLinkProgram ( program ) ; int [ ] linkStatus = new int [ 1 ] ; GLES20 . glGetProgramiv ( program , GLES20 . GL_LINK_STATUS , linkStatus , 0 ) ; if ( linkStatus [ 0 ] != GLES20 . GL_TRUE ) { Log . e ( TAG , "Could not link program: " ) ; Log . e ( TAG , GLES20 . glGetProgramInfoLog ( program ) ) ; GLES20 . glDeleteProgram ( program ) ; program = 0 ; } return program ; }
Creates a new program from the supplied vertex and fragment shaders .