mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-04 14:17:50 -04:00
OpenGL modernization: GLScope modernization #1
This commit is contained in:
parent
1126508b27
commit
1dbd387ea6
@ -27,6 +27,8 @@
|
|||||||
#include "dsp/dsptypes.h"
|
#include "dsp/dsptypes.h"
|
||||||
#include "dsp/scopevis.h"
|
#include "dsp/scopevis.h"
|
||||||
#include "gui/scaleengine.h"
|
#include "gui/scaleengine.h"
|
||||||
|
#include "gui/glshadersimple.h"
|
||||||
|
#include "gui/glshadertextured.h"
|
||||||
#include "util/export.h"
|
#include "util/export.h"
|
||||||
#include "util/bitfieldindex.h"
|
#include "util/bitfieldindex.h"
|
||||||
|
|
||||||
@ -181,6 +183,9 @@ private:
|
|||||||
|
|
||||||
QFont m_powerOverlayFont;
|
QFont m_powerOverlayFont;
|
||||||
|
|
||||||
|
GLShaderSimple m_glShaderSimple;
|
||||||
|
GLShaderTextured m_glShaderLeft1Scale;
|
||||||
|
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
void resizeGL(int width, int height);
|
void resizeGL(int width, int height);
|
||||||
void paintGL();
|
void paintGL();
|
||||||
|
@ -217,6 +217,7 @@ void GLScope::newTrace(const std::vector<Complex>& trace, int sampleRate)
|
|||||||
void GLScope::initializeGL()
|
void GLScope::initializeGL()
|
||||||
{
|
{
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
m_glShaderSimple.initializeGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLScope::resizeGL(int width, int height)
|
void GLScope::resizeGL(int width, int height)
|
||||||
@ -252,6 +253,7 @@ void GLScope::paintGL()
|
|||||||
if ((m_displays == DisplayBoth) || (m_displays == DisplayFirstOnly))
|
if ((m_displays == DisplayBoth) || (m_displays == DisplayFirstOnly))
|
||||||
{
|
{
|
||||||
// draw rect around
|
// draw rect around
|
||||||
|
#ifdef GL_DEPRECATED
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
|
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
|
||||||
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
|
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
|
||||||
@ -261,13 +263,15 @@ void GLScope::paintGL()
|
|||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
glColor4f(1, 1, 1, 0.5);
|
glColor4f(1, 1, 1, 0.5);
|
||||||
|
|
||||||
#ifdef GL_DEPRECATED
|
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
glVertex2f(1, 1);
|
glVertex2f(1, 1);
|
||||||
glVertex2f(0, 1);
|
glVertex2f(0, 1);
|
||||||
glVertex2f(0, 0);
|
glVertex2f(0, 0);
|
||||||
glVertex2f(1, 0);
|
glVertex2f(1, 0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
glPopMatrix();
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
GLfloat q3[] {
|
GLfloat q3[] {
|
||||||
@ -277,23 +281,24 @@ void GLScope::paintGL()
|
|||||||
1, 0
|
1, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
QVector4D color(1.0f, 1.0f, 1.0f, 0.5f);
|
||||||
glVertexPointer(2, GL_FLOAT, 0, q3);
|
m_glShaderSimple.drawContour(m_glScopeMatrix1, color, q3, 4);
|
||||||
glDrawArrays(GL_LINE_LOOP, 0, 4);
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
glPushMatrix();
|
|
||||||
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
|
|
||||||
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
|
|
||||||
|
|
||||||
// paint grid
|
// paint grid
|
||||||
const ScaleEngine::TickList* tickList;
|
const ScaleEngine::TickList* tickList;
|
||||||
const ScaleEngine::Tick* tick;
|
const ScaleEngine::Tick* tick;
|
||||||
|
|
||||||
|
// Horizontal Y1
|
||||||
|
tickList = &m_y1Scale.getTickList();
|
||||||
|
|
||||||
|
#ifdef GL_DEPRECATED
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
|
||||||
|
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
@ -303,10 +308,7 @@ void GLScope::paintGL()
|
|||||||
} else {
|
} else {
|
||||||
glColor4f(1, 1, 1, m_displayGridIntensity / 100.0);
|
glColor4f(1, 1, 1, m_displayGridIntensity / 100.0);
|
||||||
}
|
}
|
||||||
// Horizontal Y1
|
|
||||||
tickList = &m_y1Scale.getTickList();
|
|
||||||
|
|
||||||
#ifdef GL_DEPRECATED
|
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
for(int i= 0; i < tickList->count(); i++) {
|
||||||
tick = &(*tickList)[i];
|
tick = &(*tickList)[i];
|
||||||
if(tick->major) {
|
if(tick->major) {
|
||||||
@ -319,14 +321,21 @@ void GLScope::paintGL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
GLfloat q3[4*tickList->count()];
|
GLfloat q3[4*tickList->count()];
|
||||||
int effectiveTicks = 0;
|
int effectiveTicks = 0;
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
|
||||||
|
for (int i= 0; i < tickList->count(); i++)
|
||||||
|
{
|
||||||
tick = &(*tickList)[i];
|
tick = &(*tickList)[i];
|
||||||
if(tick->major) {
|
|
||||||
if(tick->textSize > 0) {
|
if (tick->major)
|
||||||
|
{
|
||||||
|
if (tick->textSize > 0)
|
||||||
|
{
|
||||||
float y = 1 - (tick->pos / m_y1Scale.getSize());
|
float y = 1 - (tick->pos / m_y1Scale.getSize());
|
||||||
q3[4*effectiveTicks] = 0;
|
q3[4*effectiveTicks] = 0;
|
||||||
q3[4*effectiveTicks+1] = y;
|
q3[4*effectiveTicks+1] = y;
|
||||||
@ -336,21 +345,20 @@ void GLScope::paintGL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef GL_ANDROID
|
|
||||||
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
|
if (m_mode == ModeIQPolar) {
|
||||||
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
|
QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f);
|
||||||
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
|
m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks);
|
||||||
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
|
}
|
||||||
#else
|
else
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
{
|
||||||
glVertexPointer(2, GL_FLOAT, 0, q3);
|
QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f);
|
||||||
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
|
m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
|
#ifdef GL_DEPRECATED
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
|
glTranslatef(m_glScopeRect1.x(), m_glScopeRect1.y(), 0);
|
||||||
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
|
glScalef(m_glScopeRect1.width(), m_glScopeRect1.height(), 1);
|
||||||
@ -359,7 +367,6 @@ void GLScope::paintGL()
|
|||||||
glColor4f(1, 1, 1, m_displayGridIntensity / 100.0);
|
glColor4f(1, 1, 1, m_displayGridIntensity / 100.0);
|
||||||
tickList = &m_x1Scale.getTickList();
|
tickList = &m_x1Scale.getTickList();
|
||||||
|
|
||||||
#ifdef GL_DEPRECATED
|
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
for(int i= 0; i < tickList->count(); i++) {
|
||||||
tick = &(*tickList)[i];
|
tick = &(*tickList)[i];
|
||||||
if(tick->major) {
|
if(tick->major) {
|
||||||
@ -372,8 +379,13 @@ void GLScope::paintGL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
|
// Vertical X1
|
||||||
|
tickList = &m_x1Scale.getTickList();
|
||||||
|
|
||||||
GLfloat q3[4*tickList->count()];
|
GLfloat q3[4*tickList->count()];
|
||||||
int effectiveTicks = 0;
|
int effectiveTicks = 0;
|
||||||
for(int i= 0; i < tickList->count(); i++) {
|
for(int i= 0; i < tickList->count(); i++) {
|
||||||
@ -389,20 +401,11 @@ void GLScope::paintGL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef GL_ANDROID
|
|
||||||
glEnableVertexAttribArray(GL_VERTEX_ARRAY);
|
QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f);
|
||||||
glVertexAttribPointer(GL_VERTEX_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, q3);
|
m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks);
|
||||||
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
|
|
||||||
glDisableVertexAttribArray(GL_VERTEX_ARRAY);
|
|
||||||
#else
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glVertexPointer(2, GL_FLOAT, 0, q3);
|
|
||||||
glDrawArrays(GL_LINES, 0, 2*effectiveTicks);
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
glPopMatrix();
|
|
||||||
|
|
||||||
// paint left #1 scale
|
// paint left #1 scale
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user