Ebiten: Add a mode to skip clearing the screen at the beginning of a frame

Created on 9 Apr 2020  路  11Comments  路  Source: hajimehoshi/ebiten

EDIT: The title was: skip sending vertices when they are out of the region

Inspired by https://github.com/hajimehoshi/ebiten/issues/1130. In theory, we can skip sending the vertices to GPU if they are out of the region. I'm not sure how efficiently we can do it.

performance

All 11 comments

Idea: Calculate a circumscribed circle of the region rectangle and a circumscribed circle of a triangle, and see whether those circles are excluded or not.

Ah, in the Pixel version, rendering onto the screen happens only when necessary, and that's why.

https://github.com/jrcichra/gollercoaster/blob/62570d8957c033fe121c111bc883e7df919eb24a/game/game.go#L111-L127

Yeah and camera movement in pixel, it was easier for me to move around without redrawing.

Thanks!

Yeah and camera movement in pixel, it was easier for me to move around without redrawing.

Ebiten doesn't have a mode not to clear the screen at the beginning of a frame. I'll consider this.

For the camera movement, Ebiten can do a similar thing by (*GeoM).Concat. I think this is a more suitable solution for Ebiten than introducing a global matrix.

Actually I didn't realize Ebiten does this, but this is normally not needed. If you use a tile map, then this will cover the background completely. Clearing the screen at the beginning of the frame should only happen if the back ground is set to a solid color or similar.

@hajimehoshi
I have a commit that adds isClearingSkipped and SetClearingSkipped. Would you like me to PR?

Yes, I appreciate it!

I prefer the name IsClearingScreenSkipped and SetClearingScreenSkipped.

At the moment this is how it's implemented.

if game, ok := c.game.(interface{ Draw(*Image) }); ok {
    if !IsClearingSkipped() {
        c.offscreen.Clear()
    }
    game.Draw(c.offscreen)
}

Are there any other clear instructions that should be skipped? I noticed that there were a couple more in uicontext.

There is one more c.offscreen.Clear() call for Update.

Was this page helpful?
0 / 5 - 0 ratings