How do i draw an image from an array in pyglet

I working on a voxel engine based using raycasting. But i need a way to display my frame who is a nested list like that (100x100x3). The only idea i had was to create an image in pyglet using pyglet.image.create(width,height) and to next modifie it’s data using image.set_data("RGB",width*3,data). But the problem i have is how to organize my data create like that : numpy.zeros([100,100,3]) to be used in set_data(). I have try data.tobytes() or ctypes but i always get an image glitter with random particules.enter image description here

>Solution :

See numpy.zeros. numpy.zeros([100,100,3]) generates an array of floats. You should generate an array of uint8:


numpy.zeros([100,100,3], dtype = numpy.uint8)

Leave a Reply