pygame_sdl2 icon indicating copy to clipboard operation
pygame_sdl2 copied to clipboard

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

Open martan3d opened this issue 7 years ago • 4 comments

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

martan3d avatar Feb 10 '18 18:02 martan3d

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

umbe1987 avatar Feb 16 '18 21:02 umbe1987

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

bitcraft avatar Feb 19 '18 21:02 bitcraft

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?

umbe1987 avatar Feb 20 '18 12:02 umbe1987

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.

bitcraft avatar Feb 20 '18 23:02 bitcraft