From b770e7452c11cf0acdccf824c9c9304e9de3f08b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 21 Sep 2019 18:19:22 +0200 Subject: Extract GL moments, particle buffers and add texture buffer --- channel_3d_gl_interop.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'channel_3d_gl_interop.py') diff --git a/channel_3d_gl_interop.py b/channel_3d_gl_interop.py index a9633c4..e509e45 100644 --- a/channel_3d_gl_interop.py +++ b/channel_3d_gl_interop.py @@ -3,6 +3,7 @@ from string import Template from simulation import Lattice, Geometry from utility.particles import Particles +from utility.opengl import MomentsVertexBuffer from symbolic.generator import LBM import symbolic.D3Q27 as D3Q27 @@ -238,10 +239,11 @@ primitives = list(map(lambda material: material[0], filter(lambda material: no lattice.apply_material_map(material_map) lattice.sync_material() +moments_vbo = MomentsVertexBuffer(lattice) + particles = Particles( - lattice.context, - lattice.queue, - lattice.memory.float_type, + lattice, + moments_vbo, numpy.mgrid[ 2*lattice.geometry.size_x//100:4*lattice.geometry.size_x//100:particle_count/10000j, lattice.geometry.size_y//16:15*lattice.geometry.size_y//16:100j, @@ -256,10 +258,10 @@ 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() @@ -268,13 +270,10 @@ def on_display(): glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LESS) - glEnableClientState(GL_VERTEX_ARRAY) - particles.gl_particles.bind() - shaders.glUseProgram(particle_program) glUniformMatrix4fv(projection_id, 1, False, numpy.ascontiguousarray(projection)) glUniformMatrix4fv(rotation_id, 1, False, numpy.ascontiguousarray(rotation.get())) - glVertexPointer(4, GL_FLOAT, 0, particles.gl_particles) + particles.bind() glEnable(GL_POINT_SMOOTH) glPointSize(point_size) glDrawArrays(GL_POINTS, 0, particles.count) -- cgit v1.2.3