aboutsummaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-09-04 22:52:38 +0200
committerAdrian Kummerlaender2019-09-04 22:52:38 +0200
commit4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0 (patch)
tree22a4376485604e3483b4ee044ca5460bd4f27867 /utility
parenta89d3eba9aec11a4f55817fcdb189fcd6f26b574 (diff)
downloadsymlbm_playground-4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0.tar
symlbm_playground-4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0.tar.gz
symlbm_playground-4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0.tar.bz2
symlbm_playground-4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0.tar.lz
symlbm_playground-4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0.tar.xz
symlbm_playground-4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0.tar.zst
symlbm_playground-4974c2ccc7f640d6a657c22cc1a3dfa9d114b8f0.zip
Reset stuck particles to starting position
Diffstat (limited to 'utility')
-rw-r--r--utility/particles.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/utility/particles.py b/utility/particles.py
new file mode 100644
index 0000000..b838790
--- /dev/null
+++ b/utility/particles.py
@@ -0,0 +1,22 @@
+import pyopencl as cl
+mf = cl.mem_flags
+
+import numpy
+
+import OpenGL.GL as gl
+from OpenGL.arrays import vbo
+
+class Particles:
+ def __init__(self, context, float_type, grid):
+ self.context = context
+ self.count = len(grid)
+
+ self.np_particles = numpy.ndarray(shape=(self.count, 4), dtype=float_type)
+
+ self.np_particles[:,0:2] = grid
+ self.np_particles[:,2:4] = self.np_particles[:,0:2]
+
+ self.gl_particles = vbo.VBO(data=self.np_particles, usage=gl.GL_DYNAMIC_DRAW, target=gl.GL_ARRAY_BUFFER)
+ self.gl_particles.bind()
+ self.cl_gl_particles = cl.GLBuffer(self.context, mf.READ_WRITE, int(self.gl_particles))
+