forked from genewildish/Mainline
Update docs, fix Pygame window, and improve camera stage timing
This commit is contained in:
@@ -19,7 +19,14 @@ All backends implement a common Display protocol (in `engine/display/__init__.py
|
||||
|
||||
```python
|
||||
class Display(Protocol):
|
||||
def show(self, buf: list[str]) -> None:
|
||||
width: int
|
||||
height: int
|
||||
|
||||
def init(self, width: int, height: int, reuse: bool = False) -> None:
|
||||
"""Initialize the display"""
|
||||
...
|
||||
|
||||
def show(self, buf: list[str], border: bool = False) -> None:
|
||||
"""Display the buffer"""
|
||||
...
|
||||
|
||||
@@ -27,7 +34,11 @@ class Display(Protocol):
|
||||
"""Clear the display"""
|
||||
...
|
||||
|
||||
def size(self) -> tuple[int, int]:
|
||||
def cleanup(self) -> None:
|
||||
"""Clean up resources"""
|
||||
...
|
||||
|
||||
def get_dimensions(self) -> tuple[int, int]:
|
||||
"""Return (width, height)"""
|
||||
...
|
||||
```
|
||||
@@ -37,8 +48,8 @@ class Display(Protocol):
|
||||
Discovers and manages backends:
|
||||
|
||||
```python
|
||||
from engine.display import get_monitor
|
||||
display = get_monitor("terminal") # or "websocket", "sixel", "null", "multi"
|
||||
from engine.display import DisplayRegistry
|
||||
display = DisplayRegistry.create("terminal") # or "websocket", "null", "multi"
|
||||
```
|
||||
|
||||
### Available Backends
|
||||
@@ -47,9 +58,9 @@ display = get_monitor("terminal") # or "websocket", "sixel", "null", "multi"
|
||||
|---------|------|-------------|
|
||||
| terminal | backends/terminal.py | ANSI terminal output |
|
||||
| websocket | backends/websocket.py | Web browser via WebSocket |
|
||||
| sixel | backends/sixel.py | Sixel graphics (pure Python) |
|
||||
| null | backends/null.py | Headless for testing |
|
||||
| multi | backends/multi.py | Forwards to multiple displays |
|
||||
| moderngl | backends/moderngl.py | GPU-accelerated OpenGL rendering (optional) |
|
||||
|
||||
### WebSocket Backend
|
||||
|
||||
@@ -68,9 +79,11 @@ Forwards to multiple displays simultaneously - useful for `terminal + websocket`
|
||||
3. Register in `engine/display/__init__.py`'s `DisplayRegistry`
|
||||
|
||||
Required methods:
|
||||
- `show(buf: list[str])` - Display buffer
|
||||
- `init(width: int, height: int, reuse: bool = False)` - Initialize display
|
||||
- `show(buf: list[str], border: bool = False)` - Display buffer
|
||||
- `clear()` - Clear screen
|
||||
- `size() -> tuple[int, int]` - Terminal dimensions
|
||||
- `cleanup()` - Clean up resources
|
||||
- `get_dimensions() -> tuple[int, int]` - Get terminal dimensions
|
||||
|
||||
Optional methods:
|
||||
- `title(text: str)` - Set window title
|
||||
@@ -81,6 +94,5 @@ Optional methods:
|
||||
```bash
|
||||
python mainline.py --display terminal # default
|
||||
python mainline.py --display websocket
|
||||
python mainline.py --display sixel
|
||||
python mainline.py --display both # terminal + websocket
|
||||
python mainline.py --display moderngl # GPU-accelerated (requires moderngl)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user