Skip to content
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

Reduce errors in src_c/surface.c when compiling with SDL3 #3215

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#ifndef _PYGAME_INTERNAL_H
#define _PYGAME_INTERNAL_H

#include <stdbool.h>

#include "pgplatform.h"
/*
If PY_SSIZE_T_CLEAN is defined before including Python.h, length is a
Expand Down Expand Up @@ -78,6 +80,15 @@
#define PG_ConvertSurfaceFormat SDL_ConvertSurface

#define PG_PixelFormatEnum SDL_PixelFormat
#define PG_PixelFormat const SDL_PixelFormatDetails
#define PG_PixelFormatMut SDL_PixelFormatDetails
#define PG_SurfaceFormatEnum(surf) (surf)->format
#define PG_GetSurfaceFormat(surf) \
SDL_GetPixelFormatDetails(PG_SurfaceFormatEnum(surf))
#define PG_GetSurfacePalette SDL_GetSurfacePalette
#define PG_SurfaceMapRGBA(surf, r, g, b, a) \
SDL_MapSurfaceRGBA(surf, r, g, b, a)
#define PG_GetSurfaceClipRect SDL_GetSurfaceClipRect

#define PG_SurfaceHasRLE SDL_SurfaceHasRLE

Expand All @@ -100,6 +111,8 @@ PG_UnlockMutex(SDL_mutex *mutex)
return 0;
}

#define PG_FillRect SDL_FillSurfaceRect

#define PG_SURF_BitsPerPixel(surf) SDL_BITSPERPIXEL(surf->format)
#define PG_SURF_BytesPerPixel(surf) SDL_BYTESPERPIXEL(surf->format)
#define PG_FORMAT_BitsPerPixel(format) format->bits_per_pixel
Expand Down Expand Up @@ -149,6 +162,17 @@ PG_UnlockMutex(SDL_mutex *mutex)
SDL_ConvertSurfaceFormat(src, pixel_format, 0)

#define PG_PixelFormatEnum SDL_PixelFormatEnum
#define PG_PixelFormat SDL_PixelFormat
#define PG_PixelFormatMut SDL_PixelFormat
#define PG_SurfaceFormatEnum(surf) (surf)->format->format
#define PG_GetSurfaceFormat(surf) (surf)->format
#define PG_GetSurfacePalette(surf) (surf)->format->palette
#define PG_SurfaceMapRGBA(surf, r, g, b, a) \
SDL_MapRGBA(PG_GetSurfaceFormat(surf), r, g, b, a)
#define PG_GetSurfaceClipRect(surf, rect) \
{ \
rect = &surf->clip_rect; \
}

#define PG_SoftStretchNearest(src, srcrect, dst, dstrect) \
SDL_SoftStretch(src, srcrect, dst, dstrect)
Expand All @@ -165,6 +189,12 @@ PG_UnlockMutex(SDL_mutex *mutex)
return SDL_UnlockMutex(mutex);
}

static inline bool
PG_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
{
return SDL_FillRect(dst, rect, color) != -1;
}

#define PG_SURF_BitsPerPixel(surf) surf->format->BitsPerPixel
#define PG_SURF_BytesPerPixel(surf) surf->format->BytesPerPixel
#define PG_FORMAT_BitsPerPixel(format) format->BitsPerPixel
Expand Down
Loading
Loading