Search code examples
python-3.xopenglnumbapyopengl

Can I use Numba to speed up operations with OpenGL functions?


I have a list of points that's constantly updating. I want to plot lines using those points with pyopengl. If the list becomes too big, my render function becomes slow. Can I use Numba to speed up the process? Or any other optimization tool such as cython?

I used this function but I didn't notice any improvement:

from numba import jit

@jit
def points2plot(list_points):
    glBegin(GL_LINE_STRIP)
    for point in list_points:
        glVertex2f(point[0], point[1])
    glEnd()

Solution

  • You're using immediate mode opengl, your bottleneck is how you're using your rendering API, not python. You'll need to look into modern opengl (vbo/vao/shaders etc..) if you want to speed up your line plotting. Have a look at the khronos wiki I've linked, it'll get you a starting point.

    khronos wiki