renpy / pygame_sdl2

Reimplementation of portions of the pygame API using SDL2.
GNU Lesser General Public License v2.1
326 stars 64 forks source link

Porting from pgs4a-0.9.6 - VERY slow - Any alternatives? #90

Closed martan3d closed 3 months ago

martan3d commented 6 years ago

I'm trying to port a couple of applications written using the older pygame for android. I don't really want to port them but they won't run on the newer versions of Android, specifically 7.0+ They do fine from 4.0 to 6.0 but crash on 7.0 (and I assume on 8.0 oreo)

Nevertheless, the port of the first one went fairly quickly but it is so slow its unusable. The app is very simple, just a slider on the screen that tracks your finger (mouse) movements. It's quite fast on pgs4a but ridiculous on sdl2. Is there any way to speed this up?

Or alternatively, is there a way to change the old pgs4a android build so that Android 7 is happy with it? This would actually be preferable but I don't know enough about it to do that myself or if it's possible?

Thanks, Martin

umbe1987 commented 6 years ago

I think I might have a similar problem #86. Would love to hear that pygame_sdl2 can react to the touch more responsively.

bitcraft commented 6 years ago

Is your project using surfaces and blitting? The old software API is out of date, and the most likely cause of any slow performance.

umbe1987 commented 6 years ago

Mine yes, and I'd like to test if that's the problem. It's just that I find strange that everything seems responsive from desktop but super laggy from mobile (the exact same code). Do you have any tips for converting surfaces and blitting to anything that is more SDL2-oriented?

bitcraft commented 6 years ago

pygame/sdl 1.2 have very optimized code for x86 processors that can blit surfaces very quickly (still very slow compared to a GPU). there isn't the same amount of optimization for ARM devices. Also, many of the optimizations for software rendering was removed in SDL2.

The API is not extremely different. Here are a few links to get you started:

https://wiki.libsdl.org/MigrationGuide#Setting_up_a_game_with_the_new_video_API https://wiki.libsdl.org/CategoryRender https://github.com/renpy/pygame_sdl2/blob/master/src/pygame_sdl2/render.pyx https://wiki.libsdl.org/SDL_RenderCopy?highlight=%28%5CbCategoryRender%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

The pygame_sdl2 API doesn't have support for pygame-like classes, but you can adapt C code examples.