Version

Quick search

CGL: standard C interface for OpenGL

Kivy uses OpenGL and therefore requires a backend that provides it. The backend used is controlled through the USE_OPENGL_MOCK and USE_SDL2 compile-time variables and through the KIVY_GL_BACKEND runtime environmental variable.

Currently, OpenGL is used through direct linking (gl/glew), sdl2, or by mocking it. Setting USE_OPENGL_MOCK disables gl/glew. Similarly, setting USE_SDL2 to 0 will disable sdl2. Mocking is always available.

At runtime the following backends are available and can be set using KIVY_GL_BACKEND:

  • gl – Available on unix (the default backend). Unavailable when USE_OPENGL_MOCK=0. Requires gl be installed.

  • glew – Available on Windows (the default backend). Unavailable when USE_OPENGL_MOCK=0. Requires glew be installed.

  • sdl2 – Available on Windows/unix (the default when gl/glew is disabled). Unavailable when USE_SDL2=0. Requires kivy_deps.sdl2 be installed.

  • angle_sdl2 – Available on Windows with Python 3.5+. Unavailable when USE_SDL2=0. Requires kivy_deps.sdl2 and kivy_deps.angle be installed.

  • angle – Available on macOS and iOS. Unavailable when USE_SDL2=0.

    Requires angle libEGL and libGLESv2 libraries (and includes) during Kivy build.

  • mock – Always available. Doesn’t actually do anything.

Additionally, the following environmental runtime variables control the graphics system:

  • KIVY_GL_DEBUG – Logs al gl calls when 1.

  • KIVY_GRAPHICS – Forces OpenGL ES2 when it is gles. OpenGL ES2 is always used on the android, ios, rpi, and mali OSs.

kivy.graphics.cgl.cgl_get_backend_name(allowed=[], ignored=[])
kivy.graphics.cgl.cgl_get_initialized_backend_name()
kivy.graphics.cgl.cgl_init(allowed=[], ignored=[])