Beispiel #1
0
 public void glBufferSubData(int target, int offset, int size, Buffer data) {
   if (data == null)
     throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
   else if (data instanceof ByteBuffer) GL15.glBufferSubData(target, offset, (ByteBuffer) data);
   else if (data instanceof IntBuffer) GL15.glBufferSubData(target, offset, (IntBuffer) data);
   else if (data instanceof FloatBuffer) GL15.glBufferSubData(target, offset, (FloatBuffer) data);
   else if (data instanceof DoubleBuffer)
     GL15.glBufferSubData(target, offset, (DoubleBuffer) data);
   else if (data instanceof ShortBuffer) //
   GL15.glBufferSubData(target, offset, (ShortBuffer) data);
 }
  @Override
  protected void reshape(int width, int height) {
    MatrixStack persMatrix = new MatrixStack();
    persMatrix.perspective(45.0f, (width / (float) height), zNear, zFar);

    ProjectionBlock projData = new ProjectionBlock();
    projData.cameraToClipMatrix = persMatrix.top();

    glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
    glBufferSubData(GL_UNIFORM_BUFFER, 0, projData.fillAndFlipBuffer(mat4Buffer));
    glBindBuffer(GL_UNIFORM_BUFFER, 0);

    glViewport(0, 0, width, height);
  }
  public void adjustVertexData(float xOffset, float yOffset) {

    newData.clear();

    for (int i = 0; i < 12; i += 4) {
      newData.put(vertexDataAry[i] + xOffset); // new x
      newData.put(vertexDataAry[i + 1] + yOffset); // new y
      newData.put(0); // new z
      newData.put(1); // new w (clip space value)
    }

    newData.flip();

    glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
    glBufferSubData(GL_ARRAY_BUFFER, 0, newData);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
  }