To main page | 3dengine.org

Numpy in game development


NumPy can and should be used for PyOpenGL's calls, for storage of vertex, camera data, etc.

Basically NumPy stores it's data as contiguous (I think it's not guaranteed at all times, but can be enforced with .flags['C_CONTIGUOUS'] call, or other calls).

Why?

1. It uses C for processing, so it's lightning fast (unlike Python's array processing).
2. There are many shortcuts
3. Can be used in PyOpenGL calls (very fast!)

Record arrays

Record arrays are also part of NumPy which allow more meaningful access to it's elements by name, therefore can act like internal databases.
a = recarray( 2, formats='i4,S50',names='id,filename')
a[0].id = 5
a[0].filename = "test"
a.resize(3)
print a[2]
print a[2].filename
a.dump("savefile.save")
a = loads(open("savefile.save").read())
This article is a stub, it contains information that doesn't explain subject fully.