aboutsummaryrefslogtreecommitdiff
path: root/trugfeuer_2d_gl_interop.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-09-21 18:19:22 +0200
committerAdrian Kummerlaender2019-09-21 18:19:22 +0200
commitb770e7452c11cf0acdccf824c9c9304e9de3f08b (patch)
tree045e882b8c85fa5e1ed39f1ac0db8869a24baad8 /trugfeuer_2d_gl_interop.py
parent6bed7f80ea8e67c388f1c52a60237e7ceb8c274e (diff)
downloadsymlbm_playground-b770e7452c11cf0acdccf824c9c9304e9de3f08b.tar
symlbm_playground-b770e7452c11cf0acdccf824c9c9304e9de3f08b.tar.gz
symlbm_playground-b770e7452c11cf0acdccf824c9c9304e9de3f08b.tar.bz2
symlbm_playground-b770e7452c11cf0acdccf824c9c9304e9de3f08b.tar.lz
symlbm_playground-b770e7452c11cf0acdccf824c9c9304e9de3f08b.tar.xz
symlbm_playground-b770e7452c11cf0acdccf824c9c9304e9de3f08b.tar.zst
symlbm_playground-b770e7452c11cf0acdccf824c9c9304e9de3f08b.zip
Extract GL moments, particle buffers and add texture buffer
Diffstat (limited to 'trugfeuer_2d_gl_interop.py')
-rw-r--r--trugfeuer_2d_gl_interop.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/trugfeuer_2d_gl_interop.py b/trugfeuer_2d_gl_interop.py
index 6d66efa..969fe4f 100644
--- a/trugfeuer_2d_gl_interop.py
+++ b/trugfeuer_2d_gl_interop.py
@@ -2,6 +2,7 @@ import numpy
from string import Template
from simulation import Lattice, Geometry
+from utility.opengl import MomentsVertexBuffer
from utility.particles import Particles
from symbolic.generator import LBM
@@ -174,10 +175,11 @@ lattice.apply_material_map(
get_channel_material_map(lattice.geometry))
lattice.sync_material()
+moments_vbo = MomentsVertexBuffer(lattice)
+
particles = Particles(
- lattice.context,
- lattice.queue,
- lattice.memory.float_type,
+ lattice,
+ moments_vbo,
numpy.mgrid[
4*lattice.geometry.size_x//9:5*lattice.geometry.size_x//9:particle_count/100j,
lattice.geometry.size_y//20:2*lattice.geometry.size_y//20:100j,
@@ -187,30 +189,25 @@ def on_display():
for i in range(0,updates_per_frame):
lattice.evolve()
- lattice.collect_gl_moments()
+ moments_vbo.collect()
for i in range(0,updates_per_frame):
- lattice.update_gl_particles(particles, aging = True)
+ particles.update(aging = True)
lattice.sync()
glClear(GL_COLOR_BUFFER_BIT)
- glEnableClientState(GL_VERTEX_ARRAY)
-
- lattice.memory.gl_moments.bind()
shaders.glUseProgram(moment_program)
glUniformMatrix4fv(projection_id, 1, False, numpy.ascontiguousarray(projection))
- glVertexPointer(4, GL_FLOAT, 0, lattice.memory.gl_moments)
+ moments_vbo.bind()
glPointSize(point_size)
glDisable(GL_POINT_SMOOTH)
glDrawArrays(GL_POINTS, 0, lattice.geometry.volume)
- particles.gl_particles.bind()
-
shaders.glUseProgram(particle_program)
glUniformMatrix4fv(projection_id, 1, False, numpy.ascontiguousarray(projection))
- glVertexPointer(4, GL_FLOAT, 0, particles.gl_particles)
+ particles.bind()
glPointSize(point_size)
glEnable(GL_POINT_SMOOTH)
glDrawArrays(GL_POINTS, 0, particles.count)