1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 12:51:49 -05:00

GLSpectrum: suppress VLAs templatized version

This commit is contained in:
f4exb 2018-03-01 02:19:52 +01:00
parent 0cc99dad13
commit c9fd26f661
3 changed files with 74 additions and 87 deletions

View File

@ -0,0 +1,59 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRBASE_UTIL_INCREMENTALARRAY_H_
#define SDRBASE_UTIL_INCREMENTALARRAY_H_
#include <stdint.h>
template<typename T>
class IncrementalArray
{
public:
T *m_array;
IncrementalArray();
~IncrementalArray();
void allocate(uint32_t size);
private:
uint32_t m_size;
};
template<typename T>
IncrementalArray<T>::IncrementalArray() :
m_array(0),
m_size(0)
{
}
template<typename T>
IncrementalArray<T>::~IncrementalArray()
{
if (m_array) { delete[] m_array; }
}
template<typename T>
void IncrementalArray<T>::allocate(uint32_t size)
{
if (size <= m_size) { return; }
if (m_array) { delete[] m_array; }
m_array = new T[size];
m_size = size;
}
#endif /* SDRBASE_UTIL_INCREMENTALARRAY_H_ */

View File

@ -813,7 +813,7 @@ void GLSpectrum::paintGL()
}
{
//GLfloat q3[2*m_fftSize];
GLfloat *q3 = m_shaderArrays.m_q3FFT;
GLfloat *q3 = m_q3FFT.m_array;
Real bottom = -m_powerRange;
for(int i = 0; i < m_fftSize; i++) {
@ -837,7 +837,7 @@ void GLSpectrum::paintGL()
{
Real bottom = -m_powerRange;
//GLfloat q3[2*m_fftSize];
GLfloat *q3 = m_shaderArrays.m_q3FFT;
GLfloat *q3 = m_q3FFT.m_array;
for(int i = 0; i < m_fftSize; i++) {
Real v = (*m_currentSpectrum)[i] - m_referenceLevel;
@ -863,7 +863,7 @@ void GLSpectrum::paintGL()
{
//GLfloat q3[4*tickList->count()];
GLfloat *q3 = m_shaderArrays.m_q3TickTime;
GLfloat *q3 = m_q3TickTime.m_array;
int effectiveTicks = 0;
for (int i= 0; i < tickList->count(); i++)
@ -891,7 +891,7 @@ void GLSpectrum::paintGL()
{
//GLfloat q3[4*tickList->count()];
GLfloat *q3 = m_shaderArrays.m_q3TickFrequency;
GLfloat *q3 = m_q3TickFrequency.m_array;
int effectiveTicks = 0;
for (int i= 0; i < tickList->count(); i++)
@ -925,7 +925,7 @@ void GLSpectrum::paintGL()
{
//GLfloat q3[4*tickList->count()];
GLfloat *q3 = m_shaderArrays.m_q3TickPower;
GLfloat *q3 = m_q3TickPower.m_array;
int effectiveTicks = 0;
for(int i= 0; i < tickList->count(); i++)
@ -953,7 +953,7 @@ void GLSpectrum::paintGL()
{
//GLfloat q3[4*tickList->count()];
GLfloat *q3 = m_shaderArrays.m_q3TickFrequency;
GLfloat *q3 = m_q3TickFrequency.m_array;
int effectiveTicks = 0;
for(int i= 0; i < tickList->count(); i++)
@ -1579,7 +1579,7 @@ void GLSpectrum::applyChanges()
m_histogramHoldoff = new quint8[100 * m_fftSize];
memset(m_histogramHoldoff, 0x07, 100 * m_fftSize);
m_shaderArrays.allocFFT(2*m_fftSize);
m_q3FFT.allocate(2*m_fftSize);
}
if(fftSizeChanged || windowSizeChanged)
@ -1588,9 +1588,9 @@ void GLSpectrum::applyChanges()
m_waterfallTexturePos = 0;
}
m_shaderArrays.allocTickTime(4*m_timeScale.getTickList().count());
m_shaderArrays.allocTickFrequency(4*m_frequencyScale.getTickList().count());
m_shaderArrays.allocTickPower(4*m_powerScale.getTickList().count());
m_q3TickTime.allocate(4*m_timeScale.getTickList().count());
m_q3TickFrequency.allocate(4*m_frequencyScale.getTickList().count());
m_q3TickPower.allocate(4*m_powerScale.getTickList().count());
}
void GLSpectrum::mouseMoveEvent(QMouseEvent* event)

View File

@ -33,6 +33,7 @@
#include "gui/glshadertextured.h"
#include "dsp/channelmarker.h"
#include "util/export.h"
#include "util/incrementalarray.h"
class QOpenGLShaderProgram;
@ -72,82 +73,6 @@ public:
void connectTimer(const QTimer& timer);
private:
struct ShaderArrays
{
GLfloat *m_q3TickTime;
GLfloat *m_q3TickFrequency;
GLfloat *m_q3TickPower;
GLfloat *m_q3FFT;
uint32_t m_q3TickTimeSize;
uint32_t m_q3TickTimeFrequencySize;
uint32_t m_q3TickPowerSize;
uint32_t m_q3FFTSize;
ShaderArrays() :
m_q3TickTime(0),
m_q3TickFrequency(0),
m_q3TickPower(0),
m_q3FFT(0),
m_q3TickTimeSize(0),
m_q3TickTimeFrequencySize(0),
m_q3TickPowerSize(0),
m_q3FFTSize(0)
{}
~ShaderArrays()
{
if (m_q3TickTime) { delete[] m_q3TickTime; }
if (m_q3TickFrequency) { delete[] m_q3TickFrequency; }
if (m_q3TickPower) { delete[] m_q3TickPower; }
if (m_q3FFT) { delete[] m_q3FFT; }
}
void allocTickTime(uint32_t size)
{
if (size <= m_q3TickTimeSize) {
return;
}
if (m_q3TickTime) { delete[] m_q3TickTime; }
m_q3TickTime = new GLfloat[size];
m_q3TickTimeSize = size;
}
void allocTickFrequency(uint32_t size)
{
if (size <= m_q3TickTimeFrequencySize) {
return;
}
if (m_q3TickFrequency) { delete[] m_q3TickFrequency; }
m_q3TickFrequency = new GLfloat[size];
m_q3TickTimeFrequencySize = size;
}
void allocTickPower(uint32_t size)
{
if (size <= m_q3TickPowerSize) {
return;
}
if (m_q3TickPower) { delete[] m_q3TickPower; }
m_q3TickPower = new GLfloat[size];
m_q3TickPowerSize = size;
}
void allocFFT(uint32_t size)
{
if (size <= m_q3FFTSize) {
return;
}
if (m_q3FFT) { delete[] m_q3FFT; }
m_q3FFT = new GLfloat[size];
m_q3FFTSize = size;
}
};
struct ChannelMarkerState {
ChannelMarker* m_channelMarker;
QMatrix4x4 m_glMatrixWaterfall;
@ -240,7 +165,10 @@ private:
GLShaderTextured m_glShaderHistogram;
int m_matrixLoc;
int m_colorLoc;
ShaderArrays m_shaderArrays;
IncrementalArray<GLfloat> m_q3TickTime;
IncrementalArray<GLfloat> m_q3TickFrequency;
IncrementalArray<GLfloat> m_q3TickPower;
IncrementalArray<GLfloat> m_q3FFT;
static const int m_waterfallBufferHeight = 256;