尝试在pyopengl中缩放网格时出现OpenGL错误1282

2024-10-02 16:20:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试缩放我的曲面,所以我尝试了openGL,但出现了一个显示openGL错误的错误

这是密码 https://pastebin.pl/view/8366ece3

我将展示重要的部分:

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);

错误是:

  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)
)

Tags: runineventforiftype错误level
1条回答
网友
1楼 · 发布于 2024-10-02 16:20:48

任何OpenGL语句的当前有效OpenGL Context。创建显示曲面时,需要设置pygame.OPENGL标志:

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

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

无论如何^{}只适用于在OpenGL立即模式(^{}/^{})下绘制的几何体,而不适用于精灵或由pygame函数绘制的几何体

相关问题 更多 >