From 0627bd85f3c488e99b51f396473b0f8e80271eb2 Mon Sep 17 00:00:00 2001 From: hiker Date: Tue, 14 Apr 2015 16:35:05 +1000 Subject: [PATCH] Added some (commented out) debug features for gpu particles. --- src/graphics/gpuparticles.cpp | 18 ++++++++++++++++++ src/graphics/gpuparticles.hpp | 1 - 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/graphics/gpuparticles.cpp b/src/graphics/gpuparticles.cpp index 43d832a75..d9dc260ac 100644 --- a/src/graphics/gpuparticles.cpp +++ b/src/graphics/gpuparticles.cpp @@ -406,6 +406,24 @@ void ParticleSystemProxy::simulate() glBindVertexArray(0); glDisable(GL_RASTERIZER_DISCARD); +#ifdef DEBUG_PARTICLES + // This code maps the data from the particles (initial data, current data + // and output of transform feedback shader) into memory. Useful for debugging. + if (std::string(getName()) == std::string("particles(C:/Users/jhenrich/supertuxkart/stk-assets/textures/skid-particle1.png)")) + { + glBindVertexArray(current_simulation_vao); + glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer); + ParticleData *p_initial = (ParticleData*)glMapBufferRange(GL_ARRAY_BUFFER, 0, m_count*sizeof(ParticleData), GL_MAP_READ_BIT); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]); + ParticleData *p_prev = (ParticleData*)glMapBufferRange(GL_ARRAY_BUFFER, 0, m_count*sizeof(ParticleData), GL_MAP_READ_BIT); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]); + ParticleData *p_new = (ParticleData*)glMapBufferRange(GL_ARRAY_BUFFER, 0, m_count*sizeof(ParticleData), GL_MAP_READ_BIT); + glUnmapBuffer(GL_ARRAY_BUFFER); + } +#endif + std::swap(tfb_buffers[0], tfb_buffers[1]); std::swap(current_rendering_vao, non_current_rendering_vao); std::swap(current_simulation_vao, non_current_simulation_vao); diff --git a/src/graphics/gpuparticles.hpp b/src/graphics/gpuparticles.hpp index 8225beb36..6127d304d 100644 --- a/src/graphics/gpuparticles.hpp +++ b/src/graphics/gpuparticles.hpp @@ -56,7 +56,6 @@ protected: virtual void simulate(); virtual void draw(); -public: struct ParticleData { float PositionX;