Skip to content

Commit

Permalink
Merge pull request #2707 from Starbuck5/transform-sdl3
Browse files Browse the repository at this point in the history
transform.scale: softstretch SDL2/SDL3 compat
  • Loading branch information
oddbookworm authored Feb 8, 2024
2 parents 59caf80 + cd52bcb commit b3ff30a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@

#define PG_SurfaceHasRLE SDL_SurfaceHasRLE

#define PG_SoftStretchNearest(src, srcrect, dst, dstrect) \
SDL_SoftStretch(src, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST)

#else /* ~SDL_VERSION_ATLEAST(3, 0, 0)*/
#define PG_ShowCursor() SDL_ShowCursor(SDL_ENABLE)
#define PG_HideCursor() SDL_ShowCursor(SDL_DISABLE)
Expand Down Expand Up @@ -102,6 +105,10 @@
#define PG_ConvertSurface(src, fmt) SDL_ConvertSurface(src, fmt, 0)
#define PG_ConvertSurfaceFormat(src, pixel_format) \
SDL_ConvertSurfaceFormat(src, pixel_format, 0)

#define PG_SoftStretchNearest(src, srcrect, dst, dstrect) \
SDL_SoftStretch(src, srcrect, dst, dstrect)

#if SDL_VERSION_ATLEAST(2, 0, 14)
#define PG_SurfaceHasRLE SDL_HasSurfaceRLE
#else
Expand Down
2 changes: 1 addition & 1 deletion src_c/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ scale_to(pgSurfaceObject *srcobj, pgSurfaceObject *dstobj, int width,
pgSurface_Lock(srcobj);
Py_BEGIN_ALLOW_THREADS;

stretch_result_num = SDL_SoftStretch(src, NULL, modsurf, NULL);
stretch_result_num = PG_SoftStretchNearest(src, NULL, modsurf, NULL);

Py_END_ALLOW_THREADS;
pgSurface_Unlock(srcobj);
Expand Down

0 comments on commit b3ff30a

Please sign in to comment.