Book Image

Kivy Cookbook

By : Hugo Solis
Book Image

Kivy Cookbook

By: Hugo Solis

Overview of this book

Table of Contents (16 chapters)
Kivy Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Optimizing graphics


Kivy is recommended because it makes a lot of optimizations by itself. Indeed, this permits the programmer who does not know how to use graphics and OpenGL to create applications with great graphical performance. However, you can always improve it using OpenGL code directly in Kivy, and besides the renderings presented in this chapter with the shaders, we have two additional considerations.

Getting ready

You need to have clear concepts of OpenGL to go deeper in this recipe, so it is useful to refer to the Kronos documentation at https://www.khronos.org/opengles/sdk/docs/man/.

How to do it…

In this recipe, we are going to review three examples to improve our graphics:

  1. First, if we want to work with OpenGL directly in Kivy, we import it in the Python file of our app:

    from kivy.graphics.opengl import *
    
  2. Here, we import all the OpenGL available methods. Now we can start to work with OpenGL instructions:

    glEnable(GL_DEPTH_TEST)
    
  3. Next, we add our graphics and then we end the instructions...