1

I tried to zoom my surface a bit so I tried openGL, and an error occured showing openGL error

here is the code https://pastebin.pl/view/8366ece3

I'll show the part that mattered:

def main():
    window = pg.display.set_mode((sw,sh))
    gridlength = 35
    level = 1
    grid = drawgrid(gridlength + level)
    samplechar = character(gridlength, grid)
    mapgen(grid, gridlength, samplechar, level)

    for i in grid:
        print(*i)

    run = True
    while run:
        for event in pg.event.get():
            if event.type == pg.QUIT:
                pg.quit()
                quit()
            elif event.type == pg.MOUSEBUTTONDOWN:
                if event.button == 4:
                    glScaled(1.2,1.2,1.2);
                elif event.button == 5:
                    glScaled(0.8,0.8,0.8);

and the error:

  File "src/errorchecker.pyx", line 58, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError
OpenGL.error.GLError: GLError(
    err = 1282,
    description = b'invalid operation',
    baseOperation = glScaled,
    cArguments = (1.2, 1.2, 1.2)
)
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
bluends
  • 155
  • 12

1 Answers1

0

A current and valid OpenGL Context for any OpenGL statement. You need to set the pygame.OPENGL flag when creating the display Surface:

window = pg.display.set_mode((sw,sh))

window = pg.display.set_mode((sw,sh), pygame.DOUBLEBUF | pygame.OPENGL)

Anyway glScale only applies to geometry which is drawn in OpenGL immediate mode (glBegin/glEnd), but not to Sprites or geometry which is drawn by pygame functions.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • doesnt work sadly, made alot of changes after trying your advice and ultimately ended up in a black screen :c – bluends Sep 26 '20 at 14:52
  • also its error 1282 not 1281 – bluends Sep 26 '20 at 14:55
  • @bluends Yes of course I said it won't work. Please read the answer. There is no way to interact the OpenGL fixed function matrices and drawing in pygame. You have to draw the geometry with `glBegin`/`glEnd` sequences. Linke in this [example](https://stackoverflow.com/questions/56609044/how-create-a-camera-on-pyopengl-that-can-do-perspective-rotations-on-mouse-mov) – Rabbid76 Sep 26 '20 at 14:57