Mar-20-2022, 09:49 PM
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/):
Any help would be much appreciated. Thanks!
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!
