Skip to content

Port Renderer to C code #3327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
01e537d
Add interface for _sdl2.video classes
MightyJosip Jan 28, 2025
0649105
Add interface for _sdl2.video classes
MightyJosip Jan 28, 2025
78d0881
Add interface for _sdl2.video classes
MightyJosip Jan 28, 2025
116932f
Add interface for _sdl2.video classes
MightyJosip Jan 29, 2025
5bdd0fc
Add interface for _sdl2.video classes
MightyJosip Jan 29, 2025
4a7e052
Add interface for _sdl2.video classes
MightyJosip Jan 29, 2025
5e917df
Add interface for _sdl2.video classes
MightyJosip Jan 29, 2025
8e15413
Add interface for _sdl2.video classes
MightyJosip Feb 3, 2025
dc0a2d3
Squashed commit of the following:
MightyJosip Jan 29, 2025
c6f22fa
Port Renderer to C code
MightyJosip Jan 30, 2025
79bc099
Port Renderer to C code
MightyJosip Feb 3, 2025
58516af
Port Renderer to C code
MightyJosip Feb 21, 2025
29341b5
Port Renderer to C code
MightyJosip Feb 21, 2025
3ee0c72
Port Renderer to C code
MightyJosip Feb 21, 2025
08a1170
Port Renderer to C code
MightyJosip Feb 22, 2025
d042169
Port Renderer to C code
MightyJosip Feb 26, 2025
fdf5f61
Port Renderer to C code
MightyJosip Feb 26, 2025
3761b9e
Port Renderer to C code
MightyJosip Feb 26, 2025
0e2d9ac
Port Renderer to C code
MightyJosip Feb 26, 2025
1b213e8
Port Renderer to C code
MightyJosip Feb 26, 2025
15f1c20
Port Renderer to C code
MightyJosip Feb 26, 2025
b9fa896
Port Renderer to C code
MightyJosip Mar 1, 2025
eef9759
Port Renderer to C code
MightyJosip Mar 1, 2025
0678a90
Port Renderer to C code
MightyJosip Mar 1, 2025
17c9047
Port Renderer to C code
MightyJosip Mar 1, 2025
f034b1d
Merge remote-tracking branch 'upstream/main' into NewRenderer
MightyJosip Mar 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions buildconfig/stubs/pygame/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,26 @@ from .constants import (
AUDIO_U16SYS as AUDIO_U16SYS,
AUDIO_U8 as AUDIO_U8,
BIG_ENDIAN as BIG_ENDIAN,
BLENDFACTOR_DST_ALPHA as BLENDFACTOR_DST_ALPHA,
BLENDFACTOR_DST_COLOR as BLENDFACTOR_DST_COLOR,
BLENDFACTOR_ONE as BLENDFACTOR_ONE,
BLENDFACTOR_ONE_MINUS_DST_ALPHA as BLENDFACTOR_ONE_MINUS_DST_ALPHA,
BLENDFACTOR_ONE_MINUS_DST_COLOR as BLENDFACTOR_ONE_MINUS_DST_COLOR,
BLENDFACTOR_ONE_MINUS_SRC_ALPHA as BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
BLENDFACTOR_ONE_MINUS_SRC_COLOR as BLENDFACTOR_ONE_MINUS_SRC_COLOR,
BLENDFACTOR_SRC_ALPHA as BLENDFACTOR_SRC_ALPHA,
BLENDFACTOR_SRC_COLOR as BLENDFACTOR_SRC_COLOR,
BLENDFACTOR_ZERO as BLENDFACTOR_ZERO,
BLENDMODE_ADD as BLENDMODE_ADD,
BLENDMODE_BLEND as BLENDMODE_BLEND,
BLENDMODE_MOD as BLENDMODE_MOD,
BLENDMODE_MUL as BLENDMODE_MUL,
BLENDMODE_NONE as BLENDMODE_NONE,
BLENDOPERATION_ADD as BLENDOPERATION_ADD,
BLENDOPERATION_MAXIMUM as BLENDOPERATION_MAXIMUM,
BLENDOPERATION_MINIMUM as BLENDOPERATION_MINIMUM,
BLENDOPERATION_REV_SUBTRACT as BLENDOPERATION_REV_SUBTRACT,
BLENDOPERATION_SUBTRACT as BLENDOPERATION_SUBTRACT,
BLEND_ADD as BLEND_ADD,
BLEND_ALPHA_SDL2 as BLEND_ALPHA_SDL2,
BLEND_MAX as BLEND_MAX,
Expand Down
70 changes: 70 additions & 0 deletions buildconfig/stubs/pygame/_render.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from typing import Optional, Union, Protocol, final
from typing_extensions import deprecated # added in 3.13

from pygame.window import Window
from pygame.rect import Rect
from pygame.color import Color
from pygame.surface import Surface
from pygame.typing import RectLike, ColorLike, Point, IntPoint, SequenceLike


class _DrawableClass(Protocol):
# Object that has the draw method that accepts area and dest arguments
def draw(
self, area: Optional[RectLike] = None, dest: Optional[RectLike] = None
): ...


@final
class Renderer:
def __init__(self, window: Window, index: int = -1, accelerated: int = -1, vsync: bool = False, target_texture: bool = False) -> None: ...
def blit(self, source: Union["Texture", "Image", _DrawableClass], dest: Optional[RectLike] = None, area: Optional[RectLike] = None, special_flags: int = 0) -> Rect: ...
def clear(self) -> None: ...
def draw_line(self, p1: Point, p2: Point) -> None: ...
def draw_point(self, point: Point) -> None: ...
def draw_quad(self, p1: Point, p2: Point, p3: Point, p4: Point) -> None: ...
def draw_rect(self, rect: RectLike) -> None: ...
def draw_triangle(self, p1: Point, p2: Point, p3: Point) -> None: ...
def fill_quad(self, p1: Point, p2: Point, p3: Point, p4: Point) -> None: ...
def fill_rect(self, rect: RectLike) -> None: ...
def fill_triangle(self, p1: Point, p2: Point, p3: Point) -> None: ...
def get_viewport(self) -> Rect: ...
def present(self) -> None: ...
def set_viewport(self, area: Optional[RectLike]) -> None: ...
def to_surface(self, surface: Optional[Surface] = None, area: Optional[RectLike] = None) -> Surface: ...

@property
def draw_blend_mode(self) -> int: ...
@draw_blend_mode.setter
def draw_blend_mode(self, value: int) -> None: ...
@property
def draw_color(self) -> Color: ...
@draw_color.setter
def draw_color(self, value: ColorLike) -> None: ...
@property
def logical_size(self) -> tuple[int, int]: ...
@logical_size.setter
def logical_size(self, value: IntPoint) -> None: ...
@property
def scale(self) -> tuple[float, float]: ...
@scale.setter
def scale(self, value: Point) -> None: ...
@property
def target(self) -> "Texture": ...
@target.setter
def target(self, value: "Texture") -> None: ...

@classmethod
def compose_custom_blend_mode(cls, color_mode: SequenceLike[int], alpha_mode: SequenceLike[int]) -> int: ...
@classmethod
def from_window(cls, window: Window) -> Renderer: ...


@final
class Texture:
pass


@final
class Image:
pass
15 changes: 15 additions & 0 deletions buildconfig/stubs/pygame/constants.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,26 @@ AUDIO_U16MSB: int
AUDIO_U16SYS: int
AUDIO_U8: int
BIG_ENDIAN: int
BLENDFACTOR_DST_ALPHA: int
BLENDFACTOR_DST_COLOR: int
BLENDFACTOR_ONE: int
BLENDFACTOR_ONE_MINUS_DST_ALPHA: int
BLENDFACTOR_ONE_MINUS_DST_COLOR: int
BLENDFACTOR_ONE_MINUS_SRC_ALPHA: int
BLENDFACTOR_ONE_MINUS_SRC_COLOR: int
BLENDFACTOR_SRC_ALPHA: int
BLENDFACTOR_SRC_COLOR: int
BLENDFACTOR_ZERO: int
BLENDMODE_ADD: int
BLENDMODE_BLEND: int
BLENDMODE_MOD: int
BLENDMODE_MUL: int
BLENDMODE_NONE: int
BLENDOPERATION_ADD: int
BLENDOPERATION_MAXIMUM: int
BLENDOPERATION_MINIMUM: int
BLENDOPERATION_REV_SUBTRACT: int
BLENDOPERATION_SUBTRACT: int
BLEND_ADD: int
BLEND_ALPHA_SDL2: int
BLEND_MAX: int
Expand Down
15 changes: 15 additions & 0 deletions buildconfig/stubs/pygame/locals.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,26 @@ AUDIO_U16MSB: int
AUDIO_U16SYS: int
AUDIO_U8: int
BIG_ENDIAN: int
BLENDFACTOR_DST_ALPHA: int
BLENDFACTOR_DST_COLOR: int
BLENDFACTOR_ONE: int
BLENDFACTOR_ONE_MINUS_DST_ALPHA: int
BLENDFACTOR_ONE_MINUS_DST_COLOR: int
BLENDFACTOR_ONE_MINUS_SRC_ALPHA: int
BLENDFACTOR_ONE_MINUS_SRC_COLOR: int
BLENDFACTOR_SRC_ALPHA: int
BLENDFACTOR_SRC_COLOR: int
BLENDFACTOR_ZERO: int
BLENDMODE_ADD: int
BLENDMODE_BLEND: int
BLENDMODE_MOD: int
BLENDMODE_MUL: int
BLENDMODE_NONE: int
BLENDOPERATION_ADD: int
BLENDOPERATION_MAXIMUM: int
BLENDOPERATION_MINIMUM: int
BLENDOPERATION_REV_SUBTRACT: int
BLENDOPERATION_SUBTRACT: int
BLEND_ADD: int
BLEND_ALPHA_SDL2: int
BLEND_MAX: int
Expand Down
16 changes: 16 additions & 0 deletions src_c/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ MODINIT_DEFINE(constants)
DEC_CONST(BLENDMODE_ADD);
DEC_CONST(BLENDMODE_MOD);
DEC_CONST(BLENDMODE_MUL);
DEC_CONST(BLENDFACTOR_ZERO);
DEC_CONST(BLENDFACTOR_ONE);
DEC_CONST(BLENDFACTOR_SRC_COLOR);
DEC_CONST(BLENDFACTOR_ONE_MINUS_SRC_COLOR);
DEC_CONST(BLENDFACTOR_SRC_ALPHA);
DEC_CONST(BLENDFACTOR_ONE_MINUS_SRC_ALPHA);
DEC_CONST(BLENDFACTOR_DST_COLOR);
DEC_CONST(BLENDFACTOR_ONE_MINUS_DST_COLOR);
DEC_CONST(BLENDFACTOR_DST_ALPHA);
DEC_CONST(BLENDFACTOR_ONE_MINUS_DST_ALPHA);
DEC_CONST(BLENDOPERATION_ADD);
DEC_CONST(BLENDOPERATION_SUBTRACT);
DEC_CONST(BLENDOPERATION_REV_SUBTRACT);
DEC_CONST(BLENDOPERATION_MINIMUM);
DEC_CONST(BLENDOPERATION_MAXIMUM);

DEC_CONST(GL_STEREO);
DEC_CONST(GL_MULTISAMPLEBUFFERS);
DEC_CONST(GL_MULTISAMPLESAMPLES);
Expand Down
Loading
Loading