/**
  * Binds the buffer object buffer to the binding point at index index of the array of targets
  * specified by target. Each target represents an indexed array of buffer binding points, as well
  * as a single general binding point that can be used by other buffer manipulation functions such
  * as glBindBuffer or glMapBuffer. In addition to binding buffer to the indexed buffer binding
  * target, glBindBufferBase also binds buffer to the generic buffer binding point specified by
  * target.
  *
  * @param theTarget
  * @param theIndex
  */
 public void bindBufferBase(GLBufferTarget theTarget, int theIndex) {
   switch (theTarget) {
     case ATOMIC_COUNTER:
     case TRANSFORM_FEEDBACK:
     case UNIFORM:
     case SHADER_STORAGE:
       break;
     default:
       throw new GLException("Unsupported target for bindBufferBase");
   }
   bind();
   GL4 gl = GLGraphics.currentGL();
   gl.glBindBufferBase(theTarget.glID, theIndex, _myID);
   unbind();
 }
  @Override
  protected boolean render(GL gl) {

    GL4 gl4 = (GL4) gl;

    {
      gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
      ByteBuffer pointer =
          gl4.glMapBufferRange(
              GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);

      Mat4 projection =
          glm.perspectiveFov_((float) Math.PI * 0.25f, windowSize.x, windowSize.y, 0.1f, 100.0f);
      Mat4 model = new Mat4(1.0f);

      pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_());

      // Make sure the uniform buffer is uploaded
      gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
    }

    gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);
    gl4.glClearBufferfv(GL_COLOR, 0, new float[] {1.0f, 0.5f, 0.0f, 1.0f}, 0);

    gl4.glBindProgramPipeline(pipelineName.get(0));
    gl4.glActiveTexture(GL_TEXTURE0);
    gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(0));
    gl4.glBindVertexArray(vertexArrayName.get(0));
    gl4.glBindBufferBase(
        GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));

    gl4.glDrawElementsInstancedBaseVertexBaseInstance(
        GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);

    return true;
  }