Skip to content

Opacity / Draw Ordering Refactor #78

@jinmin111

Description

@jinmin111

Background

Alpha transparency is not applied correctly in the current Pygame surface layer-based implementation. The root cause is that blit ordering between surfaces and transparency compositing are not properly controlled.

Proposed Changes

  • Preprocess draw calls and push them onto a stack instead of executing them directly from the engine
  • Pop from the stack in z-order and render sequentially
  • This allows control over which artist is visible first and which one appears on top
  • Reduce dependency on surface layers and handle blitting at the artist level
  • Define the role of layers as a logical z-order offset for the user

Implementation Approach

  • Replace the per-layer _surface_dict with a single SRCALPHA render surface (+ a separate graph cache surface)
  • Each frame: clear the render surface → blit graph cache onto it → draw all other artists in layer (z-order) order onto the same surface → blit render surface onto screen
  • Layers are a z-order sorting key, not tied to separate surfaces
  • Graph cache only redraws on camera move/zoom, everything else redraws each frame

Relevant Files (expected)

  • pygame_engine.py
  • render_manager.py

Closes

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions