@@ -908,6 +908,11 @@ def _write_sprite_buffers_to_gpu(self) -> None:
908908 self ._sprite_texture_changed ,
909909 self ._sprite_index_changed ,
910910 )
911+ self ._sprite_pos_angle_changed = False
912+ self ._sprite_size_changed = False
913+ self ._sprite_color_changed = False
914+ self ._sprite_texture_changed = False
915+ self ._sprite_index_changed = False
911916
912917 def initialize (self ) -> None :
913918 """
@@ -974,6 +979,7 @@ def _grow_sprite_buffers(self) -> None:
974979 if self ._sprite_buffer_slots <= self ._buf_capacity :
975980 return
976981
982+ print ("Growing sprite buffers..." )
977983 # Double the capacity
978984 extend_by = self ._buf_capacity
979985 self ._buf_capacity = self ._buf_capacity * 2
@@ -1591,16 +1597,20 @@ def __init__(self, ctx: ArcadeContext, capacity: int, atlas: TextureAtlasBase) -
15911597 )
15921598 # fmt: on
15931599 self ._geometry = self .ctx .geometry (
1594- [BufferDescription (self ._instance_buffer , "2f" , ["in_pos" ], instanced = True )],
1600+ [BufferDescription (self ._instance_buffer , "2f" , ["in_pos" ])],
1601+ mode = self .ctx .TRIANGLE_STRIP ,
15951602 )
15961603
15971604 # Texture buffers for per-sprite data. These are looked up using gl_InstanceID
15981605 self ._pos_angle_texture = self .ctx .texture (size = (capacity , 1 ), components = 4 , dtype = "f4" )
15991606 self ._size_texture = self .ctx .texture (size = (capacity , 1 ), components = 2 , dtype = "f4" )
16001607 self ._color_texture = self .ctx .texture (size = (capacity , 1 ), components = 4 , dtype = "f1" )
1601- self ._texture_id_texture = self .ctx .texture (size = (capacity , 1 ), components = 1 , dtype = "i4 " )
1608+ self ._texture_id_texture = self .ctx .texture (size = (capacity , 1 ), components = 1 , dtype = "f4 " )
16021609 self ._index_texture = self .ctx .texture (size = (capacity , 1 ), components = 1 , dtype = "i4" )
16031610
1611+ # Debugging
1612+ self ._query = self .ctx .query (primitives = True )
1613+
16041614 def write_sprite_buffers_to_gpu (
16051615 self ,
16061616 # The data itself
@@ -1633,26 +1643,22 @@ def write_sprite_buffers_to_gpu(
16331643 """
16341644 if sprite_pos_angle_changed :
16351645 self ._pos_angle_texture .write (sprite_pos_angle_data )
1636- self ._sprite_pos_angle_changed = False
16371646
16381647 if sprite_size_changed :
16391648 self ._size_texture .write (sprite_size_data )
1640- self ._sprite_size_changed = False
16411649
16421650 if sprite_color_changed :
16431651 self ._color_texture .write (sprite_color_data )
1644- self ._sprite_color_changed = False
16451652
16461653 if sprite_texture_changed :
16471654 self ._texture_id_texture .write (sprite_texture_data )
1648- self ._sprite_texture_changed = False
16491655
16501656 if sprite_index_changed :
16511657 self ._index_texture .write (sprite_index_data )
1652- self ._sprite_index_changed = False
16531658
16541659 def grow_sprite_buffers (self ) -> None :
16551660 """Double the internal storage"""
1661+ print (f"Growing sprite buffers from { self ._buf_capacity } to" , self ._buf_capacity * 2 )
16561662 # Double the capacity
16571663 self ._buf_capacity = self ._buf_capacity * 2
16581664
@@ -1714,7 +1720,10 @@ def render(
17141720 else :
17151721 atlas_texture .filter = default_texture_filter
17161722
1717- self .program ["spritelist_color" ] = color
1723+ try :
1724+ self .program ["spritelist_color" ] = color
1725+ except KeyError :
1726+ pass
17181727
17191728 # Control center pixel interpolation:
17201729 # 0.0 = raw interpolation using texture corners
@@ -1735,11 +1744,18 @@ def render(
17351744
17361745 if not self ._geometry :
17371746 raise ValueError ("Attempting to render without '_geometry' field being set." )
1738- self ._geometry .render (
1739- self .program ,
1740- mode = self .ctx .POINTS ,
1741- instances = count ,
1742- )
1747+
1748+ # a = array("i")
1749+ # a.frombytes(self._index_texture.read())
1750+ # print("Buffer", a)
1751+
1752+ with self ._query :
1753+ self ._geometry .render (
1754+ self .program ,
1755+ # mode=self.ctx.TRIANGLE_STRIP,
1756+ instances = count ,
1757+ )
1758+ # print(f"Primitives rendered: {self._query.primitives_generated} (count: {count})")
17431759
17441760 # Leave global states to default
17451761 if blend :
0 commit comments