From e30c4191d1ca0d7de4d3f9e6bf15406125f772f8 Mon Sep 17 00:00:00 2001 From: Hoernchen Date: Mon, 4 Aug 2014 18:18:59 +0200 Subject: [PATCH] gles --- include-gpl/dsp/dspengine.h | 2 +- include-gpl/dsp/interpolator.h | 4 +- include-gpl/gui/glspectrum.h | 8 + include/util/glmath.h | 7 + plugins/samplesource/rtlsdr/rtlsdrgui.cpp | 2 +- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 6 +- sdrbase/dsp/dspengine.cpp | 8 +- sdrbase/dsp/spectrumvis.cpp | 7 +- sdrbase/gui/glscope.cpp | 27 +- sdrbase/gui/glspectrum.cpp | 391 +++++--------------- sdrbase/gui/glspectrumgui.cpp | 4 +- sdrbase/gui/scopewindow.ui | 8 +- sdrbase/mainwindow.cpp | 48 +-- sdrbase/mainwindow.ui | 8 +- sdrbase/plugin/pluginmanager.cpp | 3 + sdrbase/settings/preset.cpp | 6 +- sdrbase/settings/settings.cpp | 4 + sdrbase/util/glmath.cpp | 32 ++ 18 files changed, 218 insertions(+), 357 deletions(-) create mode 100644 include/util/glmath.h create mode 100644 sdrbase/util/glmath.cpp diff --git a/include-gpl/dsp/dspengine.h b/include-gpl/dsp/dspengine.h index 28d2dae..856788e 100644 --- a/include-gpl/dsp/dspengine.h +++ b/include-gpl/dsp/dspengine.h @@ -84,7 +84,7 @@ private: typedef std::list SampleSinks; SampleSinks m_sampleSinks; - AudioOutput m_audioOutput; + //AudioOutput m_audioOutput; uint m_sampleRate; quint64 m_centerFrequency; diff --git a/include-gpl/dsp/interpolator.h b/include-gpl/dsp/interpolator.h index ae91062..afbcc02 100644 --- a/include-gpl/dsp/interpolator.h +++ b/include-gpl/dsp/interpolator.h @@ -1,7 +1,9 @@ #ifndef INCLUDE_INTERPOLATOR_H #define INCLUDE_INTERPOLATOR_H +#if 0 #include +#endif #include "dsp/dsptypes.h" #include "util/export.h" #include @@ -55,7 +57,7 @@ private: void doInterpolate(int phase, Complex* result) { -#if 1 +#if 0 // beware of the ringbuffer if(m_ptr == 0) { // only one straight block diff --git a/include-gpl/gui/glspectrum.h b/include-gpl/gui/glspectrum.h index 794780b..b1b22fa 100644 --- a/include-gpl/gui/glspectrum.h +++ b/include-gpl/gui/glspectrum.h @@ -21,6 +21,7 @@ #include #include #include +#include #include "dsp/dsptypes.h" #include "gui/scaleengine.h" #include "dsp/channelmarker.h" @@ -131,12 +132,19 @@ private: bool m_displayChanged; + QGLShaderProgram shaderprog; + int vertexAtt; + int texcoordAtt; + int matrixUni; + int texUni; + void updateWaterfall(const std::vector& spectrum); void updateHistogram(const std::vector& spectrum); void initializeGL(); void resizeGL(int width, int height); void paintGL(); + void GLtexBox(); void stopDrag(); void applyChanges(); diff --git a/include/util/glmath.h b/include/util/glmath.h new file mode 100644 index 0000000..e1db3b1 --- /dev/null +++ b/include/util/glmath.h @@ -0,0 +1,7 @@ +void initeglcompat(); +void glPushMatrix(); +void glPopMatrix(); +void glScalef(float x, float y, float z); +void glTranslatef(float x, float y, float z); + +QMatrix4x4 getMV(); diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index 5706565..0f2dc63 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -1,6 +1,6 @@ #include "rtlsdrgui.h" #include "ui_rtlsdrgui.h" -#include "plugin/pluginapi.h" +#include RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) : QWidget(parent), diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index a5d1d95..3e87e79 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -34,7 +34,7 @@ RTLSDRInput::Settings::Settings() : void RTLSDRInput::Settings::resetToDefaults() { m_gain = 0; - m_decimation = 0; + m_decimation = 2; } QByteArray RTLSDRInput::Settings::serialize() const @@ -111,7 +111,7 @@ bool RTLSDRInput::startInput(int device) qDebug("RTLSDRInput open: %s %s, SN: %s", vendor, product, serial); m_deviceDescription = QString("%1 (SN %2)").arg(product).arg(serial); - if((res = rtlsdr_set_sample_rate(m_dev, 2000000)) < 0) { + if((res = rtlsdr_set_sample_rate(m_dev, 1000000)) < 0) { qCritical("could not set sample rate: %s", strerror(errno)); goto failed; } @@ -182,7 +182,7 @@ const QString& RTLSDRInput::getDeviceDescription() const int RTLSDRInput::getSampleRate() const { - return 2000000 / (1 << m_settings.m_decimation); + return 1000000 / (1 << m_settings.m_decimation); } quint64 RTLSDRInput::getCenterFrequency() const diff --git a/sdrbase/dsp/dspengine.cpp b/sdrbase/dsp/dspengine.cpp index 369403f..2427d23 100644 --- a/sdrbase/dsp/dspengine.cpp +++ b/sdrbase/dsp/dspengine.cpp @@ -325,7 +325,7 @@ DSPEngine::State DSPEngine::gotoIdle() (*it)->stop(); m_sampleSource->stopInput(); m_deviceDescription.clear(); - m_audioOutput.stop(); + //m_audioOutput.stop(); m_sampleRate = 0; return StIdle; @@ -357,7 +357,7 @@ DSPEngine::State DSPEngine::gotoRunning() return gotoError("Could not start sample source"); m_deviceDescription = m_sampleSource->getDeviceDescription(); - m_audioOutput.start(0, 44100); + //m_audioOutput.start(0, 44100); for(SampleSinks::const_iterator it = m_sampleSinks.begin(); it != m_sampleSinks.end(); it++) (*it)->start(); m_sampleRate = 0; // make sure, report is sent @@ -489,10 +489,10 @@ void DSPEngine::handleMessages() m_sampleSinks.remove(sink); message->completed(); } else if(DSPAddAudioSource::match(message)) { - m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo()); + //m_audioOutput.addFifo(((DSPAddAudioSource*)message)->getAudioFifo()); message->completed(); } else if(DSPRemoveAudioSource::match(message)) { - m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo()); + //m_audioOutput.removeFifo(((DSPAddAudioSource*)message)->getAudioFifo()); message->completed(); } else if(DSPConfigureCorrection::match(message)) { DSPConfigureCorrection* conf = (DSPConfigureCorrection*)message; diff --git a/sdrbase/dsp/spectrumvis.cpp b/sdrbase/dsp/spectrumvis.cpp index 01c7dbe..ad70493 100644 --- a/sdrbase/dsp/spectrumvis.cpp +++ b/sdrbase/dsp/spectrumvis.cpp @@ -5,12 +5,11 @@ #define MAX_FFT_SIZE 4096 -#ifdef _WIN32 -double log2f(double n) +inline float log2f(float f) { - return log(n) / log(2.0); + return logf(f) * (float) (1.0 / M_LN2); } -#endif + SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) : SampleSink(), diff --git a/sdrbase/gui/glscope.cpp b/sdrbase/gui/glscope.cpp index 73c0d62..423b560 100644 --- a/sdrbase/gui/glscope.cpp +++ b/sdrbase/gui/glscope.cpp @@ -3,12 +3,13 @@ #include "gui/glscope.h" #include "dsp/dspengine.h" -#ifdef _WIN32 -static double log2f(double n) + + +inline float log2f(float f) { - return log(n) / log(2.0); + return logf(f) * (float) (1.0 / M_LN2); } -#endif + GLScope::GLScope(QWidget* parent) : QGLWidget(parent), @@ -110,6 +111,7 @@ void GLScope::resizeGL(int width, int height) void GLScope::paintGL() { +#if 0 if(!m_mutex.tryLock(2)) return; @@ -172,7 +174,7 @@ void GLScope::paintGL() glScalef(m_glScopeRect1.width(), -(m_glScopeRect1.height() / 2) * m_amp1, 1); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_LINE_SMOOTH); + //glEnable(GL_LINE_SMOOTH); glLineWidth(1.0f); glColor4f(0, 1, 0, 0.3f); glBegin(GL_LINE_LOOP); @@ -184,7 +186,7 @@ void GLScope::paintGL() glVertex2f(0, m_triggerLevelLow); glVertex2f(1, m_triggerLevelLow); glEnd(); - glDisable(GL_LINE_SMOOTH); + //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -194,7 +196,7 @@ void GLScope::paintGL() glScalef(m_glScopeRect1.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect1.height() / 2) * m_amp1, 1); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_LINE_SMOOTH); + //glEnable(GL_LINE_SMOOTH); glLineWidth(1.0f); glColor4f(1, 1, 0, 0.4f); int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000; @@ -213,7 +215,7 @@ void GLScope::paintGL() glVertex2f(i - start, v); } glEnd(); - glDisable(GL_LINE_SMOOTH); + //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -259,7 +261,7 @@ void GLScope::paintGL() glScalef(m_glScopeRect2.width(), -(m_glScopeRect2.height() / 2) * m_amp2, 1); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_LINE_SMOOTH); + //glEnable(GL_LINE_SMOOTH); glLineWidth(1.0f); glColor4f(0, 1, 0, 0.3f); glBegin(GL_LINE_LOOP); @@ -271,7 +273,7 @@ void GLScope::paintGL() glVertex2f(0, m_triggerLevelLow); glVertex2f(1, m_triggerLevelLow); glEnd(); - glDisable(GL_LINE_SMOOTH); + //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -281,7 +283,7 @@ void GLScope::paintGL() glScalef(m_glScopeRect2.width() * (float)m_timeBase / (float)(m_displayTrace->size() - 1), -(m_glScopeRect2.height() / 2) * m_amp2, 1); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_LINE_SMOOTH); + //glEnable(GL_LINE_SMOOTH); glLineWidth(1.0f); glColor4f(1, 1, 0, 0.4f); int start = m_timeOfsProMill * (m_displayTrace->size() - (m_displayTrace->size() / m_timeBase)) / 1000; @@ -300,13 +302,14 @@ void GLScope::paintGL() glVertex2f(i - start, v); } glEnd(); - glDisable(GL_LINE_SMOOTH); + //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } glPopMatrix(); m_dataChanged = false; m_mutex.unlock(); +#endif } void GLScope::mousePressEvent(QMouseEvent* event) diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp index 560f33c..534b5de 100644 --- a/sdrbase/gui/glspectrum.cpp +++ b/sdrbase/gui/glspectrum.cpp @@ -15,9 +15,12 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#if 0 #include +#endif #include #include "gui/glspectrum.h" +#include "util/glmath.h" GLSpectrum::GLSpectrum(QWidget* parent) : QGLWidget(parent), @@ -315,7 +318,7 @@ void GLSpectrum::updateHistogram(const std::vector& spectrum) m_histogramHoldoffCount = m_histogramHoldoffBase; } -//#define NO_AVX +#define NO_AVX #ifdef NO_AVX for(int i = 0; i < m_fftSize; i++) { int v = (int)((spectrum[i] - m_referenceLevel) * 100.0 / m_powerRange + 100.0); @@ -398,7 +401,46 @@ void GLSpectrum::updateHistogram(const std::vector& spectrum) void GLSpectrum::initializeGL() { - glDisable(GL_DEPTH_TEST); + initeglcompat(); + glDisable(GL_DEPTH_TEST); + + QGLShader *vshader = new QGLShader(QGLShader::Vertex); + QGLShader *fshader = new QGLShader(QGLShader::Fragment); + + const char *vsrc = + "attribute highp vec4 vertex;\n" + "attribute highp vec4 texCoord;\n" + "uniform mediump mat4 mvmatrix;\n" + "varying highp vec4 texc;\n" + "void main(void)\n" + "{\n" + " gl_Position = mvmatrix * vertex;\n" + " texc = texCoord;\n" + "}\n"; + + const char *fsrc = + "varying highp vec4 texc;\n" + "uniform sampler2D tex;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = texture2D(tex, texc.st);\n" + "}\n"; + + vshader->compileSourceCode(vsrc); + fshader->compileSourceCode(fsrc); + + shaderprog.addShader(vshader); + shaderprog.addShader(fshader); + shaderprog.link(); + + vertexAtt = shaderprog.attributeLocation("vertex"); + texcoordAtt = shaderprog.attributeLocation("texCoord"); + matrixUni = shaderprog.uniformLocation("mvmatrix"); + texUni = shaderprog.uniformLocation("tex"); + + //init base matrix here + glScalef(2.0, -2.0, 1.0); + glTranslatef(-0.50, -0.5, 0); } void GLSpectrum::resizeGL(int width, int height) @@ -408,6 +450,24 @@ void GLSpectrum::resizeGL(int width, int height) m_changesPending = true; } +void GLSpectrum::GLtexBox(){ + GLfloat vertices[] = {0,0,0, 1,0,0, 0,1,0, 1,1,0}; + GLfloat texcoords[] = {0, 0, 1, 0, 0, 1, 1, 1}; + + shaderprog.setUniformValue(matrixUni, getMV()); + shaderprog.setUniformValue(texUni, 0); + shaderprog.setAttributeArray(vertexAtt, vertices, 3); + shaderprog.setAttributeArray(texcoordAtt, texcoords, 2); + + shaderprog.enableAttributeArray(vertexAtt); + shaderprog.enableAttributeArray(texcoordAtt); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + shaderprog.disableAttributeArray(vertexAtt); + shaderprog.disableAttributeArray(texcoordAtt); +} + void GLSpectrum::paintGL() { if(!m_mutex.tryLock(2)) @@ -421,13 +481,11 @@ void GLSpectrum::paintGL() return; } - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); - glPushMatrix(); - glScalef(2.0, -2.0, 1.0); - glTranslatef(-0.50, -0.5, 0); - + shaderprog.bind(); +#if 1 // paint waterfall if(m_displayWaterfall) { glPushMatrix(); @@ -438,7 +496,7 @@ void GLSpectrum::paintGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); +// glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); for(int i = 0; i < m_waterfallBufferPos; i++) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, m_waterfallTexturePos, m_fftSize, 1, GL_RGBA, GL_UNSIGNED_BYTE, m_waterfallBuffer->scanLine(i)); m_waterfallTexturePos = (m_waterfallTexturePos + 1) % m_waterfallTextureHeight; @@ -446,58 +504,28 @@ void GLSpectrum::paintGL() m_waterfallBufferPos = 0; float prop_y = m_waterfallTexturePos / (m_waterfallTextureHeight - 1.0); float off = 1.0 / (m_waterfallTextureHeight - 1.0); - glEnable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glTexCoord2f(0, prop_y + 1 - off); - glVertex2f(0, m_invertedWaterfall ? 0 : 1); - glTexCoord2f(1, prop_y + 1 - off); - glVertex2f(1, m_invertedWaterfall ? 0 : 1); - glTexCoord2f(1, prop_y); - glVertex2f(1, m_invertedWaterfall ? 1 : 0); - glTexCoord2f(0, prop_y); - glVertex2f(0, m_invertedWaterfall ? 1 : 0); - glEnd(); - glDisable(GL_TEXTURE_2D); - // paint channels - if(m_mouseInside) { - for(int i = 0; i < m_channelMarkerStates.size(); ++i) { - ChannelMarkerState* dv = m_channelMarkerStates[i]; - if(dv->m_channelMarker->getVisible()) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f); - glPushMatrix(); - glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0); - glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1); - glBegin(GL_QUADS); - glVertex2f(0, 0); - glVertex2f(1, 0); - glVertex2f(1, 1); - glVertex2f(0, 1); - glEnd(); - glDisable(GL_BLEND); - glPopMatrix(); - } - } - } + GLfloat wavert1[] = {0,0,0, 1,0,0, 0,1,0, 1,1,0}; + GLfloat wavert2[] = {0,1,0, 1,1,0, 0,0,0, 1,0,0}; + GLfloat watexcoor[] = { 0, prop_y, 1, prop_y, 0, prop_y + 1 - off, 1, prop_y + 1 - off}; - // draw rect around - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glLineWidth(1.0f); - glColor4f(1, 1, 1, 0.5); - glBegin(GL_LINE_LOOP); - glVertex2f(1, 1); - glVertex2f(0, 1); - glVertex2f(0, 0); - glVertex2f(1, 0); - glEnd(); - glDisable(GL_BLEND); + shaderprog.setUniformValue(matrixUni, getMV()); + shaderprog.setUniformValue(texUni, 0); + shaderprog.setAttributeArray(vertexAtt, m_invertedWaterfall ? wavert2 : wavert1, 3); + shaderprog.setAttributeArray(texcoordAtt, watexcoor, 2); + + shaderprog.enableAttributeArray(vertexAtt); + shaderprog.enableAttributeArray(texcoordAtt); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + shaderprog.disableAttributeArray(vertexAtt); + shaderprog.disableAttributeArray(texcoordAtt); glPopMatrix(); } - +#endif +#if 1 // paint histogram if(m_displayHistogram || m_displayMaxHold) { glPushMatrix(); @@ -522,100 +550,40 @@ void GLSpectrum::paintGL() glBindTexture(GL_TEXTURE_2D, m_histogramTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_fftSize, 100, GL_RGBA, GL_UNSIGNED_BYTE, m_histogramBuffer->scanLine(0)); - glEnable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glTexCoord2f(0, 0); - glVertex2f(0, 0); - glTexCoord2f(1, 0); - glVertex2f(1, 0); - glTexCoord2f(1, 1); - glVertex2f(1, 1); - glTexCoord2f(0, 1); - glVertex2f(0, 1); - glEnd(); - glDisable(GL_TEXTURE_2D); - } - // paint channels - if(m_mouseInside) { - for(int i = 0; i < m_channelMarkerStates.size(); ++i) { - ChannelMarkerState* dv = m_channelMarkerStates[i]; - if(dv->m_channelMarker->getVisible()) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.3f); - glPushMatrix(); - glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0); - glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1); - glBegin(GL_QUADS); - glVertex2f(0, 0); - glVertex2f(1, 0); - glVertex2f(1, 1); - glVertex2f(0, 1); - glEnd(); - glDisable(GL_BLEND); - glColor3f(0.8f, 0.8f, 0.6f); - glBegin(GL_LINE_LOOP); - glVertex2f(0.5, 0); - glVertex2f(0.5, 1); - glEnd(); - glPopMatrix(); - } - } + GLtexBox(); } - - // draw rect around - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glLineWidth(1.0f); - glColor4f(1, 1, 1, 0.5); - glBegin(GL_LINE_LOOP); - glVertex2f(1, 1); - glVertex2f(0, 1); - glVertex2f(0, 0); - glVertex2f(1, 0); - glEnd(); - glDisable(GL_BLEND); glPopMatrix(); } - +#endif +#if 1 // paint left scales (time and power) if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) { glBindTexture(GL_TEXTURE_2D, m_leftMarginTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glPushMatrix(); glTranslatef(m_glLeftScaleRect.x(), m_glLeftScaleRect.y(), 0); glScalef(m_glLeftScaleRect.width(), m_glLeftScaleRect.height(), 1); - glEnable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glTexCoord2f(0, 1); - glVertex2f(0, 1); - glTexCoord2f(1, 1); - glVertex2f(1, 1); - glTexCoord2f(1, 0); - glVertex2f(1, 0); - glTexCoord2f(0, 0); - glVertex2f(0, 0); - glEnd(); - glDisable(GL_TEXTURE_2D); + GLtexBox(); glPopMatrix(); } - +#endif +#if 1 // paint frequency scale if(m_displayWaterfall || m_displayMaxHold || m_displayHistogram ) { glBindTexture(GL_TEXTURE_2D, m_frequencyTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -623,177 +591,12 @@ void GLSpectrum::paintGL() glTranslatef(m_glFrequencyScaleRect.x(), m_glFrequencyScaleRect.y(), 0); glScalef(m_glFrequencyScaleRect.width(), m_glFrequencyScaleRect.height(), 1); - glEnable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glTexCoord2f(0, 1); - glVertex2f(0, 1); - glTexCoord2f(1, 1); - glVertex2f(1, 1); - glTexCoord2f(1, 0); - glVertex2f(1, 0); - glTexCoord2f(0, 0); - glVertex2f(0, 0); - glEnd(); - glDisable(GL_TEXTURE_2D); - glPopMatrix(); - - // paint channels - glPushMatrix(); - glTranslatef(m_glWaterfallRect.x(), m_glFrequencyScaleRect.y(), 0); - glScalef(m_glWaterfallRect.width(), m_glFrequencyScaleRect.height(), 1); - for(int i = 0; i < m_channelMarkerStates.size(); ++i) { - ChannelMarkerState* dv = m_channelMarkerStates[i]; - if(dv->m_channelMarker->getVisible()) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.5f); - glPushMatrix(); - glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0); - glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1); - glBegin(GL_QUADS); - glVertex2f(0, 0); - glVertex2f(1, 0); - glVertex2f(1, 1); - glVertex2f(0, 1); - glEnd(); - glDisable(GL_BLEND); - glPopMatrix(); - } - } + GLtexBox(); glPopMatrix(); + glDisable(GL_BLEND); } - - // paint max hold lines on top of histogram - if(m_displayMaxHold) { - if(m_maxHold.size() < m_fftSize) - m_maxHold.resize(m_fftSize); - for(int i = 0; i < m_fftSize; i++) { - int j; - quint8* bs = m_histogram + i * 100; - for(j = 99; j > 1; j--) { - if(bs[j] > 0) - break; - } - // TODO: ((bs[j] * (float)j) + (bs[j + 1] * (float)(j + 1))) / (bs[j] + bs[j + 1]) - j = j - 99; - m_maxHold[i] = (j * m_powerRange) / 99.0 + m_referenceLevel; - } - - glPushMatrix(); - glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0); - glScalef(m_glHistogramRect.width() / (float)(m_fftSize - 1), -m_glHistogramRect.height() / m_powerRange, 1); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_LINE_SMOOTH); - glLineWidth(1.0f); - glColor3f(1, 0, 0); - Real bottom = -m_powerRange; - glBegin(GL_LINE_STRIP); - for(int i = 0; i < m_fftSize; i++) { - Real v = m_maxHold[i] - m_referenceLevel; - if(v > 0) - v = 0; - else if(v < bottom) - v = bottom; - glVertex2f(i, v); - } - glEnd(); - glDisable(GL_LINE_SMOOTH); - glPopMatrix(); - } - - // paint waterfall grid - if(m_displayWaterfall && m_displayGrid) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glLineWidth(1.0f); - glColor4f(1, 1, 1, 0.05f); - - glPushMatrix(); - glTranslatef(m_glWaterfallRect.x(), m_glWaterfallRect.y(), 0); - glScalef(m_glWaterfallRect.width(), m_glWaterfallRect.height(), 1); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - tickList = &m_timeScale.getTickList(); - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float y = tick->pos / m_timeScale.getSize(); - glBegin(GL_LINE_LOOP); - glVertex2f(0, y); - glVertex2f(1, y); - glEnd(); - } - } - } - - tickList = &m_frequencyScale.getTickList(); - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_frequencyScale.getSize(); - glBegin(GL_LINE_LOOP); - glVertex2f(x, 0); - glVertex2f(x, 1); - glEnd(); - } - } - } - - glPopMatrix(); - } - - // paint histogram grid - if((m_displayHistogram || m_displayMaxHold) && (m_displayGrid)) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glLineWidth(1.0f); - glColor4f(1, 1, 1, 0.05f); - - glPushMatrix(); - glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0); - glScalef(m_glHistogramRect.width(), m_glHistogramRect.height(), 1); - - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; - - tickList = &m_powerScale.getTickList(); - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float y = tick->pos / m_powerScale.getSize(); - glBegin(GL_LINE_LOOP); - glVertex2f(0, y); - glVertex2f(1, y); - glEnd(); - } - } - } - - tickList = &m_frequencyScale.getTickList(); - for(int i= 0; i < tickList->count(); i++) { - tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_frequencyScale.getSize(); - glBegin(GL_LINE_LOOP); - glVertex2f(x, 0); - glVertex2f(x, 1); - glEnd(); - } - } - } - - glPopMatrix(); - } - - glPopMatrix(); - +#endif + shaderprog.release(); m_mutex.unlock(); } diff --git a/sdrbase/gui/glspectrumgui.cpp b/sdrbase/gui/glspectrumgui.cpp index 1fbaaf2..5a0a1e0 100644 --- a/sdrbase/gui/glspectrumgui.cpp +++ b/sdrbase/gui/glspectrumgui.cpp @@ -17,7 +17,7 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : m_refLevel(0), m_powerRange(100), m_decay(0), - m_displayWaterfall(false), + m_displayWaterfall(true), m_invertedWaterfall(false), m_displayMaxHold(true), m_displayHistogram(true), @@ -52,7 +52,7 @@ void GLSpectrumGUI::resetToDefaults() m_refLevel = 0; m_powerRange = 100; m_decay = 0; - m_displayWaterfall = false; + m_displayWaterfall = true; m_invertedWaterfall = false; m_displayMaxHold = true; m_displayHistogram = true; diff --git a/sdrbase/gui/scopewindow.ui b/sdrbase/gui/scopewindow.ui index d521af3..97ec1d3 100644 --- a/sdrbase/gui/scopewindow.ui +++ b/sdrbase/gui/scopewindow.ui @@ -109,10 +109,10 @@ - + 16 @@ -135,10 +135,10 @@ - + 16 diff --git a/sdrbase/mainwindow.cpp b/sdrbase/mainwindow.cpp index 9cbfb0f..0058adf 100644 --- a/sdrbase/mainwindow.cpp +++ b/sdrbase/mainwindow.cpp @@ -64,30 +64,30 @@ MainWindow::MainWindow(QWidget* parent) : removeDockWidget(ui->inputDock); removeDockWidget(ui->processingDock); removeDockWidget(ui->presetDock); - removeDockWidget(ui->channelDock); - addDockWidget(Qt::LeftDockWidgetArea, ui->inputDock); - addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock); - addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock); - addDockWidget(Qt::RightDockWidgetArea, ui->channelDock); - ui->inputDock->show(); - ui->processingDock->show(); - ui->presetDock->show(); - ui->channelDock->show(); +// removeDockWidget(ui->channelDock); + addDockWidget(Qt::LeftDockWidgetArea, ui->inputDock); + addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock); +// addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock); +// addDockWidget(Qt::RightDockWidgetArea, ui->channelDock); +// ui->inputDock->show(); +// ui->processingDock->show(); +// ui->presetDock->show(); + //ui->channelDock->show(); ui->menu_Window->addAction(ui->inputDock->toggleViewAction()); ui->menu_Window->addAction(ui->processingDock->toggleViewAction()); - ui->menu_Window->addAction(ui->presetDock->toggleViewAction()); - ui->menu_Window->addAction(ui->channelDock->toggleViewAction()); +// ui->menu_Window->addAction(ui->presetDock->toggleViewAction()); + //ui->menu_Window->addAction(ui->channelDock->toggleViewAction()); connect(m_messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection); connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); m_statusTimer.start(500); - m_pluginManager->loadPlugins(); - bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); - m_pluginManager->fillSampleSourceSelector(ui->sampleSource); - ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); + m_pluginManager->loadPlugins(); + bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); + m_pluginManager->fillSampleSourceSelector(ui->sampleSource); + ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); m_dspEngine->start(); @@ -98,12 +98,12 @@ MainWindow::MainWindow(QWidget* parent) : loadSettings(); - int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings - if(sampleSourceIndex >= 0) { - bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); - ui->sampleSource->setCurrentIndex(sampleSourceIndex); - ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); - } + int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings + if(sampleSourceIndex >= 0) { + bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); + ui->sampleSource->setCurrentIndex(sampleSourceIndex); + ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); + } loadSettings(m_settings.getCurrent()); @@ -143,9 +143,9 @@ void MainWindow::addChannelCreateAction(QAction* action) void MainWindow::addChannelRollup(QWidget* widget) { - ((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget); - ui->channelDock->show(); - ui->channelDock->raise(); +// ((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget); +// ui->channelDock->show(); +// ui->channelDock->raise(); } void MainWindow::addViewAction(QAction* action) diff --git a/sdrbase/mainwindow.ui b/sdrbase/mainwindow.ui index 60e2c43..160a97e 100644 --- a/sdrbase/mainwindow.ui +++ b/sdrbase/mainwindow.ui @@ -318,7 +318,7 @@ - + E&xit @@ -444,12 +444,12 @@
gui/glspectrumgui.h
1 - + presetTree diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index 3338c01..55a3b41 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -256,6 +256,9 @@ int PluginManager::selectSampleSource(const QString& source) void PluginManager::loadPlugins(const QDir& dir) { QDir pluginsDir(dir); + QStringList filters; + filters << "libsdrange*.so" << "input*dll"; + pluginsDir.setNameFilters(filters); foreach(QString fileName, pluginsDir.entryList(QDir::Files)) { QPluginLoader* loader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName)); PluginInterface* plugin = qobject_cast(loader->instance()); diff --git a/sdrbase/settings/preset.cpp b/sdrbase/settings/preset.cpp index 6680caa..7e826c4 100644 --- a/sdrbase/settings/preset.cpp +++ b/sdrbase/settings/preset.cpp @@ -13,9 +13,9 @@ void Preset::resetToDefaults() m_centerFrequency = 0; m_spectrumConfig.clear(); m_scopeConfig.clear(); - m_dcOffsetCorrection = true; - m_iqImbalanceCorrection = true; - m_showScope = true; + m_dcOffsetCorrection = false; + m_iqImbalanceCorrection = false; + m_showScope = false; m_layout.clear(); m_spectrumConfig.clear(); m_channelConfigs.clear(); diff --git a/sdrbase/settings/settings.cpp b/sdrbase/settings/settings.cpp index b7012bc..fa368c2 100644 --- a/sdrbase/settings/settings.cpp +++ b/sdrbase/settings/settings.cpp @@ -15,6 +15,7 @@ Settings::~Settings() void Settings::load() { +#if 0 QSettings s; m_preferences.deserialize(qUncompress(QByteArray::fromBase64(s.value("preferences").toByteArray()))); @@ -31,10 +32,12 @@ void Settings::load() s.endGroup(); } } +#endif } void Settings::save() const { +#if 0 QSettings s; s.setValue("preferences", qCompress(m_preferences.serialize()).toBase64()); @@ -52,6 +55,7 @@ void Settings::save() const s.setValue("data", qCompress(m_presets[i]->serialize()).toBase64()); s.endGroup(); } +#endif } void Settings::resetToDefaults() diff --git a/sdrbase/util/glmath.cpp b/sdrbase/util/glmath.cpp new file mode 100644 index 0000000..3679ff9 --- /dev/null +++ b/sdrbase/util/glmath.cpp @@ -0,0 +1,32 @@ +#include +#include +#include + +static QMatrix4x4 mv[20]; +static int pos=0; +static std::vector stack; + +void initeglcompat() { + mv[0].setToIdentity(); +}; + +void glPushMatrix(){ + pos++; + mv[pos] = mv[pos-1]; +} + +void glPopMatrix(){ + if(pos >0){ + pos--; + } +} +void glScalef(float x, float y, float z){ + mv[pos].scale(x,y,z); +} +void glTranslatef(float x, float y, float z){ + mv[pos].translate(x,y,z); +} +QMatrix4x4 getMV() { + return mv[pos]; +} +