Example #1
0
  public static WebGLProgram createAndUseProgram(
      List<WebGLShader> shaders, WebGLRenderingContext ctx) {
    WebGLProgram program = ctx.createProgram();

    for (WebGLShader s : shaders) ctx.attachShader(program, s);

    ctx.linkProgram(program);
    if (ctx.getProgramParameter(program, WebGLRenderingContext.LINK_STATUS).getBoolean()) {
      ctx.useProgram(program);
      return program;
    }
    // else error
    String lastError = ctx.getProgramInfoLog(program);
    Window.alert("*** Error compiling program '" + program + "':" + lastError);
    ctx.deleteProgram(program);
    return null;
  }