Skip to main content
 首页 » 编程设计

python之树莓派上的 Kivy : changing provider from EGL to SDL2

2024年10月24日30mq0036

在我的 Raspberry Pi 上运行 Kivy 应用程序会得到如下输出:

[INFO   ] [Logger      ] Record log in /home/pi/.kivy/logs/kivy_16-04-26_23.txt 
[INFO   ] [Kivy        ] v1.9.2-dev0 
[INFO   ] [Python      ] v2.7.9 (default, Mar  8 2015, 00:52:26) 
[GCC 4.9.2] 
[INFO   ] [Factory     ] 193 symbols loaded 
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored) 
[INFO   ] [Text        ] Provider: pygame 
[INFO   ] [Window      ] Provider: egl_rpi 
[INFO   ] [GL          ] OpenGL version <OpenGL ES 2.0> 
[INFO   ] [GL          ] OpenGL vendor <Broadcom> 
[INFO   ] [GL          ] OpenGL renderer <VideoCore IV HW> 
[INFO   ] [GL          ] OpenGL parsed version: 2, 0 
[INFO   ] [GL          ] Shading version <OpenGL ES GLSL ES 1.00> 
[INFO   ] [GL          ] Texture max size <2048> 
[INFO   ] [GL          ] Texture max units <8> 
[INFO   ] [Shader      ] fragment shader: <Compiled> 
[INFO   ] [Shader      ] vertex shader: <Compiled> 
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked 
[INFO   ] [OSC         ] using <multiprocessing> for socket 
[INFO   ] [Base        ] Start application main loop 
[INFO   ] [GL          ] NPOT texture support is available 

但是,没有窗口启动。注意 Provider: egl_rpi。

在我的 Windows Kivy 中,Provider 是 SDL2。此外,我还能够使用 SDL 作为 Raspberry Pi 上的提供程序启动示例 mp3 视频:

sudo SDL_VIDEODRIVER=fbcon SDL_FBDEV=/dev/fb1 mplayer -vo sdl -framedrop test.mpg 

我的问题是:如何为 Pi 上的 Kivy 将 Provider 更改为 SDL2?

请您参考如下方法:

将以下代码行添加到 Python 文件的顶部应将提供程序切换为 sdl2

import os 
os.environ['KIVY_WINDOW'] = 'sdl2' 

引用:here

我和你有同样的问题,egl_rpi 没有显示窗口。我切换到 SDL2 但应用程序无法加载。我相信这是由于我的 3.5"SPI 显示器的自定义驱动程序所致。也许您的视频驱动程序会更幸运。