Пример #1
0
  public void link() {
    for (Shader s : shaders) {
      if (null != s && s.shader == -1) {
        s.compile();
      }
    }
    int newProgram = linkProgram(shaders);
    if (program != -1) {
      glDeleteProgram(program);
      program = -1;
    }
    this.uniforms.clear();
    this.attributes.clear();
    program = newProgram;
    if (program == -1) {
      throw new IllegalStateException("Link failure");
    }
    int count = glGetProgrami(program, GL_ACTIVE_UNIFORMS);
    for (int i = 0; i < count; ++i) {
      String name = glGetActiveUniform(program, i, 256);
      int location = glGetUniformLocation(program, name);
      this.uniforms.put(name, location);
    }

    count = glGetProgrami(program, GL_ACTIVE_ATTRIBUTES);
    for (int i = 0; i < count; ++i) {
      String name = glGetActiveAttrib(program, i, 256);
      int location = glGetAttribLocation(program, name);
      this.attributes.put(name, location);
    }
  }