Skip to content

Port Renderer, Texture to C #2556

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions buildconfig/Setup.Emscripten.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ rect src_c/void.c
rwobject src_c/void.c
system src_c/void.c
_window src_c/void.c
_renderer src_c/void.c
_texture src/void.c
_image src/void.c
geometry src_c/void.c

#_sdl2.controller src_c/_sdl2/controller.c $(SDL) $(DEBUG) -Isrc_c
Expand Down
3 changes: 3 additions & 0 deletions buildconfig/Setup.SDL2.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ newbuffer src_c/newbuffer.c $(SDL) $(DEBUG)
system src_c/system.c $(SDL) $(DEBUG)
geometry src_c/geometry.c $(SDL) $(DEBUG)
_window src_c/window.c $(SDL) $(DEBUG)
_renderer src_c/renderer.c $(SDL) $(DEBUG)
_texture src_c/texture.c $(SDL) $(DEBUG)
_image src_c/video_image.c $(SDL) $(DEBUG)
3 changes: 3 additions & 0 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ typedef enum {
#define PYGAMEAPI_BASE_NUMSLOTS 27
#define PYGAMEAPI_EVENT_NUMSLOTS 8
#define PYGAMEAPI_WINDOW_NUMSLOTS 1
#define PYGAMEAPI_RENDERER_NUMSLOTS 1
#define PYGAMEAPI_TEXTURE_NUMSLOTS 1
#define PYGAMEAPI_IMAGE_NUMSLOTS 1
#define PYGAMEAPI_GEOMETRY_NUMSLOTS 1

#endif /* _PYGAME_INTERNAL_H */
52 changes: 52 additions & 0 deletions src_c/include/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,52 @@ typedef struct {
#define import_pygame_window() IMPORT_PYGAME_MODULE(_window)
#endif

/*
* Renderer module
*/
typedef struct {
PyObject_HEAD SDL_Renderer *renderer;
pgWindowObject *window;
} pgRendererObject;
#ifndef PYGAMEAPI_RENDERER_INTERNAL
#define pgRenderer_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(_renderer, 0))
#define pgRenderer_Check(x) \
(PyObject_IsInstance((x), (PyObject *)&pgRenderer_Type))
#define import_pygame_renderer() IMPORT_PYGAME_MODULE(_renderer)
#endif

/*
* Texture module
*/
typedef struct {
PyObject_HEAD SDL_Texture *texture;
pgRendererObject *renderer;
int width;
int height;
} pgTextureObject;
#ifndef PYGAMEAPI_TEXTURE_INTERNAL
#define pgTexture_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(_texture, 0))
#define pgTexture_Check(x) \
(PyObject_IsInstance((x), (PyObject *)&pgTexture_Type))
#define import_pygame_texture() IMPORT_PYGAME_MODULE(_texture)
#endif

/*
* video.Image module
*/
typedef struct {
PyObject_HEAD SDL_Texture *texture;
int angle;
SDL_Point origin;
SDL_RendererFlip flip;
} pgImageObject;
#ifndef PYGAMEAPI_IMAGE_INTERNAL
#define pgImage_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(_image, 0))
#define pgImage_Check(x) \
(PyObject_IsInstance((x), (PyObject *)&pgImage_Type))
#define import_pygame_image() IMPORT_PYGAME_MODULE(_image)
#endif

#define IMPORT_PYGAME_MODULE _IMPORT_PYGAME_MODULE

/*
Expand All @@ -521,6 +567,9 @@ PYGAMEAPI_DEFINE_SLOTS(pixelarray);
PYGAMEAPI_DEFINE_SLOTS(color);
PYGAMEAPI_DEFINE_SLOTS(math);
PYGAMEAPI_DEFINE_SLOTS(_window);
PYGAMEAPI_DEFINE_SLOTS(_renderer);
PYGAMEAPI_DEFINE_SLOTS(_texture);
PYGAMEAPI_DEFINE_SLOTS(_image);
PYGAMEAPI_DEFINE_SLOTS(geometry);
#else /* ~PYGAME_H */
PYGAMEAPI_EXTERN_SLOTS(base);
Expand All @@ -535,6 +584,9 @@ PYGAMEAPI_EXTERN_SLOTS(pixelarray);
PYGAMEAPI_EXTERN_SLOTS(color);
PYGAMEAPI_EXTERN_SLOTS(math);
PYGAMEAPI_EXTERN_SLOTS(_window);
PYGAMEAPI_EXTERN_SLOTS(_renderer);
PYGAMEAPI_EXTERN_SLOTS(_texture);
PYGAMEAPI_EXTERN_SLOTS(_image);
PYGAMEAPI_EXTERN_SLOTS(geometry);

#endif /* ~PYGAME_H */
Expand Down
Loading