如何在使用opengl时在pygame中模糊图像?

问题描述 投票:0回答:1

我想用pygame来模糊我的人物图像,当opengl没有被调用时,它可以工作。

pygame.init()
display = pygame.display.set_mode((800, 600))

    def draw(self,display):
        if self.walkCount + 1 >= 30:
            self.walkCount = 0
        if self.left:
            display.blit(walkLeft[self.walkCount // 6], (int(self.x), int(self.y)))
            self.walkCount += 1
        elif self.right:
            display.blit(walkRight[self.walkCount // 6], (int(self.x), int(self.y)))
            self.walkCount += 1
        else:
            display.blit(standing, (int(self.x), int(self.y)))
        pygame.display.flip()
def redraw():
    global WalkCount
    display.fill((0, 0, 0))
    Player1.draw(display)
while True:
    redraw()
pygame.quit()

当调用opengl时。

display = pygame.display.set_mode((800, 600), pygame.DOUBLEBUF | pygame.OPENGLBLIT)
...
def redraw():
    global WalkCount
    Player1.draw(display)
while True:
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    redraw()
pygame.quit()

它不显示我的人物形象了,我该如何解决?我错过了什么吗?

python pygame pyopengl
1个回答
1
投票

我错过了什么吗?

是的,我错过了什么。pygame.OPENGLBLIT老掉牙 并且根本无法工作(不知道是否曾经工作过,我想是没有)。

所以,要么使用 "常规 "显示面,要么只使用OpenGL。

© www.soinside.com 2019 - 2024. All rights reserved.