private static int createShader(String shaderCode,int shaderType) throws Exception {
  int shader=0;
  try {
    shader=OpenGlHelper.glCreateShader(shaderType);
    if (shader == 0) {
      return 0;
    }
    byte[] shaderCodeBytes=shaderCode.getBytes();
    ByteBuffer shaderCodeByteBuffer=BufferUtils.createByteBuffer(shaderCodeBytes.length);
    shaderCodeByteBuffer.put(shaderCodeBytes);
    shaderCodeByteBuffer.position(0);
    OpenGlHelper.glShaderSource(shader,shaderCodeByteBuffer);
    OpenGlHelper.glCompileShader(shader);
    if (OpenGlHelper.glGetShaderi(shader,ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) {
      String shaderTypeName=shaderType == ARBVertexShader.GL_VERTEX_SHADER_ARB ? "vertex" : shaderType == ARBFragmentShader.GL_FRAGMENT_SHADER_ARB ? "fragment" : "";
      throw new RuntimeException("Error creating " + shaderTypeName + " shader: "+ getLogInfoShader(shader));
    }
    return shader;
  }
 catch (  Exception exc) {
    OpenGlHelper.glDeleteShader(shader);
    throw exc;
  }
}

private static int createShader ( String shaderCode , int shaderType ) throws Exception { int shader = 0 ; try { shader = OpenGlHelper . glCreateShader ( shaderType ) ; if ( shader == 0 ) { return 0 ; } byte [ ] shaderCodeBytes = shaderCode . getBytes ( ) ; ByteBuffer shaderCodeByteBuffer = BufferUtils . createByteBuffer ( shaderCodeBytes . length ) ; shaderCodeByteBuffer . put ( shaderCodeBytes ) ; shaderCodeByteBuffer . position ( 0 ) ; OpenGlHelper . glShaderSource ( shader , shaderCodeByteBuffer ) ; OpenGlHelper . glCompileShader ( shader ) ; if ( OpenGlHelper . glGetShaderi ( shader , ARBShaderObjects . GL_OBJECT_COMPILE_STATUS_ARB ) == GL11 . GL_FALSE ) { String shaderTypeName = shaderType == ARBVertexShader . GL_VERTEX_SHADER_ARB ? "vertex" : shaderType == ARBFragmentShader . GL_FRAGMENT_SHADER_ARB ? "fragment" : "" ; throw new RuntimeException ( "Error creating " + shaderTypeName + " shader: " + getLogInfoShader ( shader ) ) ; } return shader ; } catch ( Exception exc ) { OpenGlHelper . glDeleteShader ( shader ) ; throw exc ; } }
compiles and creates a shader from the shader code .
