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 --- trugfeuer_2d_gl_interop.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'trugfeuer_2d_gl_interop.py') 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) -- cgit v1.2.3