Skip to content

Commit

Permalink
Draw#discard()
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Dec 25, 2023
1 parent 13c2e55 commit d751224
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions arc-core/src/arc/graphics/g2d/Batch.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ protected void draw(Runnable request){

protected abstract void flush();

/** Discards any pending sprites. */
protected void discard(){
idx = 0;
}

protected void setBlending(Blending blending){
if(this.blending != blending){
flush();
Expand Down
7 changes: 6 additions & 1 deletion arc-core/src/arc/graphics/g2d/Draw.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,12 @@ public static void vert(Texture texture, float[] vertices, int offset, int lengt
}

public static void flush(){
Core.batch.flush();
batch.flush();
}

/** Discards any pending batched sprites. */
public static void discard(){
batch.discard();
}

public static void proj(float x, float y, float w, float h){
Expand Down
8 changes: 8 additions & 0 deletions arc-core/src/arc/graphics/g2d/SortedSpriteBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ protected void flush(){
super.flush();
}

@Override
protected void discard(){
if(!flushing){
numRequests = 0;

This comment has been minimized.

Copy link
@way-zer

way-zer Apr 28, 2024

Contributor

Set req.run = null; like 774bfa9 ?

This comment has been minimized.

Copy link
@Anuken

Anuken Apr 28, 2024

Author Owner

discard() should only be called in the logic display, which doesn't have run-type drawing.

}
super.discard();
}

protected void flushRequests(){
if(!flushing && numRequests > 0){
flushing = true;
Expand Down

0 comments on commit d751224

Please sign in to comment.