Skip to content

Commit ebbac13

Browse files
committed
Port SDL_RenderCopy.
This should be the minimum needed to render tcod tileset directly.
1 parent 8492014 commit ebbac13

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tcod/sdl/render.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ def __init__(self, sdl_renderer_p: Any) -> None:
9191
def __eq__(self, other: Any) -> bool:
9292
return bool(self.p == getattr(other, "p", None))
9393

94+
def copy(
95+
self,
96+
texture: Texture,
97+
source: Optional[Tuple[int, int, int, int]] = None,
98+
dest: Optional[Tuple[int, int, int, int]] = None,
99+
) -> None:
100+
"""Copy a texture to the rendering target.
101+
102+
`source` and `dest` are (x, y, width, height) regions of the texture parameter and target texture respectively.
103+
"""
104+
source_ = ffi.NULL if source is None else ffi.new("SDL_Rect*", source)
105+
dest_ = ffi.NULL if dest is None else ffi.new("SDL_Rect*", dest)
106+
_check(lib.SDL_RenderCopy(self.p, texture.p, source_, dest_))
107+
94108
def new_texture(
95109
self, width: int, height: int, *, format: Optional[int] = None, access: Optional[int] = None
96110
) -> Texture:

0 commit comments

Comments
 (0)