How to use the PyOpenGL for python3.6 on the nano?

I want to run a opengl code for python3.6 on the nano. I run some examples [url]https://github.com/baoboa/pyqt5/tree/master/examples/opengl[/url], and these examples I could run on my computer(ubuntu or windows) successfully, but failed to run on the nano.

The errors are:

GLError(
err = 1282,
description = b’invalid operation’,

)

I installed the pyopengl and pyopengl-accelerate module(version 3.1.0) using the pip command.

I need your help.

Hi,

PyOpenGL is a wrapper of GL library.
It’s recommended to verify if OpenGL can work correctly on your environment first.

OpenGL is not available on Jetson. Please use EGL or OpenGLES instead.
[s]Both EGL and OpenGLES are supported by PyOpenGL: [url]http://pyopengl.sourceforge.net/[/url][/s]

Thanks.

Should get the wiki updated, Jetson Nano - eLinux.org. It says it supports opengl 4.6

The EGL and OpenGLES are not very similar to OpenGL, and I must change my code.It is not good.

Hi,

Sorry that let me confirm this with our internal team first.
Will update information with you later.

Thanks.

Ok, I help the OpenGL can be also used on the jetson nano board.

I have tried to solve this problem by changing my OpenGL codes , but it don’t work. Maybe the OpenGL is not supported.

Hi,

OpenGL 4.6 is supported by Jetson Nano. I have corrected my comment above.
If your app cannot be executed successfully, could you share it with us?

Thanks.

This is a example based on python-opengl and pyqt5.
https://github.com/baoboa/pyqt5/blob/master/examples/opengl/hellogl.py
It is not work.
The errors are:

GLError(
err = 1282,
description = b’invalid operation’,

)

I didn’t spend a whole lot of time on it but something is broken with that example. For some reason it initializes OpenGL ES instead of OpenGL.

My quick hack with pyopengl returns

Vendor: NVIDIA Corporation
            Renderer: NVIDIA Tegra X1 (nvgpu)/integrated
            OpenGL Version: 4.6.0 NVIDIA 32.1.0
            Shader Version: 4.60 NVIDIA

The example given returns

Vendor: NVIDIA Corporation
            Renderer: NVIDIA Tegra X1 (nvgpu)/integrated
            OpenGL Version: OpenGL ES 3.2 NVIDIA 32.1.0
            Shader Version: OpenGL ES GLSL ES 3.20

Maybe the jetson nano initializes OpenGL ES instead of OpenGL in a default way.

Like I said I think its something in the example you gave not with the jetson nano. Here is a test I hacked together using snippets from this site noobtuts - Python OpenGL Introduction

#!/usr/bin/env python
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *

window = 0                                             # glut window number
width, height = 500, 400                               # window size

def draw_rect(x, y, width, height):
    glBegin(GL_QUADS)                                  # start drawing a rectangle
    glVertex2f(x, y)                                   # bottom left point
    glVertex2f(x + width, y)                           # bottom right point
    glVertex2f(x + width, y + height)                  # top right point
    glVertex2f(x, y + height)                          # top left point
    glEnd()      

def refresh2d(width, height):
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(0.0, width, 0.0, height, 0.0, 1.0)
    glMatrixMode (GL_MODELVIEW)
    glLoadIdentity()

def draw():                                            # ondraw is called all the time
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen
    glLoadIdentity()                                   # reset position
    refresh2d(width, height)                           # set mode to 2d

    print """
            Vendor: {0}
            Renderer: {1}
            OpenGL Version: {2}
            Shader Version: {3}
        """.format(
            glGetString(GL_VENDOR),
            glGetString(GL_RENDERER),
            glGetString(GL_VERSION),
            glGetString(GL_SHADING_LANGUAGE_VERSION)
        )
                        
        
    glColor3f(0.0, 0.0, 1.0)                           # set color to blue
    draw_rect(10, 10, 200, 100)                        # rect at (10, 10) with width 200, height 100
    
    glutSwapBuffers()                                # important for double buffering
    

# initialization
glutInit()                                             # initialize glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height)                      # set window size
glutInitWindowPosition(0, 0)                           # set window position
window = glutCreateWindow("noobtuts.com")              # create window with title
glutDisplayFunc(draw)                                  # set draw function callback
glutIdleFunc(draw)                                     # draw all the time
glutMainLoop()

What you said is right. I could run this example on my computer(ubuntu or windows) successfully, but failed to run on the jetson nano. I want to know why. This example should run well because the OpenGL is supported according to the wiki. Could you please give me some OpenGL(not OpenGL ES) examples which run successfully on the jetson nano? Thank you.

It runs fine on my nano.

If the example you gave (https://noobtuts.com/python/opengl-introduction) run fine on your nano, and the code I gave(https://github.com/baoboa/pyqt5/blob/master/examples/opengl/hellogl.py) did not work. Maybe the Pyqt5 is not supported well or it has a conflict with glut.

Hi,

It looks like there is no official PyQT5 prebuilt for ARM system yet.
If acceptable, you can use PyQT4 instead.

Try to install it with the following commands:

sudo apt-get install libqt4-dev qt4-dev-tools python-qt4-dev pyqt4-dev-tools
sudo apt-get install python-qt4
sudo apt-get install python3-pyqt4

Thanks.

Thanks, I will try what you said, and I also found the website incluing pyqt5 on arm
architecture.
https://archlinuxarm.org/packages/arm/python-pyqt5

Hello,

is finally PyQT5 ok for the Jetson Nano ? Did someone try it ?

Many thanks for your reply.

Alain

Hello,

i answer to myself :

i have just installed pyopengl and pyqt5 on the Nano and everything seem to work fine.

Alain

1 Like