1

I'm trying to blit my character image using pygame, it works when opengl is not called

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

When opengl is called,

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

it doesn't show my character image anymore, how do I fix it? Am I missing anything?

1 Answer 1

1

Am I missing anything?

Yes. pygame.OPENGLBLIT is obsolete and simply does not work (not sure if it ever worked; I guess not).

So either use a "regular" display surface or use OpenGL only.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.