Exemple #1
0
  private void setupPointers(GL2 gl) {
    int vertices[] = new int[] {25, 25, 100, 325, 175, 25, 175, 325, 250, 25, 325, 325};
    float colors[] =
        new float[] {
          1.0f, 0.2f, 0.2f, 0.2f, 0.2f, 1.0f, 0.8f, 1.0f, 0.2f, 0.75f, 0.75f, 0.75f, 0.35f, 0.35f,
          0.35f, 0.5f, 0.5f, 0.5f
        };

    if (verticesBuf == null) { // IntBuffer tmpVerticesBuf
      verticesBuf = GLBuffers.newDirectIntBuffer(vertices.length);
      verticesBuf.put(vertices);
    }
    if (colorsBuf == null) {
      colorsBuf = GLBuffers.newDirectFloatBuffer(colors.length);
      colorsBuf.put(colors);
    }
    verticesBuf.rewind();
    colorsBuf.rewind();
    //
    gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL2.GL_COLOR_ARRAY);
    //
    gl.glVertexPointer(2, GL2.GL_INT, 0, verticesBuf);
    gl.glColorPointer(3, GL.GL_FLOAT, 0, colorsBuf);
  }