问题
When trying to load and display bitmaps using Allegro 5 in C or PyGame in Python (both use SDL), instead, it renders a glitch (see screenshot below).
I tried googling it and found that it could be related to SDL_image incompatibilities with OS X El Capitan, but no solutions. Anyone?
Currently, I tried:
- Installing SDL_image 1.2.10 (latest compatible release). Nope!
- Installing SDL_image 1.2.10 with Homebrew via a custom formula. Also nothing!
On the screenshot, those random pixels should be three red brick bitmaps. By the way, I'm using those functions to load and draw the bitmap, respectively:
tileset[0] = al_load_bitmap("./data/gfx/bricks.png");
al_draw_bitmap(tileset[0], pos_x, pos_y, 0);
回答1:
The bug is actually with SDL_image under El Capitan. There is a workaround by downgrading SDL_image to 1.2.10 (not SDL). It's possible you may have installed SDL 1.2.10 but still have SDL_image 1.2.12. Try removing and force installing the correct version.
See here for details:
https://bitbucket.org/pygame/pygame/issues/284/max-osx-el-capitan-using-the-deprecated
I've tried this fix myself and Pygame is working fine under 10.11 now.
来源:https://stackoverflow.com/questions/34757499/sdl-image-visual-glitch-on-os-x-el-capitan