Пример #1
1
 /**
  * Gets the location of a shader attribute.<br>
  * Uses either the cached value {@link #getCachedAttribLocation(String)} if valid, or the GLSL
  * queried via {@link GL2ES2#glGetAttribLocation(int, String)}.<br>
  * The location will be cached.
  *
  * @return -1 if there is no such attribute available, otherwise >= 0
  * @throws GLException if no program is attached
  * @throws GLException if the program is not linked and no location was cached.
  * @see #getCachedAttribLocation(String)
  * @see #bindAttribLocation(GL2ES2, int, GLArrayData)
  * @see #bindAttribLocation(GL2ES2, int, String)
  * @see GL2ES2#glGetAttribLocation(int, String)
  */
 public int getAttribLocation(GL2ES2 gl, String name) {
   if (null == shaderProgram) throw new GLException("No program is attached");
   int location = getCachedAttribLocation(name);
   if (0 > location) {
     if (!shaderProgram.linked()) throw new GLException("Program is not linked");
     location = gl.glGetAttribLocation(shaderProgram.program(), name);
     if (0 <= location) {
       Integer idx = new Integer(location);
       activeAttribLocationMap.put(name, idx);
       if (DEBUG) {
         System.err.println("ShaderState: glGetAttribLocation: " + name + ", loc: " + location);
       }
     } else if (verbose) {
       System.err.println(
           "ShaderState: glGetAttribLocation failed, no location for: "
               + name
               + ", loc: "
               + location);
       if (DEBUG) {
         Thread.dumpStack();
       }
     }
   }
   return location;
 }
Пример #2
0
    public LineProgramHandles(GL2ES2 gl) {
      this.program =
          createProgram(gl, lineVertShader_GLSL, lineGeomShader_GLSL, lineFragShader_GLSL);

      this.AXIS_RECT = gl.glGetUniformLocation(program, "AXIS_RECT");
      this.VIEWPORT_SIZE_PX = gl.glGetUniformLocation(program, "VIEWPORT_SIZE_PX");

      this.LINE_THICKNESS_PX = gl.glGetUniformLocation(program, "LINE_THICKNESS_PX");
      this.FEATHER_THICKNESS_PX = gl.glGetUniformLocation(program, "FEATHER_THICKNESS_PX");
      this.JOIN_TYPE = gl.glGetUniformLocation(program, "JOIN_TYPE");
      this.MITER_LIMIT = gl.glGetUniformLocation(program, "MITER_LIMIT");

      this.STIPPLE_ENABLE = gl.glGetUniformLocation(program, "STIPPLE_ENABLE");
      this.STIPPLE_SCALE = gl.glGetUniformLocation(program, "STIPPLE_SCALE");
      this.STIPPLE_PATTERN = gl.glGetUniformLocation(program, "STIPPLE_PATTERN");

      this.inXy = gl.glGetAttribLocation(program, "inXy");
      this.inFlags = gl.glGetAttribLocation(program, "inFlags");
      this.inMileage = gl.glGetAttribLocation(program, "inMileage");
      this.inRgba = gl.glGetAttribLocation(program, "inRgba");
    }