From 8d43ead373de5d60cbf3e8486dea929b42fdc615 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 28 Feb 2016 22:03:37 +0100 Subject: [PATCH] Move to Open GL ES: replace glBegin/glEnd seqiences --- CMakeLists.txt | 3 +- sdrbase/gui/aboutdialog.ui | 2 +- sdrbase/gui/glscope.cpp | 462 ++++++++++++++++++++++++++++++++++++- sdrbase/gui/glspectrum.cpp | 355 +++++++++++++++++++++++++++- 4 files changed, 810 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a1502fd5..6bcd8da9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.2) +cmake_minimum_required(VERSION 3.1.0) cmake_policy(SET CMP0043 OLD) # use, i.e. don't skip the full RPATH for the build tree @@ -307,6 +307,7 @@ if(FFTW3F_FOUND) endif(FFTW3F_FOUND) set_target_properties(sdrbase PROPERTIES DEFINE_SYMBOL "sdrangel_EXPORTS") +target_compile_features(sdrbase PRIVATE cxx_generalized_initializers) # cmake >= 3.1.0 qt5_use_modules(sdrbase Core Widgets OpenGL Multimedia) diff --git a/sdrbase/gui/aboutdialog.ui b/sdrbase/gui/aboutdialog.ui index 40980b5b3..8647494d0 100644 --- a/sdrbase/gui/aboutdialog.ui +++ b/sdrbase/gui/aboutdialog.ui @@ -84,7 +84,7 @@ - <html><head/><body><p>Version 1.1.2 - Copyright (C) 2015-2016 Edouard Griffiths, F4EXB. </p><p>Code at <a href="https://github.com/f4exb/sdrangel"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/f4exb/sdrangel</span></a> This is a complete redesign from RTL-SDRangelove at <a href="https://github.com/hexameron/rtl-sdrangelove"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/hexameron/rtl-sdrangelove</span></a></p><p>Many thanks to the original developers:</p><p>The osmocom developer team - especially horizon, Hoernchen &amp; tnt.</p><p>Christian Daniel from maintech GmbH.</p><p>John Greb (hexameron) for the contributions in RTL-SDRangelove</p><p>The following rules apply to the SDRangel main application and libsdrbase:<br/>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; either version 2 of the License, or (at your option) any later version. 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. You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/"><span style=" text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/</span></a>.</p><p>For the license of installed plugins, look into the plugin list.</p></body></html> + <html><head/><body><p>Version 1.1.3 - Copyright (C) 2015-2016 Edouard Griffiths, F4EXB. </p><p>Code at <a href="https://github.com/f4exb/sdrangel"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/f4exb/sdrangel</span></a> This is a complete redesign from RTL-SDRangelove at <a href="https://github.com/hexameron/rtl-sdrangelove"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/hexameron/rtl-sdrangelove</span></a></p><p>Many thanks to the original developers:</p><p>The osmocom developer team - especially horizon, Hoernchen &amp; tnt.</p><p>Christian Daniel from maintech GmbH.</p><p>John Greb (hexameron) for the contributions in RTL-SDRangelove</p><p>The following rules apply to the SDRangel main application and libsdrbase:<br/>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; either version 2 of the License, or (at your option) any later version. 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. You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/"><span style=" text-decoration: underline; color:#0000ff;">http://www.gnu.org/licenses/</span></a>.</p><p>For the license of installed plugins, look into the plugin list.</p></body></html> true diff --git a/sdrbase/gui/glscope.cpp b/sdrbase/gui/glscope.cpp index a2b8fbc36..ccd665cf9 100644 --- a/sdrbase/gui/glscope.cpp +++ b/sdrbase/gui/glscope.cpp @@ -1,4 +1,3 @@ -#include "util/gleshelp.h" #include #include #include "gui/glscope.h" @@ -256,12 +255,28 @@ void GLScope::paintGL() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); glColor4f(1, 1, 1, 0.5); +#ifdef GL_DEPRECATED glBegin(GL_LINE_LOOP); glVertex2f(1, 1); glVertex2f(0, 1); glVertex2f(0, 0); glVertex2f(1, 0); glEnd(); +#else + { + GLfloat q3[] { + 1, 1, + 0, 1, + 0, 0, + 1, 0 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_LOOP, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glDisable(GL_BLEND); // paint grid @@ -277,6 +292,7 @@ void GLScope::paintGL() } // Horizontal Y1 tickList = &m_y1Scale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -289,9 +305,34 @@ void GLScope::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float y = 1 - (tick->pos / m_y1Scale.getSize()); + q3[4*effectiveTicks] = 0; + q3[4*effectiveTicks+1] = y; + q3[4*effectiveTicks+2] = 1; + q3[4*effectiveTicks+3] = y; + effectiveTicks++; + } + } + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif // Vertical X1 glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); tickList = &m_x1Scale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -304,6 +345,30 @@ void GLScope::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float x = tick->pos / m_x1Scale.getSize(); + q3[4*effectiveTicks] = x; + q3[4*effectiveTicks+1] = 0; + q3[4*effectiveTicks+2] = x; + q3[4*effectiveTicks+3] = 1; + effectiveTicks++; + } + } + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); // paint left #1 scale @@ -316,6 +381,7 @@ void GLScope::paintGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -326,6 +392,29 @@ void GLScope::paintGL() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); @@ -339,6 +428,7 @@ void GLScope::paintGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -349,6 +439,29 @@ void GLScope::paintGL() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); @@ -366,11 +479,12 @@ void GLScope::paintGL() //glEnable(GL_LINE_SMOOTH); glLineWidth(1.0f); glColor4f(0, 1, 0, 0.4); - glBegin(GL_LINE_LOOP); - float posLimit = 1.0 / m_amp1; float negLimit = -1.0 / m_amp1; +#ifdef GL_DEPRECATED + glBegin(GL_LINE_LOOP); + if ((m_triggerChannel == ScopeVis::TriggerChannelI) || (m_triggerChannel == ScopeVis::TriggerMagLin) || (m_triggerChannel == ScopeVis::TriggerMagDb)) @@ -383,6 +497,25 @@ void GLScope::paintGL() } glEnd(); +#else + if ((m_triggerChannel == ScopeVis::TriggerChannelI) + || (m_triggerChannel == ScopeVis::TriggerMagLin) + || (m_triggerChannel == ScopeVis::TriggerMagDb)) + { + if ((m_triggerLevelDis1 > negLimit) && (m_triggerLevelDis1 < posLimit)) + { + GLfloat q3[] { + 0, m_triggerLevelDis1, + 1, m_triggerLevelDis1 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2); + glDisableClientState(GL_VERTEX_ARRAY); + } + } +#endif //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -405,6 +538,7 @@ void GLScope::paintGL() float posLimit = 1.0 / m_amp1; float negLimit = -1.0 / m_amp1; +#ifdef GL_DEPRECATED glBegin(GL_LINE_STRIP); for(int i = start; i < end; i++) @@ -438,7 +572,48 @@ void GLScope::paintGL() m_nbPow = end - start; glEnd(); +#else + { + GLfloat q3[2*(end -start)]; + for (int i = start; i < end; i++) + { + float v = (*m_displayTrace)[i].real(); + if(v > posLimit) + v = posLimit; + else if(v < negLimit) + v = negLimit; + + q3[2*i] = i - start; + q3[2*i + 1] = v; + + if ((m_mode == ModeMagdBPha) || (m_mode == ModeMagdBDPha)) + { + if (i == start) + { + m_maxPow = m_powTrace[i]; + m_sumPow = m_powTrace[i]; + } + else + { + if (m_powTrace[i] > m_maxPow) + { + m_maxPow = m_powTrace[i]; + } + + m_sumPow += m_powTrace[i]; + } + } + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_STRIP, 0, end - start); + glDisableClientState(GL_VERTEX_ARRAY); + + m_nbPow = end - start; + } +#endif //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -472,6 +647,7 @@ void GLScope::paintGL() float posLimit = 1.0 / m_amp2; float negLimit = -1.0 / m_amp2; +#ifdef GL_DEPRECATED glBegin(GL_LINE_STRIP); for(int i = start; i < end; i++) @@ -485,6 +661,27 @@ void GLScope::paintGL() } glEnd(); +#else + { + GLfloat q3[2*(end - start)]; + + for(int i = start; i < end; i++) + { + float v = (*m_displayTrace)[i].imag(); + if(v > posLimit) + v = posLimit; + else if(v < negLimit) + v = negLimit; + q3[2*i] = i - start; + q3[2*i + 1] = v; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_STRIP, 0, end - start); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); } @@ -501,6 +698,7 @@ void GLScope::paintGL() glColor4f(0.25f, 1, 1, m_displayGridIntensity / 100.0); // Horizontal Y2 tickList = &m_y2Scale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -513,6 +711,30 @@ void GLScope::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float y = 1 - (tick->pos / m_y2Scale.getSize()); + q3[4*effectiveTicks] = 0; + q3[4*effectiveTicks+1] = y; + q3[4*effectiveTicks+2] = 1; + q3[4*effectiveTicks+3] = y; + effectiveTicks++; + } + } + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); // Paint secondary scale @@ -525,6 +747,7 @@ void GLScope::paintGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -535,6 +758,29 @@ void GLScope::paintGL() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); } @@ -552,12 +798,28 @@ void GLScope::paintGL() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); glColor4f(1, 1, 1, 0.5); +#ifdef GL_DEPRECATED glBegin(GL_LINE_LOOP); glVertex2f(1, 1); glVertex2f(0, 1); glVertex2f(0, 0); glVertex2f(1, 0); glEnd(); +#else + { + GLfloat q3[] { + 1, 1, + 0, 1, + 0, 0, + 1, 0 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_LOOP, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glDisable(GL_BLEND); // paint grid @@ -569,6 +831,7 @@ void GLScope::paintGL() glColor4f(1, 1, 1, m_displayGridIntensity / 100.0); // Horizontal Y2 tickList = &m_y2Scale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -581,8 +844,33 @@ void GLScope::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float y = 1 - (tick->pos / m_y2Scale.getSize()); + q3[4*effectiveTicks] = 0; + q3[4*effectiveTicks+1] = y; + q3[4*effectiveTicks+2] = 1; + q3[4*effectiveTicks+3] = y; + effectiveTicks++; + } + } + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif // Vertical X2 tickList = &m_x2Scale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -595,6 +883,30 @@ void GLScope::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + for(int i= 0; i < tickList->count(); i++) { + tick = &(*tickList)[i]; + if(tick->major) { + if(tick->textSize > 0) { + float x = tick->pos / m_x2Scale.getSize(); + q3[4*effectiveTicks] = x; + q3[4*effectiveTicks+1] = 0; + q3[4*effectiveTicks+2] = x; + q3[4*effectiveTicks+3] = 1; + effectiveTicks++; + } + } + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); // paint left #2 scale @@ -607,6 +919,7 @@ void GLScope::paintGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -617,6 +930,29 @@ void GLScope::paintGL() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); @@ -630,6 +966,7 @@ void GLScope::paintGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -640,6 +977,29 @@ void GLScope::paintGL() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); @@ -654,11 +1014,12 @@ void GLScope::paintGL() //glEnable(GL_LINE_SMOOTH); glLineWidth(1.0f); glColor4f(0, 1, 0, 0.4); - glBegin(GL_LINE_LOOP); float posLimit = 1.0 / m_amp2; float negLimit = -1.0 / m_amp2; +#ifdef GL_DEPRECATED + glBegin(GL_LINE_LOOP); if ((m_triggerChannel == ScopeVis::TriggerChannelQ) || (m_triggerChannel == ScopeVis::TriggerPhase) || (m_triggerChannel == ScopeVis::TriggerDPhase)) @@ -669,8 +1030,26 @@ void GLScope::paintGL() glVertex2f(1, m_triggerLevelDis2); } } - glEnd(); +#else + if ((m_triggerChannel == ScopeVis::TriggerChannelQ) + || (m_triggerChannel == ScopeVis::TriggerPhase) + || (m_triggerChannel == ScopeVis::TriggerDPhase)) + { + if ((m_triggerLevelDis2 > negLimit) && (m_triggerLevelDis2 < posLimit)) + { + GLfloat q3[] { + 0, m_triggerLevelDis2, + 1, m_triggerLevelDis2 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2); + glDisableClientState(GL_VERTEX_ARRAY); + } + } +#endif //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -693,6 +1072,7 @@ void GLScope::paintGL() if(end - start < 2) start--; +#ifdef GL_DEPRECATED glBegin(GL_LINE_STRIP); for(int i = start; i < end; i++) @@ -711,6 +1091,32 @@ void GLScope::paintGL() } glEnd(); +#else + { + GLfloat q3[2*(end - start)]; + + for(int i = start; i < end; i++) + { + float x = (*m_displayTrace)[i].real() * m_amp1; + float y = (*m_displayTrace)[i].imag() * m_amp2; + if(x > 1.0f) + x = 1.0f; + else if(x < -1.0f) + x = -1.0f; + if(y > 1.0f) + y = 1.0f; + else if(y < -1.0f) + y = -1.0f; + q3[2*i] = x; + q3[2*i+1] = y; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_STRIP, 0, end - start); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); } else @@ -729,6 +1135,7 @@ void GLScope::paintGL() start--; float posLimit = 1.0 / m_amp2; float negLimit = -1.0 / m_amp2; +#ifdef GL_DEPRECATED glBegin(GL_LINE_STRIP); for(int i = start; i < end; i++) { float v = (*m_displayTrace)[i].imag(); @@ -739,6 +1146,27 @@ void GLScope::paintGL() glVertex2f(i - start, v); } glEnd(); +#else + { + GLfloat q3[2*(end - start)]; + + for(int i = start; i < end; i++) { + float v = (*m_displayTrace)[i].imag(); + if(v > posLimit) + v = posLimit; + else if(v < negLimit) + v = negLimit; + + q3[2*i] = i - start; + q3[2*i+1] = v; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_STRIP, 0, end - start); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -1004,6 +1432,7 @@ void GLScope::drawPowerOverlay() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -1014,6 +1443,29 @@ void GLScope::drawPowerOverlay() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp index 54d304fab..cbb2ac577 100644 --- a/sdrbase/gui/glspectrum.cpp +++ b/sdrbase/gui/glspectrum.cpp @@ -19,7 +19,6 @@ #include #endif -#include "util/gleshelp.h" #include #include "gui/glspectrum.h" @@ -542,6 +541,7 @@ void GLSpectrum::paintGL() float prop_y = m_waterfallTexturePos / (m_waterfallTextureHeight - 1.0); float off = 1.0 / (m_waterfallTextureHeight - 1.0); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, prop_y + 1 - off); glVertex2f(0, m_invertedWaterfall ? 0 : 1); @@ -552,8 +552,30 @@ void GLSpectrum::paintGL() glTexCoord2f(0, prop_y); glVertex2f(0, m_invertedWaterfall ? 1 : 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, m_invertedWaterfall ? 0.0f : 1.0f, + 1, m_invertedWaterfall ? 0.0f : 1.0f, + 1, m_invertedWaterfall ? 1.0f : 0.0f, + 0, m_invertedWaterfall ? 1.0f : 0.0f + }; + GLfloat tex1[] = { + 0, prop_y + 1 - off, + 1, prop_y + 1 - off, + 1, prop_y, + 0, prop_y + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); - // paint channels if(m_mouseInside) { for(int i = 0; i < m_channelMarkerStates.size(); ++i) { @@ -565,12 +587,28 @@ void GLSpectrum::paintGL() glPushMatrix(); glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0); glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glVertex2f(0, 0); glVertex2f(1, 0); glVertex2f(1, 1); glVertex2f(0, 1); glEnd(); +#else + { + GLfloat q3[] { + 0, 0, + 1, 0, + 1, 1, + 0, 1 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glDisable(GL_BLEND); glPopMatrix(); } @@ -582,12 +620,28 @@ void GLSpectrum::paintGL() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); glColor4f(1, 1, 1, 0.5); +#ifdef GL_DEPRECATED glBegin(GL_LINE_LOOP); glVertex2f(1, 1); glVertex2f(0, 1); glVertex2f(0, 0); glVertex2f(1, 0); glEnd(); +#else + { + GLfloat q3[] { + 1, 1, + 0, 1, + 0, 0, + 1, 0 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_LOOP, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glDisable(GL_BLEND); glPopMatrix(); @@ -621,6 +675,7 @@ void GLSpectrum::paintGL() 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); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(0, 0); @@ -631,6 +686,29 @@ void GLSpectrum::paintGL() glTexCoord2f(0, 1); glVertex2f(0, 1); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 0, + 1, 0, + 1, 1, + 0, 1 + }; + GLfloat tex1[] = { + 0, 0, + 1, 0, + 1, 1, + 0, 1 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); } @@ -646,12 +724,28 @@ void GLSpectrum::paintGL() glPushMatrix(); glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0); glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glVertex2f(0, 0); glVertex2f(1, 0); glVertex2f(1, 1); glVertex2f(0, 1); glEnd(); +#else + { + GLfloat q3[] { + 0, 0, + 1, 0, + 1, 1, + 0, 1 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); } } @@ -665,10 +759,24 @@ void GLSpectrum::paintGL() glPushMatrix(); glTranslatef(dv->m_glRectDsb.x(), dv->m_glRectDsb.y(), 0); glScalef(dv->m_glRectDsb.width(), dv->m_glRectDsb.height(), 1); +#ifdef GL_DEPRECATED glBegin(GL_LINE_LOOP); glVertex2f(0.5, 0); glVertex2f(0.5, 1); glEnd(); +#else + { + GLfloat q3[] { + 0.5, 0, + 0.5, 1 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); } } @@ -679,12 +787,28 @@ void GLSpectrum::paintGL() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(1.0f); glColor4f(1, 1, 1, 0.5); +#ifdef GL_DEPRECATED glBegin(GL_LINE_LOOP); glVertex2f(1, 1); glVertex2f(0, 1); glVertex2f(0, 0); glVertex2f(1, 0); glEnd(); +#else + { + GLfloat q3[] { + 1, 1, + 0, 1, + 0, 0, + 1, 0 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_LOOP, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glDisable(GL_BLEND); glPopMatrix(); } @@ -701,6 +825,7 @@ void GLSpectrum::paintGL() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -711,6 +836,29 @@ void GLSpectrum::paintGL() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); @@ -730,6 +878,7 @@ void GLSpectrum::paintGL() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 1); @@ -740,6 +889,29 @@ void GLSpectrum::paintGL() glTexCoord2f(0, 0); glVertex2f(0, 0); glEnd(); +#else + { + GLfloat vtx1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + GLfloat tex1[] = { + 0, 1, + 1, 1, + 1, 0, + 0, 0 + }; + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +#endif glDisable(GL_TEXTURE_2D); glPopMatrix(); @@ -759,12 +931,28 @@ void GLSpectrum::paintGL() glPushMatrix(); glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0); glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1); +#ifdef GL_DEPRECATED glBegin(GL_QUADS); glVertex2f(0, 0); glVertex2f(1, 0); glVertex2f(1, 0.5); glVertex2f(0, 0.5); glEnd(); +#else + { + GLfloat q3[] { + 0, 0, + 1, 0, + 1, 0.5, + 0, 0.5 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glDisable(GL_BLEND); glPopMatrix(); } @@ -779,10 +967,24 @@ void GLSpectrum::paintGL() glPushMatrix(); glTranslatef(dv->m_glRectDsb.x(), dv->m_glRectDsb.y(), 0); glScalef(dv->m_glRectDsb.width(), dv->m_glRectDsb.height(), 1); +#ifdef GL_DEPRECATED glBegin(GL_LINE_LOOP); glVertex2f(0.5, 0); glVertex2f(0.5, 1); glEnd(); +#else + { + GLfloat q3[] { + 0.5, 0, + 0.5, 1 + }; + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); } } @@ -810,12 +1012,15 @@ void GLSpectrum::paintGL() glPushMatrix(); glTranslatef(m_glHistogramRect.x(), m_glHistogramRect.y(), 0); glScalef(m_glHistogramRect.width() / (float)(m_fftSize - 1), -m_glHistogramRect.height() / m_powerRange, 1); + + Real bottom = -m_powerRange; + glColor4f(1, 0, 0, m_displayTraceIntensity / 100.0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //glEnable(GL_LINE_SMOOTH); glLineWidth(1.0f); - glColor4f(1, 0, 0, m_displayTraceIntensity / 100.0); - Real bottom = -m_powerRange; + +#ifdef GL_DEPRECATED + //glEnable(GL_LINE_SMOOTH); glBegin(GL_LINE_STRIP); for(int i = 0; i < m_fftSize; i++) { Real v = m_maxHold[i] - m_referenceLevel; @@ -826,6 +1031,26 @@ void GLSpectrum::paintGL() glVertex2f(i, v); } glEnd(); +#else + { + GLfloat q3[2*m_fftSize]; + + 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; + q3[2*i] = (Real) i; + q3[2*i+1] = v; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_STRIP, 0, m_fftSize); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -835,12 +1060,15 @@ void GLSpectrum::paintGL() 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); glColor4f(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0); // intense yellow Real bottom = -m_powerRange; + +#ifdef GL_DEPRECATED glBegin(GL_LINE_STRIP); for(int i = 0; i < m_fftSize; i++) { Real v = (*m_currentSpectrum)[i] - m_referenceLevel; @@ -851,6 +1079,26 @@ void GLSpectrum::paintGL() glVertex2f(i, v); } glEnd(); +#else + { + GLfloat q3[2*m_fftSize]; + + for(int i = 0; i < m_fftSize; i++) { + Real v = (*m_currentSpectrum)[i] - m_referenceLevel; + if(v > 0) + v = 0; + else if(v < bottom) + v = bottom; + q3[2*i] = (Real) i; + q3[2*i+1] = v; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINE_STRIP, 0, m_fftSize); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif //glDisable(GL_LINE_SMOOTH); glPopMatrix(); } @@ -871,6 +1119,7 @@ void GLSpectrum::paintGL() const ScaleEngine::Tick* tick; tickList = &m_timeScale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -883,8 +1132,32 @@ void GLSpectrum::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + 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(); + q3[4*effectiveTicks] = 0; + q3[4*effectiveTicks+1] = y; + q3[4*effectiveTicks+2] = 1; + q3[4*effectiveTicks+3] = y; + effectiveTicks++; + } + } + } + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif tickList = &m_frequencyScale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -897,6 +1170,30 @@ void GLSpectrum::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + 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(); + q3[4*effectiveTicks] = x; + q3[4*effectiveTicks+1] = 0; + q3[4*effectiveTicks+2] = x; + q3[4*effectiveTicks+3] = 1; + effectiveTicks++; + } + } + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); } @@ -916,6 +1213,7 @@ void GLSpectrum::paintGL() const ScaleEngine::Tick* tick; tickList = &m_powerScale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -928,8 +1226,32 @@ void GLSpectrum::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + 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(); + q3[4*effectiveTicks] = 0; + q3[4*effectiveTicks+1] = 1-y; + q3[4*effectiveTicks+2] = 1; + q3[4*effectiveTicks+3] = 1-y; + effectiveTicks++; + } + } + } + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif tickList = &m_frequencyScale.getTickList(); +#ifdef GL_DEPRECATED for(int i= 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; if(tick->major) { @@ -942,7 +1264,30 @@ void GLSpectrum::paintGL() } } } +#else + { + GLfloat q3[4*tickList->count()]; + int effectiveTicks = 0; + 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(); + q3[4*effectiveTicks] = x; + q3[4*effectiveTicks+1] = 0; + q3[4*effectiveTicks+2] = x; + q3[4*effectiveTicks+3] = 1; + effectiveTicks++; + } + } + } + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, q3); + glDrawArrays(GL_LINES, 0, 2*effectiveTicks); + glDisableClientState(GL_VERTEX_ARRAY); + } +#endif glPopMatrix(); }