Count sprite draw calls

This commit is contained in:
2020-06-13 13:42:26 +01:00
parent f971ba320c
commit eac6017c2c

View File

@@ -95,17 +95,15 @@ func (s *Scenario) Draw(screen *ebiten.Image) error {
return false return false
}) })
counter := map[string]int{} counter := 0
for _, pt := range toDraw { for _, pt := range toDraw {
for z := 0; z <= s.ZIdx; z++ { for z := 0; z <= s.ZIdx; z++ {
if err := s.renderCell(int(pt.X), int(pt.Y), z, screen, counter); err != nil { if err := s.renderCell(int(pt.X), int(pt.Y), z, screen, &counter); err != nil {
return err return err
} }
} }
} }
//log.Printf("%#+v", counter)
// Finally, draw cursor chrome // Finally, draw cursor chrome
// FIXME: it looks like we might need to do this in normal painting order... // FIXME: it looks like we might need to do this in normal painting order...
spr, err := s.specials.Sprite(0) spr, err := s.specials.Sprite(0)
@@ -132,6 +130,8 @@ func (s *Scenario) Draw(screen *ebiten.Image) error {
int(y1), int(y1),
) )
ebitenutil.DebugPrintAt(screen, fmt.Sprintf("Sprites: %v", counter), 0, 16)
/* /*
// debug: draw a square around the selected cell // debug: draw a square around the selected cell
x2, y2 := geo.Apply(cellWidth, cellHeight) x2, y2 := geo.Apply(cellWidth, cellHeight)
@@ -164,7 +164,7 @@ func (s *Scenario) geoForCoords(x, y, z int) ebiten.GeoM {
return geo return geo
} }
func (s *Scenario) renderCell(x, y, z int, screen *ebiten.Image, counter map[string]int) error { func (s *Scenario) renderCell(x, y, z int, screen *ebiten.Image, counter *int) error {
sprites, err := s.area.SpritesForCell(x, y, z) sprites, err := s.area.SpritesForCell(x, y, z)
if err != nil { if err != nil {
return err return err
@@ -179,10 +179,7 @@ func (s *Scenario) renderCell(x, y, z int, screen *ebiten.Image, counter map[str
iso.Translate(-209, -332) iso.Translate(-209, -332)
for _, spr := range sprites { for _, spr := range sprites {
// if _, ok := counter[spr.ID]; !ok { *counter = *counter + 1
// counter[spr.ID] = 0
// }
// counter[spr.ID] = counter[spr.ID] + 1
op := ebiten.DrawImageOptions{GeoM: iso} op := ebiten.DrawImageOptions{GeoM: iso}
op.GeoM.Translate(float64(spr.Rect.Min.X), float64(spr.Rect.Min.Y)) op.GeoM.Translate(float64(spr.Rect.Min.X), float64(spr.Rect.Min.Y))