Python Forum
Pygame with OpenGL on RPI Zero without X: invalid operation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pygame with OpenGL on RPI Zero without X: invalid operation
#1
Hello everyone!

I have the following code, which I just copied from a tutorial on internet (https://www.jarutex.com/index.php/2021/10/15/7164/):

import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *

def render():
    pass

if __name__=="__main__":
    pygame.init()
    fpsClock = pygame.time.Clock()
    pygame.display.set_mode((320,240), pygame.DOUBLEBUF|pygame.OPENGL)
    pygame.display.set_caption("ex01")
    glViewport(0,0,320,240)
    gluOrtho2D(-1.0,1.0,1.0,-1.0)
    running = True
    while running:
        fpsClock.tick(30)
        glClearColor(1.0, 1.0, 1.0, 1.0)
        glClear(GL_COLOR_BUFFER_BIT)
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        render()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
        pygame.display.flip()
    pygame.quit()
When I execute this on the RPI, I get:

Output:
pygame 2.1.2 (SDL 2.0.16, Python 3.9.10) Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "/root/./ex01.py", line 27, in <module> glClearColor(1.0, 1.0, 1.0, 1.0) File "/usr/lib/python3.9/site-packages/OpenGL/platform/baseplatform.py", line 415, in __call__ return self( *args, **named ) File "/usr/lib/python3.9/site-packages/OpenGL/error.py", line 230, in glCheckError raise self._errorClass( OpenGL.error.GLError: GLError( err = 1282, description = b'invalid operation', baseOperation = glClearColor, cArguments = (1.0, 1.0, 1.0, 1.0) )
I have been researching a bit about this and I cannot find the answer. By the way, this code is perfectly fine as it works in my desktop machine with X server though. I'm missing something in the RPI. Maybe the GL_CONTEXT? But if I query the pygame.display.gl_get_attribute() it seems that it gives me some information, as if it would have a GL_CONTEXT. Maybe something related with EGL missing?

Any help would be much appreciated. Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  zlib decompress error: invalid code lengths set / invalid block type DreamingInsanity 0 6,877 Mar-29-2020, 12:44 PM
Last Post: DreamingInsanity
  Pygame*import pygame ImportError: No module named pygame CASPERHANISCH 1 9,762 Jun-05-2017, 09:50 PM
Last Post: nilamo
  Creating shadow in OpenGL with normal? hsunteik 0 3,385 Apr-27-2017, 08:23 AM
Last Post: hsunteik
  how to destroy or remove object rendered with opengl from the screen? hsunteik 1 7,063 Apr-09-2017, 01:30 PM
Last Post: hsunteik
  NullFunctionError in opengl hsunteik 2 4,096 Apr-04-2017, 07:29 AM
Last Post: hsunteik
  Traditional OpenGL vs GLSL? hsunteik 2 4,084 Mar-27-2017, 03:54 PM
Last Post: nilamo
  How to set the window icon with OpenGL GLUT hsunteik 3 6,280 Mar-19-2017, 11:53 AM
Last Post: Larz60+
  NullFunctionError opengl glutInit hsunteik 3 12,426 Mar-18-2017, 10:25 AM
Last Post: wavic
  how to draw terrain like minecraft in python using opengl with perlin noise value? hsunteik 0 5,521 Jan-21-2017, 11:45 AM
Last Post: hsunteik
  Can OpenGL object be overlap? hsunteik 4 5,106 Jan-19-2017, 02:43 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020