Closed sezero closed 4 months ago
I'm not too familiar with sdl2-compat, but couldn't you manually define functions with SDL2 signatures that call SDL3 functions.
Like how in SDL2 you have
int SDL_ShowCursor(int toggle);
but in SDL3 there are
int SDL_ShowCursor(void);
SDL_bool SDL_CursorVisible(void);
int SDL_HideCursor(void);
That's what we are doing already. The problem is, as I said, mismatching
SDL2/SDL3 signatures. E.g. for SDL_PremultiplyAlpha
from the preprocessor
output:
/* from sdl2_protos.h -- _REAL stuff is from dynapi.. */
extern int SDL_PremultiplyAlpha_REAL (int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h) ;
/* function body: */
int SDL_PremultiplyAlpha_REAL (int a, int b, SDL_PixelFormatEnum c, const void *d, int e, SDL_PixelFormatEnum f, void *g, int h) {
return SDL3_PremultiplyAlpha (a,b,c,d,e,f,g,h); }
Same issue for SDL_PixelFormatEnumToMasks, SDL_MasksToPixelFormatEnum, and SDL_AllocFormat.
As for the rest, i.e. SDL_ConvertPixels, SDL_CreateRGBSurfaceWithFormat,
SDL_CreateRGBSurfaceWithFormatFrom, and SDL_RenderReadPixels:
We take Uint32
format from SDL2 procedure (because that's its signature)
and feeded it to the SDL3 procedure who takes SDL_PixelFormatEnum
and
that's where g++ fails.
If I'm understanding correctly, I think we need small shim functions to cast between Uint32 and SDL_PixelFormatEnum. Once I'm done with SDL3, I I'll take a crack at handling this if you want, and ask you to review when I'm done.
If I'm understanding correctly, I think we need small shim functions to cast between Uint32 and SDL_PixelFormatEnum. Once I'm done with SDL3, I I'll take a crack at handling this if you want, and ask you to review when I'm done.
Sure, I'm on hold.
If it helps, my solution is lieing about SDL2 signatures: patch.txt (inlined below: )
After enum patch merges of @Susko3 in SDL3,
SDL_PixelFormatEnum
in particular, sdl2-compat needed adjusting. I did the following to fix the SDL3 signatures:However, signatures of SDL2 and SDL3 procedures don't match and we fail in
test_sdl3_syms.cpp
:What is the correct fix here: Should we lie about the SDL2 signatures by changing them to
SDL_PixelFormatEnum
indynapi/SDL_dynapi_procs.h
andsdl2_protos.h
? Or what?