[英]How does Kivy achieve cross-platform compatibility?
What allows Kivy to be cross-platform compatible?是什么让 Kivy 跨平台兼容?
In other words, how can the same Kivy source code generate apps on multiple kinds of hardware platforms, such as desktop, iOS, and Android?换句话说,同一个 Kivy 源代码如何在桌面、iOS 和 Android 等多种硬件平台上生成应用程序?
I suppose there are two key extremes of achieving cross-platform compatibility:我认为实现跨平台兼容性有两个关键的极端:
Kivy has a bit of both of these, but in particular all the drawing uses OpenGL ES 2 which is the second type: all of Kivy's drawing logic is just about identical across all supported platforms. Kivy 有一点两者,但特别是所有绘图都使用 OpenGL ES 2,这是第二种类型:Kivy 的所有绘图逻辑在所有支持的平台上都几乎相同。 Of course there are other types too, eg when working out display metrics such as the pixel density Kivy uses a different method on each platform but doesn't expose any of that detail to the user.当然还有其他类型,例如,在计算像素密度等显示指标时,Kivy 在每个平台上使用不同的方法,但不会向用户公开任何细节。
Of course things are much more nuanced when considering things as a whole.当然,将事情作为一个整体考虑时,事情要微妙得多。 For instance, Kivy uses SDL2 as a library for creating a window, setting its size/pos handling pause/resume etc., so Kivy's code is of the second type here as it calls SDL2 in the same way on every platform.例如,Kivy 使用 SDL2 作为库来创建窗口,设置其大小/位置处理暂停/恢复等,因此 Kivy 的代码在这里属于第二种类型,因为它在每个平台上以相同的方式调用 SDL2。 However, SDL2 is not itself platform-native and is of the first type, implementing its API differently on different platforms but exposing the same API to Kivy on each one.然而,SDL2 本身并不是平台原生的,而是第一种类型,在不同平台上以不同方式实现其 API,但在每个平台上向 Kivy 公开相同的 API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.