/** * Creates, Compiles, links and validates the given shader source. * * @param gl * to be link against * @param GL_SHADER_ID * either {@link GL#GL_VERTEX_SHADER} or {@link GL#GL_FRAGMENT_SHADER} * @param shaderSource * to be used * @return the id of the shader program and the id of teh shader. */ private int compileShader( GL gl, int GL_SHADER_ID, String shaderSource ) throws RuntimeException { if ( oglProgramId == -1 ) { oglProgramId = gl.glCreateProgram(); } int shaderId = -1; try { shaderId = compileShaderProgram( gl, GL_SHADER_ID, shaderSource ); } catch ( RuntimeException r ) { LOG.error( "Could not compile " + ( ( GL.GL_VERTEX_SHADER == GL_SHADER_ID ) ? "vertex" : "fragment" ) + " shader from source: \n" + shaderSource + " \nbecause: " + r.getLocalizedMessage(), r ); throw ( r ); } return shaderId; }