Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
way-zer authored Jul 22, 2024
1 parent a7310ce commit a169534
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion arc-core/src/arc/graphics/gl/VertexArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void set(float[] vertices, int offset, int count){
public void update(int targetOffset, float[] vertices, int sourceOffset, int count){
final int pos = byteBuffer.position();
byteBuffer.position(targetOffset * 4);
Buffers.copy(vertices, sourceOffset, count, byteBuffer);
Buffers.copy(vertices, sourceOffset, byteBuffer, count);
byteBuffer.position(pos);
}

Expand Down
3 changes: 1 addition & 2 deletions arc-core/src/arc/graphics/gl/VertexBufferObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public VertexBufferObject(boolean isStatic, int numVertices, Mesh mesh){
usage = isStatic ? Gl.staticDraw : Gl.dynamicDraw;

ByteBuffer data = Buffers.newUnsafeByteBuffer(mesh.vertexSize * numVertices);
data.limit(0);
setBuffer(data, true);
}

Expand Down Expand Up @@ -101,7 +100,7 @@ public void update(int targetOffset, float[] vertices, int sourceOffset, int cou
dirty = true;
final int pos = byteBuffer.position();
byteBuffer.position(targetOffset * 4);
Buffers.copy(vertices, sourceOffset, count, byteBuffer);
Buffers.copy(vertices, sourceOffset, byteBuffer, count);
byteBuffer.position(pos);
buffer.position(0);
bufferChanged();
Expand Down
8 changes: 3 additions & 5 deletions arc-core/src/arc/graphics/gl/VertexBufferObjectWithVAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public FloatBuffer buffer(){
}

private void upload(){
Gl.bufferData(Gl.arrayBuffer, byteBuffer.limit(), byteBuffer, usage);
Gl.bufferData(Gl.arrayBuffer, buffer.limit() * 4, byteBuffer, usage);
}

private void bufferChanged(){
Expand All @@ -94,10 +94,9 @@ public void set(float[] vertices, int offset, int count){
@Override
public void update(int targetOffset, float[] vertices, int sourceOffset, int count){
isDirty = true;
final int pos = byteBuffer.position();
byteBuffer.position(targetOffset * 4);
Buffers.copy(vertices, sourceOffset, byteBuffer, count);
byteBuffer.position(pos);
Buffers.copy(vertices, sourceOffset, count, byteBuffer);
byteBuffer.position(0);
buffer.position(0);
bufferChanged();
}
Expand Down Expand Up @@ -165,7 +164,6 @@ private void unbindAttributes(Shader shader){
private void bindData(){
if(isDirty){
Gl.bindBuffer(Gl.arrayBuffer, bufferHandle);
byteBuffer.limit(buffer.limit() * 4);
upload();
isDirty = false;
}
Expand Down

0 comments on commit a169534

Please sign in to comment.