diff options
| author | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-16 21:00:28 +0300 |
|---|---|---|
| committer | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-16 21:00:28 +0300 |
| commit | 68e6ebe24cb476997b2ddfc21a5b13fb6f332fa7 (patch) | |
| tree | 646db708a2db1b61904003c81a05b01358cdb4cc /src/live.cpp | |
| parent | b13609afcdf66d781db70fb75f6869a052a49079 (diff) | |
Render texture onto window on each iteration.
Keep colormap in renderer so we don't pass the colormapped windows like
animals.
Pre-render empty window.
Fixes #15.
Diffstat (limited to 'src/live.cpp')
| -rw-r--r-- | src/live.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/live.cpp b/src/live.cpp index f1ae3d6..641eb7d 100644 --- a/src/live.cpp +++ b/src/live.cpp @@ -23,11 +23,17 @@ LiveOutput::LiveOutput(const Configuration& conf, const ColorMap& cmap, const Va /* FFT area raw memory used to update the area texture */ this->fft_area_.resize(conf.GetWidth() * conf.GetCount() * 4); /* RGBA pixel array */ + + /* render the live FFT area with a DC signal of zero */ + Render(); /* I don't have a good idea why this is needed, but I guess it has something to do with double buffering */ + this->renderer_.RenderFFTArea(this->fft_area_); + this->renderer_.RenderLiveFFT(RealWindow(conf.GetWidth())); } -void -LiveOutput::AddWindow(const std::vector<uint8_t>& window, const RealWindow& win_values) +std::vector<uint8_t> +LiveOutput::AddWindow(const RealWindow& win_values) { + auto window = this->renderer_.RenderLiveFFT(win_values); std::size_t wlen_bytes = this->configuration_.GetWidth() * 4; if (window.size() != wlen_bytes) { throw std::runtime_error("input window size differs from live window size"); @@ -43,12 +49,9 @@ LiveOutput::AddWindow(const std::vector<uint8_t>& window, const RealWindow& win_ reinterpret_cast<const void *>(window.data()), wlen_bytes); - /* update renderer */ + /* update renderer texture */ this->renderer_.RenderFFTArea(this->fft_area_); - this->renderer_.RenderLiveFFT(win_values, window); - - /* draw window */ - this->Render(); + return window; } bool @@ -65,6 +68,7 @@ LiveOutput::HandleEvents() void LiveOutput::Render() { + /* draw renderer output to window */ sf::Texture canvas_texture = this->renderer_.GetCanvas(); sf::Sprite canvas_sprite(canvas_texture); if (this->configuration_.IsHorizontal()) { @@ -74,4 +78,4 @@ LiveOutput::Render() this->window_.draw(canvas_sprite); this->window_.display(); -}
\ No newline at end of file +} |
