简体   繁体   English

如何让Kivy 1.9.1或1.9.2在OSX 10.12.2上使用SDL2而不是pygame?

[英]How to I get Kivy 1.9.1 or 1.9.2 to use SDL2 instead of pygame on OSX 10.12.2?

Trying to get Kivy to use SDL2 and not pygame, on OSX 10.12.2 under python 2.7.13 installed by brew. 试图让Kivy在由Brew安装的python 2.7.13下的OSX 10.12.2上使用SDL2而不是pygame。 I've run the following to install dependencies. 我运行以下命令来安装依赖项。 They appear to be installed fine, as 'brew doctor' returns clean. 它们看起来安装得很好,因为“酿造医生”会恢复干净。

brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer
pip install -I Cython==0.23

Then I've tried both 1.9.2-dev0 and 1.9.1 version of Kivy, compiling from source, with an attempt to use SDL. 然后我尝试了从源代码编译的1.9.2-dev0和1.9.1版本的Kivy,尝试使用SDL。 I've also tried pip install kivy as well, rather than the latest code from the repo, and none of these attempts get Kivy to recognize SDL2. 我也尝试了pip install kivy,而不是来自repo的最新代码,并且这些尝试都没有让Kivy识别SDL2。

git clone http://github.com/kivy/kivy
cd kivy
USE_SDL2=1 make force
USE_OSX_FRAMEWORKS=0 sudo pip install -e kivy

bash-3.2$ KIVY_WINDOW=sdl2 KIVY_IMAGE=sdl2 KIVY_CLIPBOARD=sdl2 KIVY_TEXT=sdl2 python main.py
[INFO   ] [Logger      ] Record log in /Users/dancaron/.kivy/logs/kivy_17-01-23_107.txt
[INFO   ] [Kivy        ] v1.9.2-dev0
[INFO   ] [Python      ] v2.7.13 (default, Jan 23 2017, 19:04:34)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
[INFO   ] [Factory     ] 193 symbols loaded
[INFO   ] [Image       ] Providers:  (img_imageio, img_tex, img_dds, img_pygame, img_ffpyplayer, img_pil, img_gif ignored)
[CRITICAL] [App         ] Unable to get any Image provider, abort.

How do I get Kivy to use SDL2? 如何让Kivy使用SDL2?

I was able to get SDL2 working with Kivy 1.9.2 on OSX 10.12.2 using the following procedure. 我能够使用以下程序让SDL2在OSX 10.12.2上使用Kivy 1.9.2。 This assumes a brew installed python 2.7, and brew installed SDL2. 假设brew安装了python 2.7,并且brew安装了SDL2。

1) Download Kivy source (into /usr/local/lib/python2.7/site-packages directory) 1)下载Kivy源码(进入/usr/local/lib/python2.7/site-packages目录)

git clone https://github.com/kivy/kivy
cd kivy

2) Set environmental variables to tell Kivy where to find brewed SDL2 libs, not to use OSX frameworks path, and to actually use SDL2, and build Kivy. 2)设置环境变量告诉Kivy在哪里找到酿造的SDL2库,不使用OSX框架路径,实际使用SDL2,并构建Kivy。

KIVY_SDL2_PATH=/usr/local/lib USE_OSX_FRAMEWORKS=0 USE_SDL2=1 make force

Now, running your main script, you should see Window provider is SDL2. 现在,运行主脚本,您应该看到Window provider是SDL2。

bash-3.2$ python main.py
[WARNING] [Config      ] Older configuration version detected (14 instead of 17)
[WARNING] [Config      ] Upgrading configuration in progress.
[INFO   ] [Kivy        ] v1.9.2-dev0
[INFO   ] [Python      ] v2.7.13 (default, Jan 23 2017, 19:04:34)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
[INFO   ] [Factory     ] 193 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2

Using SDL2 over pygame provides retina support, and fixes issues like black screen on window resize. 在pygame上使用SDL2提供了视网膜支持,并修复了窗口调整大小等黑屏问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM