Repository navigation
Add SpriteList.draw_range for partial batch rendering - #2980
Open
snowyukitty wants to merge 2 commits into
Open
snowyukitty wants to merge 2 commits into
snowyukitty wants to merge 2 commits into
Conversation
sjrd
reviewed
Oct 13, 2026
sjrd
left a comment
Contributor
There was a problem hiding this comment.
This method could be introduced in SpriteSequence, and documented there, like draw.
Contributor
Author
|
Updated in 6498500.
The 1,665 native unit tests, repository formatting/lint/type checks, and full documentation build with warnings treated as errors pass locally. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2231.
Add
SpriteList.draw_range(start=0, stop=None, ...)so games can draw a contiguous portion of an existing sprite batch without creating another list. Bounds follow Python slicing, including negative indices, clipping and an exclusive stop; selected sprites retain list order.Declare and document
draw_rangeon the read-onlySpriteSequence, followingdraw.SpriteListprovides the rendering implementation, and consumers annotated asSpriteSequencecan call it directly.The buffer renderer uses the existing index-buffer offset. The texture renderer uses a shader instance offset and restores the shared uniform after rendering. Empty, invisible and transparent ranges keep lazy lists uninitialized. Filtering and blending options match
draw(). Legacy texture shaders remain usable for ordinary drawing and zero-start ranges; a nonzero range requiressprite_start.Validation on Linux / Python 3.12 / pyglet 3.0.dev11 with Mesa and Xvfb:
python -m pytest tests/unit -q: 1,665 passed, including actual pixel and Window/View regressions in both storage implementations.SpriteSequence[Sprite]type-checks; the same consumer fails with a missing-attribute error against the previous published interface.make.py format --check,ruff-check,mypyandpyrightpass.python make.py docs-fullpasses with warnings treated as errors, using prefetched intersphinx inventories.Texture storage was exercised on native OpenGL. Browser/WebGL and controller hardware were not run locally.