pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
949 stars 158 forks source link

Add support for Windows on ARM (3267) #1627

Open GalacticEmperor1 opened 1 year ago

GalacticEmperor1 commented 1 year ago

Issue №3267 opened by RockLakeGrass at 2022-06-30 09:53:14

I tried to build it on a Windows on ARM64 device, but it does not show support. I looked at the SDL dependencies, except for those not supported by mpg123, which all have ARM64 versions and can be installed by vcpkg. I would like Pygame to add support for windows on arm64.


Comments

*ankith26 commented at 2022-07-01 03:42:16*

I'm +1 for the proposal, but the implementation would probably not be as straightforward. This will involve some rewriting in our buildconfig, because libsdl.org does not provide arm binaries

I don't think any of our regular contributors have an ARM64 Windows machine, but since you have one, we would be happy if you are interested in submitting some patches for this


*RockLakeGrass commented at 2022-07-01 15:35:52*

As far as I know, only mpg123 in SDL2_mixer is missing from the SDL2 dependency, because it uses yasm, which makes the porting work very complicated.


*Starbuck5 commented at 2022-07-02 07:16:25*

I'm not really sure what this issue entails.

it does not show support.

We don't have prebuilts for ARM, and SDL doesn't have prebuilts for ARM. But it should still work if you manage to navigate through compiling everything. (Although that would be quite a hassle).

It's also interesting that Python doesn't even provide prebuilt Python for Windows ARM yet. They're only starting with 3.11.


*RockLakeGrass commented at 2022-07-02 07:49:04*

I have successfully built the sdl2 arm64 Version (except mpg123), but the following errors are reported when compiling Pygame: buildconfig\obj\win64\scale_mmx.obj : Module computer type "x64" conflicts with target computer type "ARM64" I don't know where the "scale_mmx.obj" file came from so I can't rebuild it for WoA

They're only starting with 3.11.

You can see my repository in https://github.com/RockLakeGrass/Windows-on-ARM64-Toolchain , which contains MSI construction of Python 3.7~3.10.


*Starbuck5 commented at 2022-07-02 07:58:46*

except mpg123

Well that's fine. It just won't support mp3. Nothing in pygame directly touches mpg123, but SDL_mixer uses it. SDL_mixer can also use other libraries as their mp3 backend, so you may have better luck porting one of those.

buildconfig\obj\win64\scale_mmx.obj : Module computer type "x64" conflicts with target computer type "ARM64" I don't know where the "scale_mmx.obj" file came from so I can't rebuild it for WoA

This is solvable. It looks the pygame.transform will compile fine without it (I tested this), so you can just remove it from the "SETUP" file. You'll see a SETUP file in the pygame root dir, that gets spit out by buildconfig. It starts out as buildconfig/SETUP.SDL2.in .

By remove it, I mean change the transform line to this: transform src_c/transform.c src_c/rotozoom.c src_c/scale2x.c $(SDL) $(DEBUG)


*RockLakeGrass commented at 2022-07-02 08:51:18*

I have successfully built a wheel file, but I failed to load the DLL in error when loading fonts. Which DLL do I need to load fonts?

This is the wheel file.Please change the suffix name to .whl pygame-2.1.2-cp310-cp310-win_arm64.zip


*RockLakeGrass commented at 2022-07-02 09:40:11*

This is a dependency package I built myself, it is only available, but it contains a lot of unknown errors. deps.zip The wheel file is in my GitHub Repository


*Starbuck5 commented at 2022-07-03 17:13:43*

Fonts are SDL_ttf or freetype directly, for pygame.font and pygame.freetype respectively)

I see on your repo you also have trouble with images. You need SDL_image for that, compiled with the component libs for each format. (Like libpng).


*RockLakeGrass commented at 2022-07-04 02:08:16*

You need SDL_image for that

I'm sure I compiled sdl2_image module and its dependent files, but failed in Pygame tests.

Fonts are SDL_ttf or freetype directly

Similarly, I compiled freetype. When I try to put libfreetype-6.dll renamed freetype.dll, it no longer errors, but it cannot start.

mpg123 in SDL2_mixer is missing from the SDL2 dependency

Mpg123 was deleted in the preview version of SDL2mixer, does this mean SDL2 mixer can be fully ported to Windows ARM, but I am not sure if pyGame supports SDL preview version

I think the best way is to wait for the SDL to officially support Windows ARM, but this is hardly possible in the short term.


*RockLakeGrass commented at 2022-07-04 10:42:21*

Recent developments, using a new version of SDL, fixing fonts, pictures, etc. Transform is the only known problem that cannot be used because there is no source code for "scale_xmm.obj". I will upload the WHL file in my repo later.


*RockLakeGrass commented at 2022-07-04 13:22:27*

By remove it, I mean change the transform line to this: transform src_c/transform.c src_c/rotozoom.c src_c/scale2x.c $(SDL) $(DEBUG)

Changing this alone does not work, and conditional compilation instructions need to be modified in "trainsform.c". Recent developments, successfully supported transform module.

MyreMylar commented 6 months ago

This should be easier to resolve now @RockLakeGrass (if you are still doing any programming). Pygame-ce has moved to the meson build system and should exclude the mmx files by default now with Windows on ARM.