user2755916
user2755916

Reputation: 11

Python/pygame: Usage of surfarray.pixels3d()

Using the following code:

import pygame
n = pygame.Surface((80,80))
m = pygame.surfarray.pixels3d(n)

m[1][1][1] = 255
del m

screen = pygame.display.set_mode((80,80))
screen.blit(n, (0,0))

Gives me the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pygame.error: Surfaces must not be locked during blit

Didn't I just delete the reference?

Upvotes: 1

Views: 709

Answers (1)

Shashank
Shashank

Reputation: 13869

Well this is a case where the pygame documentation is just unclear. It SAYS the referenced surface will be locked for the lifetime of the array, but deleting the array won't actually unlock the surface that it references. Use n.unlock() to unlock the surface before blitting.

Upvotes: 1

Related Questions