Uncategorized

opengl – Error with glClear(GL_COLOR_BUFFER_BIT) in Python being ‘invalid operation’


When I run the following basic code just to open a pygame window with opengl, I get an ‘invalid operation’ error.

The full error message is

OpenGL.error.GLError: GLError(
    err = 1282,
    description = b'invalid operation',
    baseOperation = glClear,
    cArguments = (GL_COLOR_BUFFER_BIT,)
)

My code is

import pygame as pg
from OpenGL.GL import *


class App:
    def __init__(self):
        pg.init()
        pg.display.set_mode((640, 480), pg.OPENGL | pg.DOUBLEBUF)
        self.clock = pg.time.Clock()

        glClearColor(0.1, 0.2, 0.2, 1)
        self.mainloop()

    def mainloop(self):
        running = True
        while running:
            for event in pg.event.get():
                if event.type == pg.quit():
                    running = False
            #print(glCheckFramebufferStatus)
            glClear(GL_COLOR_BUFFER_BIT)  # refresh display
            pg.display.flip()             # refresh display
            self.clock.tick(60)
        self.quit()

    def quit(self):
        pg.quit


if __name__ == '__main__':
    app = App()
    app.run()

I am following a tutorial and directly copied their code with no typos. I have installed both OpenPyGL and OpenPyGL_accelerate with no issue.

I tried checking the framebuffer status with print(glCheckFramebufferStatus) and got <OpenGL.platform.baseplatform.glCheckFramebufferStatus object at 0x039A1B38>.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *